LCOV - code coverage report
Current view: top level - svx/source/inc - fmtextcontrolshell.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 6 0.0 %
Date: 2014-04-14 Functions: 0 6 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             : #ifndef INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX
      20             : #define INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX
      21             : 
      22             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      23             : #include <com/sun/star/awt/XTextComponent.hpp>
      24             : #include <com/sun/star/frame/XStatusListener.hpp>
      25             : #include <com/sun/star/awt/XFocusListener.hpp>
      26             : #include <com/sun/star/awt/XMouseListener.hpp>
      27             : #include <com/sun/star/form/runtime/XFormController.hpp>
      28             : #include <com/sun/star/awt/XControl.hpp>
      29             : #include <com/sun/star/util/XURLTransformer.hpp>
      30             : #include <comphelper/implementationreference.hxx>
      31             : #include <tools/link.hxx>
      32             : #include <vcl/timer.hxx>
      33             : #include "fmslotinvalidator.hxx"
      34             : 
      35             : #include <vector>
      36             : #include <map>
      37             : 
      38             : class SfxRequest;
      39             : class SfxItemSet;
      40             : class SfxAllItemSet;
      41             : class SfxBindings;
      42             : class SfxViewFrame;
      43             : class SfxApplication;
      44             : 
      45             : 
      46             : namespace svx
      47             : {
      48             : 
      49             : 
      50             :     class FmFocusListenerAdapter;
      51             :     class FmTextControlFeature;
      52             :     class FmMouseListenerAdapter;
      53             : 
      54             : 
      55             :     //= IFocusObserver
      56             : 
      57           0 :     class IFocusObserver
      58             :     {
      59             :     public:
      60             :         virtual void    focusGained( const ::com::sun::star::awt::FocusEvent& _rEvent ) = 0;
      61             :         virtual void    focusLost( const ::com::sun::star::awt::FocusEvent& _rEvent ) = 0;
      62             : 
      63             :     protected:
      64           0 :         ~IFocusObserver() {}
      65             :     };
      66             : 
      67             : 
      68             :     //= IFocusObserver
      69             : 
      70           0 :     class IContextRequestObserver
      71             :     {
      72             :     public:
      73             :         virtual void    contextMenuRequested( const ::com::sun::star::awt::MouseEvent& _rEvent ) = 0;
      74             : 
      75             :     protected:
      76           0 :         ~IContextRequestObserver() {}
      77             :     };
      78             : 
      79             : 
      80             :     //= FmTextControlShell
      81             : 
      82             :     class FmTextControlShell :public IFocusObserver
      83             :                              ,public ISlotInvalidator
      84             :                              ,public IContextRequestObserver
      85             :     {
      86             :     private:
      87             :         ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer >             m_xURLTransformer;
      88             :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >                     m_xActiveControl;
      89             :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >               m_xActiveTextComponent;
      90             :         ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >    m_xActiveController;
      91             : #ifndef DONT_REMEMBER_LAST_CONTROL
      92             :         // without this define, m_xActiveControl remembers the *last* active control, even
      93             :         // if it, in the meantime, already lost the focus
      94             :         bool                                                                        m_bActiveControl;
      95             :             // so we need an additional boolean flag telling whether the active cotrol
      96             :             // is really focused
      97             : #endif
      98             :         bool                                                                        m_bActiveControlIsReadOnly;
      99             :         bool                                                                        m_bActiveControlIsRichText;
     100             : 
     101             :         // listening at all controls of the active controller for focus changes
     102             :         typedef ::comphelper::ImplementationReference< FmFocusListenerAdapter, ::com::sun::star::awt::XFocusListener >
     103             :                                                                                     FocusListenerAdapter;
     104             :         typedef ::std::vector< FocusListenerAdapter >                               FocusListenerAdapters;
     105             :         FocusListenerAdapters                                                       m_aControlObservers;
     106             : 
     107             :         typedef ::comphelper::ImplementationReference< FmMouseListenerAdapter, ::com::sun::star::awt::XMouseListener >
     108             :                                                                                     MouseListenerAdapter;
     109             :         MouseListenerAdapter                                                        m_aContextMenuObserver;
     110             : 
     111             :         // translating between "slots" of the framework and "features" of the active control
     112             :         typedef ::comphelper::ImplementationReference< FmTextControlFeature, ::com::sun::star::frame::XStatusListener >
     113             :                                                                                     ControlFeature;
     114             :         typedef ::std::map< SfxSlotId, ControlFeature, ::std::less< SfxSlotId > >   ControlFeatures;
     115             :         ControlFeatures                                                             m_aControlFeatures;
     116             : 
     117             :         SfxViewFrame*                                                               m_pViewFrame;
     118             :         // invalidating slots
     119             :         SfxBindings&                                                                m_rBindings;
     120             :         Link                                                                        m_aControlActivationHandler;
     121             :         AutoTimer                                                                   m_aClipboardInvalidation;
     122             :         bool                                                                        m_bNeedClipboardInvalidation;
     123             : 
     124             :     public:
     125             :         FmTextControlShell( SfxViewFrame* _pFrame );
     126             :         virtual ~FmTextControlShell();
     127             : 
     128             :         // clean up any resources associated with this instance
     129             :         void    dispose();
     130             : 
     131             :         void    ExecuteTextAttribute( SfxRequest& _rReq );
     132             :         void    GetTextAttributeState( SfxItemSet& _rSet );
     133             :         bool    IsActiveControl( bool _bCountRichTextOnly = false ) const;
     134             :         void    ForgetActiveControl();
     135           0 :         void    SetControlActivationHandler( const Link& _rHdl ) { m_aControlActivationHandler = _rHdl; }
     136             : 
     137             :         /** to be called when a form in our document has been activated
     138             :         */
     139             :         void    formActivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController );
     140             :         /** to be called when a form in our document has been deactivated
     141             :         */
     142             :         void    formDeactivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController );
     143             : 
     144             :         /** notifies the instance that the design mode has changed
     145             :         */
     146             :         void    designModeChanged( bool _bNewDesignMode );
     147             : 
     148             :     protected:
     149             :         // IFocusObserver
     150             :         virtual void    focusGained( const ::com::sun::star::awt::FocusEvent& _rEvent ) SAL_OVERRIDE;
     151             :         virtual void    focusLost( const ::com::sun::star::awt::FocusEvent& _rEvent ) SAL_OVERRIDE;
     152             : 
     153             :         // IContextRequestObserver
     154             :         virtual void    contextMenuRequested( const ::com::sun::star::awt::MouseEvent& _rEvent ) SAL_OVERRIDE;
     155             : 
     156             :         // ISlotInvalidator
     157             :         virtual void    Invalidate( SfxSlotId _nSlot ) SAL_OVERRIDE;
     158             : 
     159             :     protected:
     160             :         enum AttributeSet { eCharAttribs, eParaAttribs };
     161             :         void    executeAttributeDialog( AttributeSet _eSet, SfxRequest& _rReq );
     162             :         bool    executeSelectAll( );
     163             :         bool    executeClipboardSlot( SfxSlotId _nSlot );
     164             : 
     165             :     private:
     166           0 :         inline  bool    isControllerListening() const { return !m_aControlObservers.empty(); }
     167             : 
     168             :         FmTextControlFeature*
     169             :                         implGetFeatureDispatcher(
     170             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& _rxProvider,
     171             :                             SfxApplication* _pApplication,
     172             :                             SfxSlotId _nSlot
     173             :                         );
     174             : 
     175             :         // fills the given structure with dispatchers for the given slots, for the given control
     176             :         void            fillFeatureDispatchers(
     177             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > _rxControl,
     178             :                             SfxSlotId* _pZeroTerminatedSlots,
     179             :                             ControlFeatures& _rDispatchers
     180             :                         );
     181             : 
     182             :         /// creates SfxPoolItes for all features in the given set, and puts them into the given SfxAllItemSet
     183             :         void            transferFeatureStatesToItemSet(
     184             :                             ControlFeatures& _rDispatchers,
     185             :                             SfxAllItemSet& _rSet,
     186             :                             bool _bTranslateLatin = false
     187             :                         );
     188             : 
     189             :         /// to be called when a control has been activated
     190             :         void    controlActivated( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl );
     191             :         /// to be called when the currently active control has been deactivated
     192             :         void    controlDeactivated( );
     193             : 
     194             :         void    implClearActiveControlRef();
     195             : 
     196             :         /** starts listening at all controls of the given controller for focus events
     197             :         @precond
     198             :             we don't have an active controller currently
     199             :         */
     200             :         void    startControllerListening( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController );
     201             :         /** stops listening at the active controller
     202             :         @precond
     203             :             we have an active controller currently
     204             :         */
     205             :         void    stopControllerListening( );
     206             : 
     207             :         /** parses the given URL's Complete member, by calling XURLTransformer::parseString
     208             :         */
     209             :         void    impl_parseURL_nothrow( ::com::sun::star::util::URL& _rURL );
     210             : 
     211             :         DECL_LINK( OnInvalidateClipboard, void* );
     212             :     };
     213             : 
     214             : 
     215             : } // namespace svx
     216             : 
     217             : 
     218             : #endif // INCLUDED_SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX
     219             : 
     220             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10