LCOV - code coverage report
Current view: top level - svx/inc - tbunosearchcontrollers.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 6 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 6 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef __TBUNOSEARCHCONTROLLERS_HXX_
      30                 :            : #define __TBUNOSEARCHCONTROLLERS_HXX_
      31                 :            : 
      32                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      33                 :            : #include <com/sun/star/frame/DispatchDescriptor.hpp>
      34                 :            : #include <com/sun/star/frame/XDispatch.hpp>
      35                 :            : #include <com/sun/star/frame/XDispatchHelper.hpp>
      36                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      37                 :            : #include <com/sun/star/frame/XStatusListener.hpp>
      38                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      39                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      40                 :            : 
      41                 :            : #include <comphelper/sequenceasvector.hxx>
      42                 :            : #include <cppuhelper/implbase1.hxx>
      43                 :            : #include <cppuhelper/weak.hxx>
      44                 :            : #include <svtools/toolboxcontroller.hxx>
      45                 :            : #include <vcl/combobox.hxx>
      46                 :            : #include <vcl/window.hxx>
      47                 :            : 
      48                 :            : #include <map>
      49                 :            : #include <vector>
      50                 :            : 
      51                 :            : namespace css = ::com::sun::star        ;
      52                 :            : namespace svx
      53                 :            : {
      54                 :            : 
      55                 :            : class FindTextFieldControl : public ComboBox
      56                 :            : {
      57                 :            : public:
      58                 :            :     FindTextFieldControl( Window* pParent, WinBits nStyle,
      59                 :            :         css::uno::Reference< css::frame::XFrame >& xFrame,
      60                 :            :         css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
      61                 :            :     virtual ~FindTextFieldControl();
      62                 :            : 
      63                 :            :     virtual void Modify();
      64                 :            :     virtual long PreNotify( NotifyEvent& rNEvt );
      65                 :            : 
      66                 :            :     void InitControls_Impl();
      67                 :            :     void Remember_Impl(const String& rStr);
      68                 :            :     void SetTextToSelected_Impl();
      69                 :            : 
      70                 :            : private:
      71                 :            : 
      72                 :            :     css::uno::Reference< css::frame::XFrame > m_xFrame;
      73                 :            :     css::uno::Reference< css::lang::XMultiServiceFactory > m_xServiceManager;
      74                 :            :     sal_Bool m_bToClearTextField;
      75                 :            : 
      76                 :            : };
      77                 :            : 
      78                 :            : class SearchToolbarControllersManager
      79                 :            : {
      80                 :            : public:
      81                 :            : 
      82                 :            :     SearchToolbarControllersManager();
      83                 :            :     ~SearchToolbarControllersManager();
      84                 :            : 
      85                 :            :     static SearchToolbarControllersManager& createControllersManager();
      86                 :            : 
      87                 :            :     void registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL );
      88                 :            :     void freeController ( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL );
      89                 :            :     css::uno::Reference< css::frame::XStatusListener > findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL );
      90                 :            : 
      91                 :            :     void saveSearchHistory(const FindTextFieldControl* m_pFindTextFieldControl);
      92                 :            :     void loadSearchHistory(FindTextFieldControl* m_pFindTextFieldControl);
      93                 :            : 
      94                 :            : private:
      95                 :            : 
      96                 :            :     typedef ::comphelper::SequenceAsVector< css::beans::PropertyValue > SearchToolbarControllersVec;
      97                 :            :     typedef ::std::map< css::uno::Reference< css::frame::XFrame >, SearchToolbarControllersVec > SearchToolbarControllersMap;
      98                 :            :     SearchToolbarControllersMap aSearchToolbarControllersMap;
      99                 :            :     std::vector<rtl::OUString> m_aSearchStrings;
     100                 :            : 
     101                 :            : };
     102                 :            : 
     103                 :            : class FindTextToolbarController : public svt::ToolboxController,
     104                 :            :                                   public css::lang::XServiceInfo
     105                 :            : {
     106                 :            : public:
     107                 :            : 
     108                 :            :     FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager );
     109                 :            :     ~FindTextToolbarController();
     110                 :            : 
     111                 :            :     // XInterface
     112                 :            :     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
     113                 :            :     virtual void SAL_CALL acquire() throw ();
     114                 :            :     virtual void SAL_CALL release() throw ();
     115                 :            : 
     116                 :            :     // XServiceInfo
     117                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
     118                 :            :     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
     119                 :            :     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
     120                 :            : 
     121                 :          9 :     static ::rtl::OUString getImplementationName_Static() throw()
     122                 :            :     {
     123                 :          9 :         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.svx.FindTextToolboxController" ));
     124                 :            :     }
     125                 :            : 
     126                 :            :     static ::com::sun::star::uno::Sequence< ::rtl::OUString >  getSupportedServiceNames_Static() throw();
     127                 :            : 
     128                 :            :     // XComponent
     129                 :            :     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
     130                 :            : 
     131                 :            :     // XInitialization
     132                 :            :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
     133                 :            : 
     134                 :            :     // XToolbarController
     135                 :            :     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException);
     136                 :            :     virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException );
     137                 :            : 
     138                 :            :     // XStatusListener
     139                 :            :     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException );
     140                 :            : 
     141                 :            :     DECL_LINK(EditModifyHdl, void*);
     142                 :            : 
     143                 :            : private:
     144                 :            : 
     145                 :            :     FindTextFieldControl* m_pFindTextFieldControl;
     146                 :            : 
     147                 :            :     sal_uInt16 m_nDownSearchId; // item position of findbar
     148                 :            :     sal_uInt16 m_nUpSearchId;   // item position of findbar
     149                 :            : 
     150                 :            : };
     151                 :            : 
     152                 :            : class UpDownSearchToolboxController : public svt::ToolboxController,
     153                 :            :                                       public css::lang::XServiceInfo
     154                 :            : {
     155                 :            : public:
     156                 :            :     enum Type { UP, DOWN };
     157                 :            : 
     158                 :            :     UpDownSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager, Type eType );
     159                 :            :     ~UpDownSearchToolboxController();
     160                 :            : 
     161                 :            :     // XInterface
     162                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
     163                 :            :     virtual void SAL_CALL acquire() throw ();
     164                 :            :     virtual void SAL_CALL release() throw ();
     165                 :            : 
     166                 :            :     // XServiceInfo
     167                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
     168                 :            :     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
     169                 :            :     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
     170                 :            : 
     171                 :         18 :     static ::rtl::OUString getImplementationName_Static( Type eType ) throw()
     172                 :            :     {
     173                 :            :         return eType == UP? ::rtl::OUString( "com.sun.star.svx.UpSearchToolboxController" ) :
     174 [ +  + ][ +  + ]:         18 :                             ::rtl::OUString( "com.sun.star.svx.DownSearchToolboxController" );
                 [ +  + ]
     175                 :            :     }
     176                 :            : 
     177                 :            :     static css::uno::Sequence< ::rtl::OUString >  getSupportedServiceNames_Static() throw();
     178                 :            : 
     179                 :            :     // XComponent
     180                 :            :     virtual void SAL_CALL dispose() throw ( css::uno::RuntimeException );
     181                 :            : 
     182                 :            :     // XInitialization
     183                 :            :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException);
     184                 :            : 
     185                 :            :     // XToolbarController
     186                 :            :     virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw ( css::uno::RuntimeException );
     187                 :            : 
     188                 :            :     // XStatusListener
     189                 :            :     virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException );
     190                 :            : 
     191                 :            : private:
     192                 :            :     Type meType;
     193                 :            : };
     194                 :            : 
     195                 :            : // protocol handler for "vnd.sun.star.findbar:*" URLs
     196                 :            : // The dispatch object will be used for shortcut commands for findbar
     197                 :            : class FindbarDispatcher : public css::lang::XServiceInfo,
     198                 :            :                           public css::lang::XInitialization,
     199                 :            :                           public css::frame::XDispatchProvider,
     200                 :            :                           public css::frame::XDispatch,
     201                 :            :                           public ::cppu::OWeakObject
     202                 :            : {
     203                 :            : public:
     204                 :            : 
     205                 :            :     FindbarDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
     206                 :            :     virtual ~FindbarDispatcher();
     207                 :            : 
     208                 :            :     // XInterface
     209                 :            :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException );
     210                 :            :     virtual void SAL_CALL acquire() throw();
     211                 :            :     virtual void SAL_CALL release() throw();
     212                 :            : 
     213                 :            :     // XServiceInfo
     214                 :            :     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
     215                 :            :     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException );
     216                 :            :     virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
     217                 :            : 
     218                 :         11 :     static ::rtl::OUString getImplementationName_Static() throw()
     219                 :            :     {
     220                 :         11 :         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.Impl.FindbarDispatcher" ));
     221                 :            :     }
     222                 :            : 
     223                 :            :     static css::uno::Sequence< ::rtl::OUString >  getSupportedServiceNames_Static() throw();
     224                 :            : 
     225                 :            :     // XInitialization
     226                 :            :     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException );
     227                 :            : 
     228                 :            :     // XDispatchProvider
     229                 :            :     virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL, const ::rtl::OUString& sTargetFrameName , sal_Int32 nSearchFlags ) throw( css::uno::RuntimeException );
     230                 :            :     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 );
     231                 :            : 
     232                 :            :     // XDispatch
     233                 :            :     virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException );
     234                 :            :     virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException );
     235                 :            :     virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener, const css::util::URL& aURL ) throw( css::uno::RuntimeException );
     236                 :            : 
     237                 :            : private:
     238                 :            : 
     239                 :            :     css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory;
     240                 :            :     css::uno::Reference< css::frame::XFrame > m_xFrame;
     241                 :            : 
     242                 :            : };
     243                 :            : 
     244                 :            : // createInstance
     245                 :            : css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     246                 :            : css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     247                 :            : css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     248                 :            : css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr );
     249                 :            : 
     250                 :            : }
     251                 :            : 
     252                 :            : #endif // __TBUNOSEARCHCONTROLLERS_HXX_
     253                 :            : 
     254                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10