LCOV - code coverage report
Current view: top level - svx/source/form - fmtextcontrolshell.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 138 483 28.6 %
Date: 2012-08-25 Functions: 22 50 44.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 107 791 13.5 %

           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                 :            : 
      30                 :            : #include "fmprop.hrc"
      31                 :            : #include "svx/fmresids.hrc"
      32                 :            : #include "fmtextcontroldialogs.hxx"
      33                 :            : #include "fmtextcontrolfeature.hxx"
      34                 :            : #include "fmtextcontrolshell.hxx"
      35                 :            : #include "editeng/crsditem.hxx"
      36                 :            : #include "svx/dialmgr.hxx"
      37                 :            : #include "editeng/editeng.hxx"
      38                 :            : #include "editeng/eeitem.hxx"
      39                 :            : #include "svx/fmglob.hxx"
      40                 :            : #include "editeng/scriptspaceitem.hxx"
      41                 :            : #include "svx/svxids.hrc"
      42                 :            : #include "editeng/udlnitem.hxx"
      43                 :            : 
      44                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      45                 :            : #include <com/sun/star/awt/FontDescriptor.hpp>
      46                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      47                 :            : #include <com/sun/star/form/XForm.hpp>
      48                 :            : #include <com/sun/star/container/XChild.hpp>
      49                 :            : #include <com/sun/star/awt/XFocusListener.hpp>
      50                 :            : #include <com/sun/star/awt/XMouseListener.hpp>
      51                 :            : #include <com/sun/star/util/URLTransformer.hpp>
      52                 :            : 
      53                 :            : #include <comphelper/componentcontext.hxx>
      54                 :            : #include <comphelper/processfactory.hxx>
      55                 :            : #include <cppuhelper/implbase1.hxx>
      56                 :            : #include <sfx2/app.hxx>
      57                 :            : #include <sfx2/bindings.hxx>
      58                 :            : #include <sfx2/dispatch.hxx>
      59                 :            : #include <sfx2/msgpool.hxx>
      60                 :            : #include <sfx2/objsh.hxx>
      61                 :            : #include <sfx2/request.hxx>
      62                 :            : #include <sfx2/sfxuno.hxx>
      63                 :            : #include <sfx2/viewfrm.hxx>
      64                 :            : #include <svl/eitem.hxx>
      65                 :            : #include <svl/intitem.hxx>
      66                 :            : #include <svl/itempool.hxx>
      67                 :            : #include <svl/languageoptions.hxx>
      68                 :            : #include <svtools/stringtransfer.hxx>
      69                 :            : #include <svl/whiter.hxx>
      70                 :            : #include <toolkit/helper/vclunohelper.hxx>
      71                 :            : #include <tools/diagnose_ex.h>
      72                 :            : #include <vcl/msgbox.hxx>
      73                 :            : #include <vcl/outdev.hxx>
      74                 :            : #include <osl/mutex.hxx>
      75                 :            : 
      76                 :            : #include <memory>
      77                 :            : 
      78                 :            : //........................................................................
      79                 :            : namespace svx
      80                 :            : {
      81                 :            : //........................................................................
      82                 :            : 
      83                 :            :     using namespace ::com::sun::star;
      84                 :            :     using namespace ::com::sun::star::uno;
      85                 :            :     using namespace ::com::sun::star::awt;
      86                 :            :     using namespace ::com::sun::star::form;
      87                 :            :     using namespace ::com::sun::star::form::runtime;
      88                 :            :     using namespace ::com::sun::star::lang;
      89                 :            :     using namespace ::com::sun::star::frame;
      90                 :            :     using namespace ::com::sun::star::util;
      91                 :            :     using namespace ::com::sun::star::beans;
      92                 :            :     using namespace ::com::sun::star::container;
      93                 :            : 
      94                 :            :     //====================================================================
      95                 :            :     typedef sal_uInt16 WhichId;
      96                 :            : 
      97                 :            :     //====================================================================
      98                 :            :     static SfxSlotId pTextControlSlots[] =
      99                 :            :     {
     100                 :            :         SID_CLIPBOARD_FORMAT_ITEMS,
     101                 :            :         SID_CUT,
     102                 :            :         SID_COPY,
     103                 :            :         SID_PASTE,
     104                 :            :         SID_SELECTALL,
     105                 :            : //        SID_ATTR_TABSTOP,           /* 2 */
     106                 :            :         SID_ATTR_CHAR_FONT,
     107                 :            :         SID_ATTR_CHAR_POSTURE,
     108                 :            :         SID_ATTR_CHAR_WEIGHT,
     109                 :            :         SID_ATTR_CHAR_SHADOWED,
     110                 :            :         SID_ATTR_CHAR_WORDLINEMODE,
     111                 :            :         SID_ATTR_CHAR_CONTOUR,
     112                 :            :         SID_ATTR_CHAR_STRIKEOUT,
     113                 :            :         SID_ATTR_CHAR_UNDERLINE,
     114                 :            :         SID_ATTR_CHAR_FONTHEIGHT,
     115                 :            :         SID_ATTR_CHAR_COLOR,
     116                 :            :         SID_ATTR_CHAR_KERNING,
     117                 :            :         SID_ATTR_CHAR_LANGUAGE,     /* 20 */
     118                 :            :         SID_ATTR_CHAR_ESCAPEMENT,
     119                 :            :         SID_ATTR_PARA_ADJUST,       /* 28 */
     120                 :            :         SID_ATTR_PARA_ADJUST_LEFT,
     121                 :            :         SID_ATTR_PARA_ADJUST_RIGHT,
     122                 :            :         SID_ATTR_PARA_ADJUST_CENTER,
     123                 :            :         SID_ATTR_PARA_ADJUST_BLOCK,
     124                 :            :         SID_ATTR_PARA_LINESPACE,    /* 33 */
     125                 :            :         SID_ATTR_PARA_LINESPACE_10,
     126                 :            :         SID_ATTR_PARA_LINESPACE_15,
     127                 :            :         SID_ATTR_PARA_LINESPACE_20,
     128                 :            :         SID_ATTR_LRSPACE,           /* 48 */
     129                 :            :         SID_ATTR_ULSPACE,           /* 49 */
     130                 :            :         SID_ATTR_CHAR_AUTOKERN,
     131                 :            :         SID_SET_SUPER_SCRIPT,
     132                 :            :         SID_SET_SUB_SCRIPT,
     133                 :            :         SID_CHAR_DLG,
     134                 :            :         SID_PARA_DLG,
     135                 :            : //        SID_TEXTDIRECTION_LEFT_TO_RIGHT, /* 907 */
     136                 :            : //        SID_TEXTDIRECTION_TOP_TO_BOTTOM,
     137                 :            :         SID_ATTR_CHAR_SCALEWIDTH,       /* 911 */
     138                 :            :         SID_ATTR_CHAR_RELIEF,
     139                 :            :         SID_ATTR_PARA_LEFT_TO_RIGHT,    /* 950 */
     140                 :            :         SID_ATTR_PARA_RIGHT_TO_LEFT,
     141                 :            :         SID_ATTR_CHAR_OVERLINE,
     142                 :            :         0
     143                 :            :     };
     144                 :            : 
     145                 :            :     // slots which we are not responsible for on the SfxShell level, but
     146                 :            :     // need to handle during the "paragraph attributes" and/or "character
     147                 :            :     // attributes" dialogs
     148                 :            :     static SfxSlotId pDialogSlots[] =
     149                 :            :     {
     150                 :            :         SID_ATTR_TABSTOP,
     151                 :            :         SID_ATTR_PARA_HANGPUNCTUATION,
     152                 :            :         SID_ATTR_PARA_FORBIDDEN_RULES,
     153                 :            :         SID_ATTR_PARA_SCRIPTSPACE,
     154                 :            :         SID_ATTR_CHAR_LATIN_LANGUAGE,
     155                 :            :         SID_ATTR_CHAR_CJK_LANGUAGE,
     156                 :            :         SID_ATTR_CHAR_CTL_LANGUAGE,
     157                 :            :         SID_ATTR_CHAR_LATIN_FONT,
     158                 :            :         SID_ATTR_CHAR_CJK_FONT,
     159                 :            :         SID_ATTR_CHAR_CTL_FONT,
     160                 :            :         SID_ATTR_CHAR_LATIN_FONTHEIGHT,
     161                 :            :         SID_ATTR_CHAR_CJK_FONTHEIGHT,
     162                 :            :         SID_ATTR_CHAR_CTL_FONTHEIGHT,
     163                 :            :         SID_ATTR_CHAR_LATIN_WEIGHT,
     164                 :            :         SID_ATTR_CHAR_CJK_WEIGHT,
     165                 :            :         SID_ATTR_CHAR_CTL_WEIGHT,
     166                 :            :         SID_ATTR_CHAR_LATIN_POSTURE,
     167                 :            :         SID_ATTR_CHAR_CJK_POSTURE,
     168                 :            :         SID_ATTR_CHAR_CTL_POSTURE,
     169                 :            :         SID_ATTR_CHAR_EMPHASISMARK,
     170                 :            :         0
     171                 :            :     };
     172                 :            : 
     173                 :            :     //====================================================================
     174                 :            :     //= FmFocusListenerAdapter
     175                 :            :     //====================================================================
     176                 :            :     typedef ::cppu::WeakImplHelper1 <   XFocusListener
     177                 :            :                                     >   FmFocusListenerAdapter_Base;
     178                 :            :     class FmFocusListenerAdapter : public FmFocusListenerAdapter_Base
     179                 :            :     {
     180                 :            :     private:
     181                 :            :         IFocusObserver*         m_pObserver;
     182                 :            :         Reference< XWindow >    m_xWindow;
     183                 :            : 
     184                 :            :     public:
     185                 :            :         FmFocusListenerAdapter( const Reference< XControl >& _rxControl, IFocusObserver* _pObserver );
     186                 :            : 
     187                 :            :         // clean up the instance
     188                 :            :         void    dispose();
     189                 :            : 
     190                 :            :     protected:
     191                 :            :         ~FmFocusListenerAdapter();
     192                 :            : 
     193                 :            :     protected:
     194                 :            :         virtual void SAL_CALL focusGained( const FocusEvent& e ) throw (RuntimeException);
     195                 :            :         virtual void SAL_CALL focusLost( const FocusEvent& e ) throw (RuntimeException);
     196                 :            :         virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
     197                 :            :     };
     198                 :            : 
     199                 :            :     //--------------------------------------------------------------------
     200                 :            :     DBG_NAME( FmFocusListenerAdapter )
     201                 :            :     //--------------------------------------------------------------------
     202                 :         18 :     FmFocusListenerAdapter::FmFocusListenerAdapter( const Reference< XControl >& _rxControl, IFocusObserver* _pObserver )
     203                 :            :         :m_pObserver( _pObserver )
     204         [ +  - ]:         18 :         ,m_xWindow( _rxControl, UNO_QUERY )
     205                 :            :     {
     206                 :            :         DBG_CTOR( FmFocusListenerAdapter, NULL );
     207                 :            : 
     208                 :            :         DBG_ASSERT( m_xWindow.is(), "FmFocusListenerAdapter::FmFocusListenerAdapter: invalid control!" );
     209         [ +  - ]:         18 :         osl_incrementInterlockedCount( &m_refCount );
     210                 :            :         {
     211                 :            :             try
     212                 :            :             {
     213         [ +  - ]:         18 :                 if ( m_xWindow.is() )
     214 [ +  - ][ +  - ]:         18 :                     m_xWindow->addFocusListener( this );
         [ +  - ][ #  # ]
     215                 :            :             }
     216         [ #  # ]:          0 :             catch( const Exception& )
     217                 :            :             {
     218                 :            :                 DBG_UNHANDLED_EXCEPTION();
     219                 :            :             }
     220                 :            :         }
     221         [ +  - ]:         18 :         osl_decrementInterlockedCount( &m_refCount );
     222                 :         18 :     }
     223                 :            : 
     224                 :            :     //--------------------------------------------------------------------
     225                 :         18 :     FmFocusListenerAdapter::~FmFocusListenerAdapter()
     226                 :            :     {
     227                 :         18 :         acquire();
     228         [ +  - ]:         18 :         dispose();
     229                 :            : 
     230                 :            :         DBG_DTOR( FmFocusListenerAdapter, NULL );
     231         [ -  + ]:         36 :     }
     232                 :            : 
     233                 :            :     //--------------------------------------------------------------------
     234                 :         36 :     void FmFocusListenerAdapter::dispose()
     235                 :            :     {
     236         [ +  + ]:         36 :         if ( m_xWindow.is() )
     237                 :            :         {
     238         [ +  - ]:         18 :             m_xWindow->removeFocusListener( this );
     239                 :         18 :             m_xWindow.clear();
     240                 :            :         }
     241                 :         36 :     }
     242                 :            : 
     243                 :            :     //--------------------------------------------------------------------
     244                 :          0 :     void SAL_CALL FmFocusListenerAdapter::focusGained( const FocusEvent& e ) throw (RuntimeException)
     245                 :            :     {
     246         [ #  # ]:          0 :         if ( m_pObserver )
     247                 :          0 :             m_pObserver->focusGained( e );
     248                 :          0 :     }
     249                 :            : 
     250                 :            :     //--------------------------------------------------------------------
     251                 :          6 :     void SAL_CALL FmFocusListenerAdapter::focusLost( const FocusEvent& e ) throw (RuntimeException)
     252                 :            :     {
     253         [ +  - ]:          6 :         if ( m_pObserver )
     254                 :          6 :             m_pObserver->focusLost( e );
     255                 :          6 :     }
     256                 :            : 
     257                 :            :     //--------------------------------------------------------------------
     258                 :          0 :     void SAL_CALL FmFocusListenerAdapter::disposing( const EventObject& Source ) throw (RuntimeException)
     259                 :            :     {
     260                 :            :         (void)Source;
     261                 :            :         DBG_ASSERT( Source.Source == m_xWindow, "FmFocusListenerAdapter::disposing: where did this come from?" );
     262                 :          0 :         m_xWindow.clear();
     263                 :          0 :     }
     264                 :            : 
     265                 :            :     //====================================================================
     266                 :            :     //= FmMouseListenerAdapter
     267                 :            :     //====================================================================
     268                 :            :     typedef ::cppu::WeakImplHelper1 <   XMouseListener
     269                 :            :                                     >   FmMouseListenerAdapter_Base;
     270                 :            :     class FmMouseListenerAdapter : public FmMouseListenerAdapter_Base
     271                 :            :     {
     272                 :            :     private:
     273                 :            :         IContextRequestObserver*  m_pObserver;
     274                 :            :         Reference< XWindow >    m_xWindow;
     275                 :            : 
     276                 :            :     public:
     277                 :            :         FmMouseListenerAdapter( const Reference< XControl >& _rxControl, IContextRequestObserver* _pObserver );
     278                 :            : 
     279                 :            :         // clean up the instance
     280                 :            :         void    dispose();
     281                 :            : 
     282                 :            :     protected:
     283                 :            :         ~FmMouseListenerAdapter();
     284                 :            : 
     285                 :            :     protected:
     286                 :            :         virtual void SAL_CALL mousePressed( const awt::MouseEvent& e ) throw (RuntimeException);
     287                 :            :         virtual void SAL_CALL mouseReleased( const awt::MouseEvent& e ) throw (RuntimeException);
     288                 :            :         virtual void SAL_CALL mouseEntered( const awt::MouseEvent& e ) throw (RuntimeException);
     289                 :            :         virtual void SAL_CALL mouseExited( const awt::MouseEvent& e ) throw (RuntimeException);
     290                 :            :         virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
     291                 :            :     };
     292                 :            : 
     293                 :            :     //====================================================================
     294                 :            :     //= FmMouseListenerAdapter
     295                 :            :     //====================================================================
     296                 :            :     //--------------------------------------------------------------------
     297                 :            :     DBG_NAME( FmMouseListenerAdapter )
     298                 :            :     //--------------------------------------------------------------------
     299                 :          0 :     FmMouseListenerAdapter::FmMouseListenerAdapter( const Reference< XControl >& _rxControl, IContextRequestObserver* _pObserver )
     300                 :            :         :m_pObserver( _pObserver )
     301         [ #  # ]:          0 :         ,m_xWindow( _rxControl, UNO_QUERY )
     302                 :            :     {
     303                 :            :         DBG_CTOR( FmMouseListenerAdapter, NULL );
     304                 :            : 
     305                 :            :         DBG_ASSERT( m_xWindow.is(), "FmMouseListenerAdapter::FmMouseListenerAdapter: invalid control!" );
     306         [ #  # ]:          0 :         osl_incrementInterlockedCount( &m_refCount );
     307                 :            :         {
     308                 :            :             try
     309                 :            :             {
     310         [ #  # ]:          0 :                 if ( m_xWindow.is() )
     311 [ #  # ][ #  # ]:          0 :                     m_xWindow->addMouseListener( this );
         [ #  # ][ #  # ]
     312                 :            :             }
     313         [ #  # ]:          0 :             catch( const Exception& )
     314                 :            :             {
     315                 :            :                 DBG_UNHANDLED_EXCEPTION();
     316                 :            :             }
     317                 :            :         }
     318         [ #  # ]:          0 :         osl_decrementInterlockedCount( &m_refCount );
     319                 :          0 :     }
     320                 :            : 
     321                 :            :     //--------------------------------------------------------------------
     322                 :          0 :     FmMouseListenerAdapter::~FmMouseListenerAdapter()
     323                 :            :     {
     324                 :          0 :         acquire();
     325         [ #  # ]:          0 :         dispose();
     326                 :            : 
     327                 :            :         DBG_DTOR( FmMouseListenerAdapter, NULL );
     328         [ #  # ]:          0 :     }
     329                 :            : 
     330                 :            :     //--------------------------------------------------------------------
     331                 :          0 :     void FmMouseListenerAdapter::dispose()
     332                 :            :     {
     333         [ #  # ]:          0 :         if ( m_xWindow.is() )
     334                 :            :         {
     335         [ #  # ]:          0 :             m_xWindow->removeMouseListener( this );
     336                 :          0 :             m_xWindow.clear();
     337                 :            :         }
     338                 :          0 :     }
     339                 :            : 
     340                 :            :     //--------------------------------------------------------------------
     341                 :          0 :     void SAL_CALL FmMouseListenerAdapter::mousePressed( const awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException)
     342                 :            :     {
     343         [ #  # ]:          0 :         SolarMutexGuard aGuard;
     344                 :            :         // is this a request for a context menu?
     345         [ #  # ]:          0 :         if ( _rEvent.PopupTrigger )
     346                 :            :         {
     347         [ #  # ]:          0 :             if ( m_pObserver )
     348         [ #  # ]:          0 :                 m_pObserver->contextMenuRequested( _rEvent );
     349         [ #  # ]:          0 :         }
     350                 :          0 :     }
     351                 :            : 
     352                 :            :     //--------------------------------------------------------------------
     353                 :          0 :     void SAL_CALL FmMouseListenerAdapter::mouseReleased( const awt::MouseEvent& /*e*/ ) throw (::com::sun::star::uno::RuntimeException)
     354                 :            :     {
     355                 :            :         // not interested in
     356                 :          0 :     }
     357                 :            : 
     358                 :            :     //--------------------------------------------------------------------
     359                 :          0 :     void SAL_CALL FmMouseListenerAdapter::mouseEntered( const awt::MouseEvent& /*e*/ ) throw (::com::sun::star::uno::RuntimeException)
     360                 :            :     {
     361                 :            :         // not interested in
     362                 :          0 :     }
     363                 :            : 
     364                 :            :     //--------------------------------------------------------------------
     365                 :          0 :     void SAL_CALL FmMouseListenerAdapter::mouseExited( const awt::MouseEvent& /*e*/ ) throw (::com::sun::star::uno::RuntimeException)
     366                 :            :     {
     367                 :            :         // not interested in
     368                 :          0 :     }
     369                 :            : 
     370                 :            :     //--------------------------------------------------------------------
     371                 :          0 :     void SAL_CALL FmMouseListenerAdapter::disposing( const EventObject& Source ) throw (RuntimeException)
     372                 :            :     {
     373                 :            :         (void)Source;
     374                 :            :         DBG_ASSERT( Source.Source == m_xWindow, "FmMouseListenerAdapter::disposing: where did this come from?" );
     375                 :          0 :         m_xWindow.clear();
     376                 :          0 :     }
     377                 :            : 
     378                 :            :     //====================================================================
     379                 :            :     //= FmTextControlShell
     380                 :            :     //====================================================================
     381                 :            :     //------------------------------------------------------------------------
     382                 :            :     namespace
     383                 :            :     {
     384                 :            :         //....................................................................
     385                 :          0 :         void lcl_translateUnoStateToItem( SfxSlotId _nSlot, const Any& _rUnoState, SfxItemSet& _rSet )
     386                 :            :         {
     387                 :          0 :             WhichId nWhich = _rSet.GetPool()->GetWhich( _nSlot );
     388         [ #  # ]:          0 :             if ( !_rUnoState.hasValue() )
     389                 :            :             {
     390 [ #  # ][ #  # ]:          0 :                 if  ( ( _nSlot != SID_CUT )
                 [ #  # ]
     391                 :            :                    && ( _nSlot != SID_COPY )
     392                 :            :                    && ( _nSlot != SID_PASTE )
     393                 :            :                     )
     394                 :            :                 {
     395                 :          0 :                     _rSet.InvalidateItem( nWhich );
     396                 :            :                 }
     397                 :            :             }
     398                 :            :             else
     399                 :            :             {
     400         [ #  # ]:          0 :                 switch ( _rUnoState.getValueType().getTypeClass() )
     401                 :            :                 {
     402                 :            :                 case TypeClass_BOOLEAN:
     403                 :            :                 {
     404                 :          0 :                     sal_Bool bState = sal_False;
     405                 :          0 :                     _rUnoState >>= bState;
     406         [ #  # ]:          0 :                     if ( _nSlot == SID_ATTR_PARA_SCRIPTSPACE )
     407 [ #  # ][ #  # ]:          0 :                         _rSet.Put( SvxScriptSpaceItem( bState, nWhich ) );
                 [ #  # ]
     408                 :            :                     else
     409 [ #  # ][ #  # ]:          0 :                         _rSet.Put( SfxBoolItem( nWhich, bState ) );
                 [ #  # ]
     410                 :            :                 }
     411                 :          0 :                 break;
     412                 :            : 
     413                 :            :                 default:
     414                 :            :                 {
     415         [ #  # ]:          0 :                     Sequence< PropertyValue > aComplexState;
     416 [ #  # ][ #  # ]:          0 :                     if ( _rUnoState >>= aComplexState )
     417                 :            :                     {
     418         [ #  # ]:          0 :                         if ( !aComplexState.getLength() )
     419         [ #  # ]:          0 :                             _rSet.InvalidateItem( nWhich );
     420                 :            :                         else
     421                 :            :                         {
     422         [ #  # ]:          0 :                             SfxAllItemSet aAllItems( _rSet );
     423         [ #  # ]:          0 :                             TransformParameters( _nSlot, aComplexState, aAllItems );
     424         [ #  # ]:          0 :                             const SfxPoolItem* pTransformed = aAllItems.GetItem( nWhich );
     425                 :            :                             OSL_ENSURE( pTransformed, "lcl_translateUnoStateToItem: non-empty parameter sequence leading to empty item?" );
     426         [ #  # ]:          0 :                             if ( pTransformed )
     427         [ #  # ]:          0 :                                 _rSet.Put( *pTransformed );
     428                 :            :                             else
     429 [ #  # ][ #  # ]:          0 :                                 _rSet.InvalidateItem( nWhich );
     430                 :            :                         }
     431                 :            :                     }
     432                 :            :                     else
     433                 :            :                     {
     434                 :            :                         OSL_FAIL( "lcl_translateUnoStateToItem: invalid state!" );
     435         [ #  # ]:          0 :                     }
     436                 :            :                 }
     437                 :            :                 }
     438                 :            :             }
     439                 :          0 :         }
     440                 :            : 
     441                 :            :         //....................................................................
     442                 :          0 :         ::rtl::OUString lcl_getUnoSlotName( SfxApplication&, SfxSlotId _nSlotId )
     443                 :            :         {
     444                 :          0 :             ::rtl::OUString sSlotUnoName;
     445                 :            : 
     446         [ #  # ]:          0 :             SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( NULL );
     447         [ #  # ]:          0 :             const SfxSlot* pSlot = rSlotPool.GetSlot( _nSlotId );
     448                 :            : 
     449                 :          0 :             const sal_Char* pAsciiUnoName = NULL;
     450         [ #  # ]:          0 :             if ( pSlot )
     451                 :            :             {
     452                 :          0 :                 pAsciiUnoName = pSlot->GetUnoName();
     453                 :            :             }
     454                 :            :             else
     455                 :            :             {
     456                 :            :                 // some hard-coded slots, which do not have a UNO name at SFX level, but which
     457                 :            :                 // we nevertheless need to transport via UNO mechanisms, so we need a name
     458   [ #  #  #  # ]:          0 :                 switch ( _nSlotId )
     459                 :            :                 {
     460                 :          0 :                 case SID_ATTR_PARA_HANGPUNCTUATION: pAsciiUnoName = "AllowHangingPunctuation"; break;
     461                 :          0 :                 case SID_ATTR_PARA_FORBIDDEN_RULES: pAsciiUnoName = "ApplyForbiddenCharacterRules"; break;
     462                 :          0 :                 case SID_ATTR_PARA_SCRIPTSPACE: pAsciiUnoName = "UseScriptSpacing"; break;
     463                 :            :                 }
     464                 :            :             }
     465                 :            : 
     466         [ #  # ]:          0 :             if ( pAsciiUnoName )
     467                 :            :             {
     468         [ #  # ]:          0 :                 sSlotUnoName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) );
     469                 :          0 :                 sSlotUnoName += ::rtl::OUString::createFromAscii( pAsciiUnoName );
     470                 :            :             }
     471                 :            : #if OSL_DEBUG_LEVEL > 0
     472                 :            :             else
     473                 :            :             {
     474                 :            :                 ::rtl::OString sMessage( "lcl_getUnoSlotName: invalid slot id, or invalid slot, or no UNO name!\n" );
     475                 :            :                 sMessage += "(slot id: ";
     476                 :            :                 sMessage += ::rtl::OString::valueOf( (sal_Int32)_nSlotId );
     477                 :            :                 sMessage += ")";
     478                 :            :                 OSL_FAIL( sMessage.getStr() );
     479                 :            :             }
     480                 :            : #endif
     481                 :          0 :             return sSlotUnoName;
     482                 :            :         }
     483                 :            : 
     484                 :            :         //....................................................................
     485                 :          6 :         bool lcl_determineReadOnly( const Reference< XControl >& _rxControl )
     486                 :            :         {
     487                 :          6 :             bool bIsReadOnlyModel = true;
     488                 :            :             try
     489                 :            :             {
     490                 :          6 :                 Reference< XPropertySet > xModelProps;
     491         [ +  - ]:          6 :                 if ( _rxControl.is() )
     492 [ +  - ][ +  - ]:          6 :                     xModelProps = xModelProps.query( _rxControl->getModel() );
         [ +  - ][ +  - ]
     493                 :          6 :                 Reference< XPropertySetInfo > xModelPropInfo;
     494         [ +  - ]:          6 :                 if ( xModelProps.is() )
     495 [ +  - ][ +  - ]:          6 :                     xModelPropInfo = xModelProps->getPropertySetInfo();
                 [ +  - ]
     496                 :            : 
     497 [ +  - ][ +  - ]:          6 :                 if ( !xModelPropInfo.is() || !xModelPropInfo->hasPropertyByName( FM_PROP_READONLY ) )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
           [ +  -  #  # ]
     498                 :          6 :                     bIsReadOnlyModel = true;
     499                 :            :                 else
     500                 :            :                 {
     501                 :          0 :                     sal_Bool bReadOnly = sal_True;
     502 [ #  # ][ #  # ]:          0 :                     xModelProps->getPropertyValue( FM_PROP_READONLY ) >>= bReadOnly;
                 [ #  # ]
     503                 :          0 :                     bIsReadOnlyModel = bReadOnly;
     504         [ #  # ]:          6 :                 }
     505                 :            :             }
     506                 :          0 :             catch( const Exception& )
     507                 :            :             {
     508                 :            :                 DBG_UNHANDLED_EXCEPTION();
     509                 :            :             }
     510                 :          6 :             return bIsReadOnlyModel;
     511                 :            :         }
     512                 :            : 
     513                 :            :         //....................................................................
     514                 :          0 :         static Window* lcl_getWindow( const Reference< XControl >& _rxControl )
     515                 :            :         {
     516                 :          0 :             Window* pWindow = NULL;
     517                 :            :             try
     518                 :            :             {
     519                 :          0 :                 Reference< XWindowPeer > xControlPeer;
     520         [ #  # ]:          0 :                 if ( _rxControl.is() )
     521 [ #  # ][ #  # ]:          0 :                     xControlPeer = _rxControl->getPeer();
                 [ #  # ]
     522         [ #  # ]:          0 :                 if ( xControlPeer.is() )
     523 [ #  # ][ #  # ]:          0 :                     pWindow = VCLUnoHelper::GetWindow( xControlPeer );
     524                 :            :             }
     525                 :          0 :             catch( const Exception& )
     526                 :            :             {
     527                 :            :                 DBG_UNHANDLED_EXCEPTION();
     528                 :            :             }
     529                 :            : 
     530                 :          0 :             return pWindow;
     531                 :            :         }
     532                 :            : 
     533                 :            :         //....................................................................
     534                 :          6 :         bool lcl_isRichText( const Reference< XControl >& _rxControl )
     535                 :            :         {
     536         [ -  + ]:          6 :             if ( !_rxControl.is() )
     537                 :          0 :                 return false;
     538                 :            : 
     539                 :          6 :             bool bIsRichText = false;
     540                 :            :             try
     541                 :            :             {
     542 [ +  - ][ +  - ]:          6 :                 Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY );
                 [ +  - ]
     543                 :          6 :                 Reference< XPropertySetInfo > xPSI;
     544         [ +  - ]:          6 :                 if ( xModelProps.is() )
     545 [ +  - ][ +  - ]:          6 :                     xPSI = xModelProps->getPropertySetInfo();
                 [ +  - ]
     546         [ +  - ]:          6 :                 ::rtl::OUString sRichTextPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RichText" ) );
     547 [ +  - ][ +  - ]:          6 :                 if ( xPSI.is() && xPSI->hasPropertyByName( sRichTextPropertyName ) )
         [ +  - ][ -  + ]
                 [ -  + ]
     548                 :            :                 {
     549 [ #  # ][ #  # ]:          0 :                     OSL_VERIFY( xModelProps->getPropertyValue( sRichTextPropertyName ) >>= bIsRichText );
     550         [ #  # ]:          6 :                 }
     551                 :            :             }
     552         [ #  # ]:          0 :             catch( const Exception& )
     553                 :            :             {
     554                 :            :                 DBG_UNHANDLED_EXCEPTION();
     555                 :            :             }
     556                 :          6 :             return bIsRichText;
     557                 :            :         }
     558                 :            :     }
     559                 :            : 
     560                 :            :     //------------------------------------------------------------------------
     561                 :       1669 :     FmTextControlShell::FmTextControlShell( SfxViewFrame* _pFrame )
     562                 :            :         :m_bActiveControl( false )
     563                 :            :         ,m_bActiveControlIsReadOnly( true )
     564                 :            :         ,m_bActiveControlIsRichText( false )
     565                 :            :         ,m_pViewFrame( _pFrame )
     566                 :       1669 :         ,m_rBindings( _pFrame->GetBindings() )
     567 [ +  - ][ +  - ]:       3338 :         ,m_bNeedClipboardInvalidation( true )
           [ +  -  +  - ]
                 [ +  - ]
     568                 :            :     {
     569         [ +  - ]:       1669 :         m_aClipboardInvalidation.SetTimeoutHdl( LINK( this, FmTextControlShell, OnInvalidateClipboard ) );
     570         [ +  - ]:       1669 :         m_aClipboardInvalidation.SetTimeout( 200 );
     571                 :       1669 :     }
     572                 :            : 
     573                 :            :     //------------------------------------------------------------------------
     574 [ +  - ][ +  - ]:       1578 :     FmTextControlShell::~FmTextControlShell()
     575                 :            :     {
     576         [ +  - ]:       1578 :         dispose();
     577         [ -  + ]:       3156 :     }
     578                 :            : 
     579                 :            :     //------------------------------------------------------------------------
     580                 :          0 :     IMPL_LINK( FmTextControlShell, OnInvalidateClipboard, void*, /*_pNotInterestedIn*/ )
     581                 :            :     {
     582         [ #  # ]:          0 :         if ( m_bNeedClipboardInvalidation )
     583                 :            :         {
     584                 :            :             OSL_TRACE( "FmTextControlShell::ClipBoard: invalidating clipboard slots" );
     585                 :          0 :             m_rBindings.Invalidate( SID_CUT );
     586                 :          0 :             m_rBindings.Invalidate( SID_COPY );
     587                 :          0 :             m_rBindings.Invalidate( SID_PASTE );
     588                 :          0 :             m_bNeedClipboardInvalidation = false;
     589                 :            :         }
     590                 :          0 :         return 0L;
     591                 :            :     }
     592                 :            : 
     593                 :            :     //------------------------------------------------------------------------
     594                 :          0 :     void FmTextControlShell::transferFeatureStatesToItemSet( ControlFeatures& _rDispatchers, SfxAllItemSet& _rSet, bool _bTranslateLatin )
     595                 :            :     {
     596                 :          0 :         SfxItemPool& rPool = *_rSet.GetPool();
     597                 :            : 
     598         [ #  # ]:          0 :         for (   ControlFeatures::const_iterator aFeature = _rDispatchers.begin();
     599                 :          0 :                 aFeature != _rDispatchers.end();
     600                 :            :                 ++aFeature
     601                 :            :             )
     602                 :            :         {
     603                 :          0 :             SfxSlotId nSlotId( aFeature->first );
     604                 :            :             #if OSL_DEBUG_LEVEL > 0
     605                 :            :                 ::rtl::OUString sUnoSlotName;
     606                 :            :                 if ( SFX_APP() )
     607                 :            :                     sUnoSlotName = lcl_getUnoSlotName( *SFX_APP(), nSlotId );
     608                 :            :                 else
     609                 :            :                     sUnoSlotName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "<unknown>" ) );
     610                 :            :                 ::rtl::OString sUnoSlotNameAscii( "\"" );
     611                 :            :                 sUnoSlotNameAscii += ::rtl::OString( sUnoSlotName.getStr(), sUnoSlotName.getLength(), RTL_TEXTENCODING_ASCII_US );
     612                 :            :                 sUnoSlotNameAscii += "\"";
     613                 :            :             #endif
     614                 :            : 
     615         [ #  # ]:          0 :             if ( _bTranslateLatin )
     616                 :            :             {
     617                 :            :                 // A rich text control offers a dispatcher for the "Font" slot/feature.
     618                 :            :                 // Sadly, the semantics of the dispatches is that the feature "Font" depends
     619                 :            :                 // on the current cursor position: If it's on latin text, it's the "latin font"
     620                 :            :                 // which is set up at the control. If it's on CJK text, it's the "CJK font", and
     621                 :            :                 // aequivalent for "CTL font".
     622                 :            :                 // The same holds for some other font related features/slots.
     623                 :            :                 // Thus, we have separate dispatches for "Latin Font", "Latin Font Size", etc,
     624                 :            :                 // which are only "virtual", in a sense that there exist no item with this id.
     625                 :            :                 // So when we encounter such a dispatcher for, say, "Latin Font", we need to
     626                 :            :                 // put an item into the set which has the "Font" id.
     627                 :            : 
     628   [ #  #  #  #  :          0 :                 switch ( nSlotId )
                   #  # ]
     629                 :            :                 {
     630                 :          0 :                 case SID_ATTR_CHAR_LATIN_FONT:      nSlotId = SID_ATTR_CHAR_FONT; break;
     631                 :          0 :                 case SID_ATTR_CHAR_LATIN_FONTHEIGHT:nSlotId = SID_ATTR_CHAR_FONTHEIGHT; break;
     632                 :          0 :                 case SID_ATTR_CHAR_LATIN_LANGUAGE:  nSlotId = SID_ATTR_CHAR_LANGUAGE; break;
     633                 :          0 :                 case SID_ATTR_CHAR_LATIN_POSTURE:   nSlotId = SID_ATTR_CHAR_POSTURE; break;
     634                 :          0 :                 case SID_ATTR_CHAR_LATIN_WEIGHT:    nSlotId = SID_ATTR_CHAR_WEIGHT; break;
     635                 :            :                 }
     636                 :            :             }
     637                 :            : 
     638         [ #  # ]:          0 :             WhichId nWhich = rPool.GetWhich( nSlotId );
     639         [ #  # ]:          0 :             bool bIsInPool = rPool.IsInRange( nWhich );
     640         [ #  # ]:          0 :             if ( bIsInPool )
     641                 :            :             {
     642                 :            :                 #if OSL_DEBUG_LEVEL > 0
     643                 :            :                     bool bFeatureIsEnabled = aFeature->second->isFeatureEnabled();
     644                 :            :                     ::rtl::OString sMessage( "FmTextControlShell::transferFeatureStatesToItemSet: found a feature state for " );
     645                 :            :                     sMessage += sUnoSlotNameAscii;
     646                 :            :                     if ( !bFeatureIsEnabled )
     647                 :            :                         sMessage += " (disabled)";
     648                 :            :                     OSL_TRACE( "%s", sMessage.getStr() );
     649                 :            :                 #endif
     650                 :            : 
     651         [ #  # ]:          0 :                 lcl_translateUnoStateToItem( nSlotId, aFeature->second->getFeatureState(), _rSet );
     652                 :            :             }
     653                 :            :             #if OSL_DEBUG_LEVEL > 0
     654                 :            :             else
     655                 :            :             {
     656                 :            :                 ::rtl::OString sMessage( "FmTextControlShell::transferFeatureStatesToItemSet: found a feature state for " );
     657                 :            :                 sMessage += sUnoSlotNameAscii;
     658                 :            :                 sMessage += ", but could not translate it into an item!";
     659                 :            :                 OSL_TRACE( "%s", sMessage.getStr() );
     660                 :            :             }
     661                 :            :             #endif
     662                 :            :         }
     663                 :          0 :     }
     664                 :            : 
     665                 :            :     //------------------------------------------------------------------------
     666                 :          0 :     void FmTextControlShell::executeAttributeDialog( AttributeSet _eSet, SfxRequest& _rReq )
     667                 :            :     {
     668 [ #  # ][ #  # ]:          0 :         const SvxFontListItem* pFontList = PTR_CAST( SvxFontListItem, m_pViewFrame->GetObjectShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     669                 :            :         DBG_ASSERT( pFontList, "FmTextControlShell::executeAttributeDialog: no font list item!" );
     670         [ #  # ]:          0 :         if ( !pFontList )
     671                 :          0 :             return;
     672                 :            : 
     673         [ #  # ]:          0 :         SfxItemPool* pPool = EditEngine::CreatePool();
     674         [ #  # ]:          0 :         pPool->FreezeIdRanges();
     675 [ #  # ][ #  # ]:          0 :         ::std::auto_ptr< SfxItemSet > pPureItems( new SfxItemSet( *pPool ) );
     676                 :            : 
     677                 :            :         // put the current states of the items into the set
     678 [ #  # ][ #  # ]:          0 :         ::std::auto_ptr< SfxAllItemSet > pCurrentItems( new SfxAllItemSet( *pPureItems ) );
     679         [ #  # ]:          0 :         transferFeatureStatesToItemSet( m_aControlFeatures, *pCurrentItems );
     680                 :            : 
     681                 :            :         // additional items, which we are not responsible for at the SfxShell level,
     682                 :            :         // but which need to be forwarded to the dialog, anyway
     683         [ #  # ]:          0 :         ControlFeatures aAdditionalFestures;
     684         [ #  # ]:          0 :         fillFeatureDispatchers( m_xActiveControl, pDialogSlots, aAdditionalFestures );
     685         [ #  # ]:          0 :         transferFeatureStatesToItemSet( aAdditionalFestures, *pCurrentItems, true );
     686                 :            : 
     687                 :            :         ::std::auto_ptr< SfxTabDialog > pDialog ( _eSet == eCharAttribs
     688         [ #  # ]:          0 :                                                 ? static_cast< SfxTabDialog* >( new TextControlCharAttribDialog( NULL, *pCurrentItems, *pFontList ) )
     689   [ #  #  #  # ]:          0 :                                                 : static_cast< SfxTabDialog* >( new TextControlParaAttribDialog( NULL, *pCurrentItems ) ) );
         [ #  # ][ #  # ]
     690 [ #  # ][ #  # ]:          0 :         if ( RET_OK == pDialog->Execute() )
     691                 :            :         {
     692                 :          0 :             const SfxItemSet& rModifiedItems = *pDialog->GetOutputItemSet();
     693 [ #  # ][ #  # ]:          0 :             for ( WhichId nWhich = pPool->GetFirstWhich(); nWhich <= pPool->GetLastWhich(); ++nWhich )
                 [ #  # ]
     694                 :            :             {
     695 [ #  # ][ #  # ]:          0 :                 if ( rModifiedItems.GetItemState( nWhich ) == SFX_ITEM_SET )
     696                 :            :                 {
     697         [ #  # ]:          0 :                     SfxSlotId nSlotForItemSet = pPool->GetSlotId( nWhich );
     698         [ #  # ]:          0 :                     const SfxPoolItem* pModifiedItem = rModifiedItems.GetItem( nWhich );
     699                 :            : 
     700                 :            : 
     701                 :          0 :                     SfxSlotId nSlotForDispatcher = nSlotForItemSet;
     702   [ #  #  #  #  :          0 :                     switch ( nSlotForDispatcher )
                   #  # ]
     703                 :            :                     {
     704                 :          0 :                         case SID_ATTR_CHAR_FONT:      nSlotForDispatcher = SID_ATTR_CHAR_LATIN_FONT; break;
     705                 :          0 :                         case SID_ATTR_CHAR_FONTHEIGHT:nSlotForDispatcher = SID_ATTR_CHAR_LATIN_FONTHEIGHT; break;
     706                 :          0 :                         case SID_ATTR_CHAR_LANGUAGE:  nSlotForDispatcher = SID_ATTR_CHAR_LATIN_LANGUAGE; break;
     707                 :          0 :                         case SID_ATTR_CHAR_POSTURE:   nSlotForDispatcher = SID_ATTR_CHAR_LATIN_POSTURE; break;
     708                 :          0 :                         case SID_ATTR_CHAR_WEIGHT:    nSlotForDispatcher = SID_ATTR_CHAR_LATIN_WEIGHT; break;
     709                 :            :                     }
     710                 :            : 
     711                 :            :                     // do we already have a dispatcher for this slot/feature?
     712         [ #  # ]:          0 :                     ControlFeatures::const_iterator aFeaturePos = m_aControlFeatures.find( nSlotForDispatcher );
     713                 :          0 :                     bool bFound = aFeaturePos != m_aControlFeatures.end( );
     714                 :            : 
     715         [ #  # ]:          0 :                     if ( !bFound )
     716                 :            :                     {
     717         [ #  # ]:          0 :                         aFeaturePos = aAdditionalFestures.find( nSlotForDispatcher );
     718                 :          0 :                         bFound = aFeaturePos != aAdditionalFestures.end( );
     719                 :            :                     }
     720                 :            : 
     721         [ #  # ]:          0 :                     if ( bFound )
     722                 :            :                     {
     723         [ #  # ]:          0 :                         Sequence< PropertyValue > aArgs;
     724                 :            :                         // temporarily put the modified item into a "clean" set,
     725                 :            :                         // and let TransformItems calc the respective UNO parameters
     726         [ #  # ]:          0 :                         pPureItems->Put( *pModifiedItem );
     727         [ #  # ]:          0 :                         TransformItems( nSlotForItemSet, *pPureItems, aArgs );
     728         [ #  # ]:          0 :                         pPureItems->ClearItem( nWhich );
     729                 :            : 
     730 [ #  # ][ #  # ]:          0 :                         if  (   ( nSlotForItemSet == SID_ATTR_PARA_HANGPUNCTUATION )
                 [ #  # ]
     731                 :            :                             ||  ( nSlotForItemSet == SID_ATTR_PARA_FORBIDDEN_RULES )
     732                 :            :                             ||  ( nSlotForItemSet == SID_ATTR_PARA_SCRIPTSPACE )
     733                 :            :                             )
     734                 :            :                         {
     735                 :            :                             // these are no UNO slots, they need special handling since TransformItems cannot
     736                 :            :                             // handle them
     737                 :            :                             DBG_ASSERT( aArgs.getLength() == 0, "FmTextControlShell::executeAttributeDialog: these are no UNO slots - are they?" );
     738                 :            : 
     739 [ #  # ][ #  # ]:          0 :                             const SfxBoolItem* pBoolItem = PTR_CAST( SfxBoolItem, pModifiedItem );
         [ #  # ][ #  # ]
     740                 :            :                             DBG_ASSERT( pBoolItem, "FmTextControlShell::executeAttributeDialog: no bool item?!" );
     741         [ #  # ]:          0 :                             if ( pBoolItem )
     742                 :            :                             {
     743         [ #  # ]:          0 :                                 aArgs.realloc( 1 );
     744 [ #  # ][ #  # ]:          0 :                                 aArgs[ 0 ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enable" ) );
     745 [ #  # ][ #  # ]:          0 :                                 aArgs[ 0 ].Value <<= (sal_Bool)pBoolItem->GetValue();
     746                 :            :                             }
     747                 :            :                         }
     748                 :            : 
     749                 :            :                         // dispatch this
     750 [ #  # ][ #  # ]:          0 :                         aFeaturePos->second->dispatch( aArgs );
     751                 :            :                     }
     752                 :            :                 #if OSL_DEBUG_LEVEL > 0
     753                 :            :                     else
     754                 :            :                     {
     755                 :            :                         ::rtl::OString sError( "FmTextControShell::executeAttributeDialog: Could not handle the following item:" );
     756                 :            :                         sError += "\n  SlotID: "; sError += ::rtl::OString::valueOf( (sal_Int32)nSlotForItemSet );
     757                 :            :                         sError += "\n  WhichID: "; sError += ::rtl::OString::valueOf( (sal_Int32)nWhich );
     758                 :            :                         sError += "\n  UNO name: ";
     759                 :            : 
     760                 :            :                         ::rtl::OUString sUnoSlotName = lcl_getUnoSlotName( *SFX_APP(), nSlotForItemSet );
     761                 :            :                         if ( !sUnoSlotName.isEmpty() )
     762                 :            :                             sError += ::rtl::OString( sUnoSlotName.getStr(), sUnoSlotName.getLength(), RTL_TEXTENCODING_ASCII_US );
     763                 :            :                         else
     764                 :            :                             sError += "unknown (no SfxSlot)";
     765                 :            :                         OSL_FAIL( sError.getStr() );
     766                 :            :                     }
     767                 :            :                 #endif
     768                 :            :                 }
     769                 :            :             }
     770         [ #  # ]:          0 :             _rReq.Done( rModifiedItems );
     771                 :            :         }
     772                 :            : 
     773                 :          0 :         pDialog.reset();
     774                 :          0 :         pCurrentItems.reset();
     775                 :          0 :         pPureItems.reset();
     776 [ #  # ][ #  # ]:          0 :         SfxItemPool::Free(pPool);
         [ #  # ][ #  # ]
     777                 :            :     }
     778                 :            : 
     779                 :            :     //------------------------------------------------------------------------
     780                 :          0 :     bool FmTextControlShell::executeSelectAll( )
     781                 :            :     {
     782                 :            :         try
     783                 :            :         {
     784         [ #  # ]:          0 :             if ( m_xActiveTextComponent.is() )
     785                 :            :             {
     786 [ #  # ][ #  # ]:          0 :                 sal_Int32 nTextLen = m_xActiveTextComponent->getText().getLength();
     787   [ #  #  #  # ]:          0 :                 m_xActiveTextComponent->setSelection( awt::Selection( 0, nTextLen ) );
                 [ #  # ]
     788                 :          0 :                 return true;
     789                 :            :             }
     790                 :            :         }
     791                 :          0 :         catch( const Exception& )
     792                 :            :         {
     793                 :            :             DBG_UNHANDLED_EXCEPTION();
     794                 :            :         }
     795                 :          0 :         return false;   // not handled
     796                 :            :     }
     797                 :            : 
     798                 :            :     //------------------------------------------------------------------------
     799                 :          0 :     bool FmTextControlShell::executeClipboardSlot( SfxSlotId _nSlot )
     800                 :            :     {
     801                 :            :         try
     802                 :            :         {
     803         [ #  # ]:          0 :             if ( m_xActiveTextComponent.is() )
     804                 :            :             {
     805      [ #  #  # ]:          0 :                 switch ( _nSlot )
     806                 :            :                 {
     807                 :            :                 case SID_COPY:
     808                 :            :                 case SID_CUT:
     809                 :            :                 {
     810 [ #  # ][ #  # ]:          0 :                     ::rtl::OUString sSelectedText( m_xActiveTextComponent->getSelectedText() );
     811 [ #  # ][ #  # ]:          0 :                     ::svt::OStringTransfer::CopyString( sSelectedText, lcl_getWindow( m_xActiveControl ) );
     812         [ #  # ]:          0 :                     if ( SID_CUT == _nSlot )
     813                 :            :                     {
     814 [ #  # ][ #  # ]:          0 :                         awt::Selection aSelection( m_xActiveTextComponent->getSelection() );
     815 [ #  # ][ #  # ]:          0 :                         m_xActiveTextComponent->insertText( aSelection, ::rtl::OUString() );
     816                 :          0 :                     }
     817                 :            :                 }
     818                 :          0 :                 break;
     819                 :            :                 case SID_PASTE:
     820                 :            :                 {
     821                 :          0 :                     ::rtl::OUString sClipboardContent;
     822 [ #  # ][ #  # ]:          0 :                     OSL_VERIFY( ::svt::OStringTransfer::PasteString( sClipboardContent, lcl_getWindow( m_xActiveControl ) ) );
     823 [ #  # ][ #  # ]:          0 :                     awt::Selection aSelection( m_xActiveTextComponent->getSelection() );
     824 [ #  # ][ #  # ]:          0 :                     m_xActiveTextComponent->insertText( aSelection, sClipboardContent );
                 [ #  # ]
     825                 :            :                 }
     826                 :          0 :                 break;
     827                 :            :                 default:
     828                 :            :                     OSL_FAIL( "FmTextControlShell::executeClipboardSlot: invalid slot!" );
     829                 :            :                 }
     830                 :          0 :                 return true;
     831                 :            :             }
     832                 :            :         }
     833                 :          0 :         catch( const Exception& )
     834                 :            :         {
     835                 :            :             DBG_UNHANDLED_EXCEPTION();
     836                 :            :         }
     837                 :          0 :         return false;   // not handled
     838                 :            :     }
     839                 :            : 
     840                 :            :     //------------------------------------------------------------------------
     841                 :          0 :     void FmTextControlShell::ExecuteTextAttribute( SfxRequest& _rReq )
     842                 :            :     {
     843                 :          0 :         SfxSlotId nSlot = _rReq.GetSlot();
     844                 :            : 
     845         [ #  # ]:          0 :         ControlFeatures::const_iterator aFeaturePos = m_aControlFeatures.find( nSlot );
     846         [ #  # ]:          0 :         if ( aFeaturePos == m_aControlFeatures.end() )
     847                 :            :         {
     848                 :            :             // special slots
     849   [ #  #  #  #  :          0 :             switch ( nSlot )
                      # ]
     850                 :            :             {
     851                 :            :             case SID_CHAR_DLG:
     852         [ #  # ]:          0 :                 executeAttributeDialog( eCharAttribs, _rReq );
     853                 :          0 :                 break;
     854                 :            : 
     855                 :            :             case SID_PARA_DLG:
     856         [ #  # ]:          0 :                 executeAttributeDialog( eParaAttribs, _rReq );
     857                 :          0 :                 break;
     858                 :            : 
     859                 :            :             case SID_SELECTALL:
     860         [ #  # ]:          0 :                 executeSelectAll();
     861                 :          0 :                 break;
     862                 :            : 
     863                 :            :             case SID_CUT:
     864                 :            :             case SID_COPY:
     865                 :            :             case SID_PASTE:
     866         [ #  # ]:          0 :                 executeClipboardSlot( nSlot );
     867                 :          0 :                 break;
     868                 :            : 
     869                 :            :             default:
     870                 :            :                 DBG_ASSERT( aFeaturePos != m_aControlFeatures.end(), "FmTextControShell::ExecuteTextAttribute: I have no such dispatcher, and cannot handle it at all!" );
     871                 :          0 :                 return;
     872                 :            :             }
     873                 :            :         }
     874                 :            :         else
     875                 :            :         {
     876                 :            :             // slots which are dispatched to the control
     877                 :            : 
     878      [ #  #  # ]:          0 :             switch ( nSlot )
     879                 :            :             {
     880                 :            :             case SID_ATTR_CHAR_STRIKEOUT:
     881                 :            :             case SID_ATTR_CHAR_UNDERLINE:
     882                 :            :             case SID_ATTR_CHAR_OVERLINE:
     883                 :            :             {
     884         [ #  # ]:          0 :                 SfxItemSet aToggled( *_rReq.GetArgs() );
     885                 :            : 
     886         [ #  # ]:          0 :                 lcl_translateUnoStateToItem( nSlot, aFeaturePos->second->getFeatureState(), aToggled );
     887         [ #  # ]:          0 :                 WhichId nWhich = aToggled.GetPool()->GetWhich( nSlot );
     888         [ #  # ]:          0 :                 const SfxPoolItem* pItem = aToggled.GetItem( nWhich );
     889 [ #  # ][ #  # ]:          0 :                 if ( ( SID_ATTR_CHAR_UNDERLINE == nSlot ) || ( SID_ATTR_CHAR_OVERLINE == nSlot ) )
     890                 :            :                 {
     891 [ #  # ][ #  # ]:          0 :                     const SvxOverlineItem* pTextLine = PTR_CAST( SvxOverlineItem, pItem );
         [ #  # ][ #  # ]
     892                 :            :                     DBG_ASSERT( pTextLine, "FmTextControlShell::ExecuteTextAttribute: ooops - no underline/overline item!" );
     893         [ #  # ]:          0 :                     if ( pTextLine )
     894                 :            :                     {
     895                 :          0 :                         FontUnderline eTL = pTextLine->GetLineStyle();
     896         [ #  # ]:          0 :                         if ( SID_ATTR_CHAR_UNDERLINE == nSlot ) {
     897 [ #  # ][ #  # ]:          0 :                             aToggled.Put( SvxUnderlineItem( eTL == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, nWhich ) );
                 [ #  # ]
     898                 :            :                         } else {
     899 [ #  # ][ #  # ]:          0 :                             aToggled.Put( SvxOverlineItem( eTL == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, nWhich ) );
                 [ #  # ]
     900                 :            :                         }
     901                 :          0 :                     }
     902                 :            :                 }
     903                 :            :                 else
     904                 :            :                 {
     905 [ #  # ][ #  # ]:          0 :                     const SvxCrossedOutItem* pCrossedOut = PTR_CAST( SvxCrossedOutItem, pItem );
         [ #  # ][ #  # ]
     906                 :            :                     DBG_ASSERT( pCrossedOut, "FmTextControlShell::ExecuteTextAttribute: ooops - no CrossedOut item!" );
     907         [ #  # ]:          0 :                     if ( pCrossedOut )
     908                 :            :                     {
     909                 :          0 :                         FontStrikeout eFS = pCrossedOut->GetStrikeout();
     910 [ #  # ][ #  # ]:          0 :                         aToggled.Put( SvxCrossedOutItem( eFS == STRIKEOUT_SINGLE ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, nWhich ) );
                 [ #  # ]
     911                 :            :                     }
     912                 :            :                 }
     913                 :            : 
     914         [ #  # ]:          0 :                 Sequence< PropertyValue > aArguments;
     915         [ #  # ]:          0 :                 TransformItems( nSlot, aToggled, aArguments );
     916 [ #  # ][ #  # ]:          0 :                 aFeaturePos->second->dispatch( aArguments );
                 [ #  # ]
     917                 :            :             }
     918                 :          0 :             break;
     919                 :            : 
     920                 :            :             case SID_ATTR_CHAR_FONTHEIGHT:
     921                 :            :             case SID_ATTR_CHAR_FONT:
     922                 :            :             case SID_ATTR_CHAR_POSTURE:
     923                 :            :             case SID_ATTR_CHAR_WEIGHT:
     924                 :            :             case SID_ATTR_CHAR_SHADOWED:
     925                 :            :             case SID_ATTR_CHAR_CONTOUR:
     926                 :            :             case SID_SET_SUPER_SCRIPT:
     927                 :            :             case SID_SET_SUB_SCRIPT:
     928                 :            :             {
     929                 :          0 :                 const SfxItemSet* pArgs = _rReq.GetArgs();
     930         [ #  # ]:          0 :                 Sequence< PropertyValue > aArgs;
     931         [ #  # ]:          0 :                 if ( pArgs )
     932         [ #  # ]:          0 :                     TransformItems( nSlot, *pArgs, aArgs );
     933 [ #  # ][ #  # ]:          0 :                 aFeaturePos->second->dispatch( aArgs );
     934                 :            :             }
     935                 :          0 :             break;
     936                 :            : 
     937                 :            :             default:
     938         [ #  # ]:          0 :                 if ( aFeaturePos->second->isFeatureEnabled() )
     939         [ #  # ]:          0 :                     aFeaturePos->second->dispatch();
     940                 :          0 :                 break;
     941                 :            :             }
     942                 :            :         }
     943         [ #  # ]:          0 :         _rReq.Done();
     944                 :            :     }
     945                 :            : 
     946                 :            :     //------------------------------------------------------------------------
     947                 :          0 :     void FmTextControlShell::GetTextAttributeState( SfxItemSet& _rSet )
     948                 :            :     {
     949         [ #  # ]:          0 :         SfxWhichIter aIter( _rSet );
     950         [ #  # ]:          0 :         sal_uInt16 nSlot = aIter.FirstWhich();
     951         [ #  # ]:          0 :         while ( nSlot )
     952                 :            :         {
     953 [ #  # ][ #  # ]:          0 :             if  (   ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT )
     954                 :            :                 ||  ( nSlot == SID_ATTR_PARA_RIGHT_TO_LEFT )
     955                 :            :                 )
     956                 :            :             {
     957 [ #  # ][ #  # ]:          0 :                 if ( !SvtLanguageOptions().IsCTLFontEnabled() )
         [ #  # ][ #  # ]
     958                 :            :                 {
     959         [ #  # ]:          0 :                     _rSet.DisableItem( nSlot );
     960         [ #  # ]:          0 :                     nSlot = aIter.NextWhich();
     961                 :          0 :                     continue;
     962                 :            :                 }
     963                 :            :             }
     964                 :            : 
     965         [ #  # ]:          0 :             ControlFeatures::const_iterator aFeaturePos = m_aControlFeatures.find( nSlot );
     966         [ #  # ]:          0 :             if ( aFeaturePos != m_aControlFeatures.end() )
     967                 :            :             {
     968         [ #  # ]:          0 :                 if ( aFeaturePos->second->isFeatureEnabled() )
     969         [ #  # ]:          0 :                     lcl_translateUnoStateToItem( nSlot, aFeaturePos->second->getFeatureState(), _rSet );
     970                 :            :                 else
     971         [ #  # ]:          0 :                     _rSet.DisableItem( nSlot );
     972                 :            :             }
     973                 :            :             else
     974                 :            :             {
     975                 :          0 :                 bool bDisable = false;
     976                 :            : 
     977                 :          0 :                 bool bNeedWriteableControl = false;
     978                 :          0 :                 bool bNeedTextComponent = false;
     979                 :          0 :                 bool bNeedSelection = false;
     980                 :            : 
     981   [ #  #  #  #  :          0 :                 switch ( nSlot )
                   #  # ]
     982                 :            :                 {
     983                 :            :                 case SID_CHAR_DLG:
     984                 :            :                 case SID_PARA_DLG:
     985                 :          0 :                     bDisable |= m_aControlFeatures.empty();
     986                 :          0 :                     bNeedWriteableControl = true;
     987                 :          0 :                     break;
     988                 :            : 
     989                 :            :                 case SID_CUT:
     990                 :          0 :                     bNeedSelection = true;
     991                 :          0 :                     bNeedTextComponent = true;
     992                 :          0 :                     bNeedWriteableControl = true;
     993                 :            :                     OSL_TRACE( "FmTextControlShell::ClipBoard: need to invalidate again" );
     994                 :          0 :                     m_bNeedClipboardInvalidation = true;
     995                 :          0 :                     break;
     996                 :            : 
     997                 :            :                 case SID_PASTE:
     998                 :            :                 {
     999         [ #  # ]:          0 :                     Window* pActiveControlVCLWindow = lcl_getWindow( m_xActiveControl );
    1000         [ #  # ]:          0 :                     if ( pActiveControlVCLWindow )
    1001                 :            :                     {
    1002         [ #  # ]:          0 :                         TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pActiveControlVCLWindow) );
    1003 [ #  # ][ #  # ]:          0 :                         bDisable |= !aDataHelper.HasFormat( SOT_FORMAT_STRING );
    1004                 :            :                     }
    1005                 :            :                     else
    1006                 :          0 :                         bDisable |= true;
    1007                 :            : 
    1008                 :          0 :                     bNeedTextComponent = true;
    1009                 :          0 :                     bNeedWriteableControl = true;
    1010                 :            :                 }
    1011                 :          0 :                 break;
    1012                 :            : 
    1013                 :            :                 case SID_COPY:
    1014                 :          0 :                     bNeedTextComponent = true;
    1015                 :          0 :                     bNeedSelection = true;
    1016                 :          0 :                     break;
    1017                 :            : 
    1018                 :            :                 case SID_SELECTALL:
    1019                 :          0 :                     bNeedTextComponent = true;
    1020                 :          0 :                     break;
    1021                 :            : 
    1022                 :            :                 default:
    1023                 :            :                     // slot is unknown at all
    1024                 :          0 :                     bDisable |= true;
    1025                 :          0 :                     break;
    1026                 :            :                 }
    1027                 :            :                 OSL_POSTCOND( !bNeedSelection || bNeedTextComponent, "FmTextControlShell::GetTextAttributeState: bNeedSelection should imply bNeedTextComponent!" );
    1028                 :            : 
    1029 [ #  # ][ #  # ]:          0 :                 if ( !bDisable && bNeedWriteableControl )
    1030 [ #  # ][ #  # ]:          0 :                     bDisable |= !IsActiveControl( ) || m_bActiveControlIsReadOnly;
    1031                 :            : 
    1032 [ #  # ][ #  # ]:          0 :                 if ( !bDisable && bNeedTextComponent )
    1033                 :          0 :                     bDisable |= !m_xActiveTextComponent.is();
    1034                 :            : 
    1035 [ #  # ][ #  # ]:          0 :                 if ( !bDisable && bNeedSelection )
    1036                 :            :                 {
    1037 [ #  # ][ #  # ]:          0 :                     awt::Selection aSelection = m_xActiveTextComponent->getSelection();
    1038                 :          0 :                     bDisable |= aSelection.Min == aSelection.Max;
    1039                 :            :                 }
    1040                 :            : 
    1041         [ #  # ]:          0 :                 if ( bDisable )
    1042         [ #  # ]:          0 :                     _rSet.DisableItem( nSlot );
    1043                 :            :             }
    1044                 :            : 
    1045         [ #  # ]:          0 :             nSlot = aIter.NextWhich();
    1046         [ #  # ]:          0 :         }
    1047                 :          0 :     }
    1048                 :            : 
    1049                 :            :     //------------------------------------------------------------------------
    1050                 :      25992 :     bool FmTextControlShell::IsActiveControl( bool _bCountRichTextOnly ) const
    1051                 :            :     {
    1052 [ +  + ][ +  - ]:      25992 :         if ( _bCountRichTextOnly && !m_bActiveControlIsRichText )
    1053                 :       3241 :             return false;
    1054                 :            : 
    1055                 :      25992 :         return m_bActiveControl;
    1056                 :            :     }
    1057                 :            : 
    1058                 :            :     //------------------------------------------------------------------------
    1059                 :       3156 :     void FmTextControlShell::dispose()
    1060                 :            :     {
    1061         [ -  + ]:       3156 :         if ( IsActiveControl() )
    1062                 :          0 :             controlDeactivated();
    1063         [ -  + ]:       3156 :         if ( isControllerListening() )
    1064                 :          0 :             stopControllerListening();
    1065                 :       3156 :     }
    1066                 :            : 
    1067                 :            :     //------------------------------------------------------------------------
    1068                 :       1673 :     void FmTextControlShell::designModeChanged( bool /*_bNewDesignMode*/ )
    1069                 :            :     {
    1070                 :       1673 :         m_rBindings.Invalidate( pTextControlSlots );
    1071                 :       1673 :     }
    1072                 :            : 
    1073                 :            :     //------------------------------------------------------------------------
    1074                 :          6 :     void FmTextControlShell::formActivated( const Reference< XFormController >& _rxController )
    1075                 :            :     {
    1076                 :            : #if OSL_DEBUG_LEVEL > 0
    1077                 :            :         ::rtl::OString sTrace( "FmTextControlShell::formActivated: 0x" );
    1078                 :            :         sTrace += ::rtl::OString::valueOf( (sal_IntPtr)_rxController.get(), 16 );
    1079                 :            :         OSL_TRACE( "%s", sTrace.getStr() );
    1080                 :            : #endif
    1081                 :            : 
    1082                 :            :         DBG_ASSERT( _rxController.is(), "FmTextControlShell::formActivated: invalid controller!" );
    1083         [ -  + ]:          6 :         if ( !_rxController.is() )
    1084                 :          0 :             return;
    1085                 :            : 
    1086                 :            :         // sometimes, a form controller notifies activations, even if it's already activated
    1087         [ -  + ]:          6 :         if ( m_xActiveController == _rxController )
    1088                 :          0 :             return;
    1089                 :            : 
    1090                 :            :         try
    1091                 :            :         {
    1092         [ +  - ]:          6 :             startControllerListening( _rxController );
    1093 [ +  - ][ +  - ]:          6 :             controlActivated( _rxController->getCurrentControl() );
         [ +  - ][ #  # ]
    1094                 :            :         }
    1095                 :          0 :         catch( const Exception& )
    1096                 :            :         {
    1097                 :            :             DBG_UNHANDLED_EXCEPTION();
    1098                 :            :         }
    1099                 :            :     }
    1100                 :            : 
    1101                 :            :     //------------------------------------------------------------------------
    1102                 :          6 :     void FmTextControlShell::formDeactivated( const Reference< XFormController >& _rxController )
    1103                 :            :     {
    1104                 :            : #if OSL_DEBUG_LEVEL > 0
    1105                 :            :         ::rtl::OString sTrace( "FmTextControlShell::formDeactivated: 0x" );
    1106                 :            :         sTrace += ::rtl::OString::valueOf( (sal_IntPtr)_rxController.get(), 16 );
    1107                 :            :         OSL_TRACE( "%s", sTrace.getStr() );
    1108                 :            : #endif
    1109                 :            :         (void)_rxController;
    1110                 :            : 
    1111         [ -  + ]:          6 :         if ( IsActiveControl() )
    1112                 :          0 :             controlDeactivated();
    1113         [ +  - ]:          6 :         if ( isControllerListening() )
    1114                 :          6 :             stopControllerListening();
    1115                 :          6 :     }
    1116                 :            : 
    1117                 :            :     //------------------------------------------------------------------------
    1118                 :          6 :     void FmTextControlShell::startControllerListening( const Reference< XFormController >& _rxController )
    1119                 :            :     {
    1120                 :            :         OSL_PRECOND( _rxController.is(), "FmTextControlShell::startControllerListening: invalid controller!" );
    1121         [ -  + ]:          6 :         if ( !_rxController.is() )
    1122                 :          6 :             return;
    1123                 :            : 
    1124                 :            :         OSL_PRECOND( !isControllerListening(), "FmTextControlShell::startControllerListening: already listening!" );
    1125         [ -  + ]:          6 :         if ( isControllerListening() )
    1126                 :          0 :             stopControllerListening( );
    1127                 :            :         DBG_ASSERT( !isControllerListening(), "FmTextControlShell::startControllerListening: inconsistence!" );
    1128                 :            : 
    1129                 :            :         try
    1130                 :            :         {
    1131 [ +  - ][ +  - ]:          6 :             Sequence< Reference< XControl > > aControls( _rxController->getControls() );
    1132         [ +  - ]:          6 :             m_aControlObservers.resize( 0 );
    1133         [ +  - ]:          6 :             m_aControlObservers.reserve( aControls.getLength() );
    1134                 :            : 
    1135                 :          6 :             const Reference< XControl >* pControls = aControls.getConstArray();
    1136                 :          6 :             const Reference< XControl >* pControlsEnd = pControls + aControls.getLength();
    1137         [ +  + ]:         24 :             for ( ; pControls != pControlsEnd; ++pControls )
    1138                 :            :             {
    1139 [ +  - ][ +  - ]:         18 :                 m_aControlObservers.push_back( FocusListenerAdapter( new FmFocusListenerAdapter( *pControls, this ) ) );
         [ +  - ][ +  - ]
    1140 [ +  - ][ #  # ]:          6 :             }
    1141                 :            :         }
    1142                 :          0 :         catch( const Exception& )
    1143                 :            :         {
    1144                 :            :             DBG_UNHANDLED_EXCEPTION();
    1145                 :            :         }
    1146                 :            : 
    1147                 :          6 :         m_xActiveController = _rxController;
    1148                 :            :     }
    1149                 :            : 
    1150                 :            :     //------------------------------------------------------------------------
    1151                 :          6 :     void FmTextControlShell::stopControllerListening( )
    1152                 :            :     {
    1153                 :            :         OSL_PRECOND( isControllerListening(), "FmTextControlShell::stopControllerListening: inconsistence!" );
    1154                 :            : 
    1155                 :            :         // dispose all listeners associated with the controls of the active controller
    1156 [ +  - ][ +  + ]:         48 :         for (   FocusListenerAdapters::iterator aLoop = m_aControlObservers.begin();
    1157                 :         24 :                 aLoop != m_aControlObservers.end();
    1158                 :            :                 ++aLoop
    1159                 :            :             )
    1160                 :            :         {
    1161         [ +  - ]:         18 :             (*aLoop)->dispose();
    1162                 :            :         }
    1163                 :            : 
    1164         [ +  - ]:          6 :         FocusListenerAdapters aEmpty;
    1165                 :          6 :         m_aControlObservers.swap( aEmpty );
    1166                 :            : 
    1167                 :          6 :         m_xActiveController.clear();
    1168                 :          6 :     }
    1169                 :            : 
    1170                 :            :     //------------------------------------------------------------------------
    1171                 :        227 :     void FmTextControlShell::implClearActiveControlRef()
    1172                 :            :     {
    1173                 :            :         // no more features for this control
    1174         [ -  + ]:        454 :         for (   ControlFeatures::iterator aLoop = m_aControlFeatures.begin();
    1175                 :        227 :                 aLoop != m_aControlFeatures.end();
    1176                 :            :                 ++aLoop
    1177                 :            :             )
    1178                 :            :         {
    1179         [ #  # ]:          0 :             aLoop->second->dispose();
    1180                 :            :         }
    1181                 :            : 
    1182         [ +  - ]:        227 :         ControlFeatures aEmpty;
    1183         [ +  - ]:        227 :         m_aControlFeatures.swap( aEmpty );
    1184                 :            : 
    1185         [ -  + ]:        227 :         if ( m_aContextMenuObserver.get() )
    1186                 :            :         {
    1187         [ #  # ]:          0 :             m_aContextMenuObserver->dispose();
    1188 [ #  # ][ #  # ]:          0 :             m_aContextMenuObserver = MouseListenerAdapter();
                 [ #  # ]
    1189                 :            :         }
    1190                 :            : 
    1191         [ -  + ]:        227 :         if ( m_xActiveTextComponent.is() )
    1192                 :            :         {
    1193                 :            :             OSL_TRACE( "FmTextControlShell::ClipBoard: stopping timer for clipboard invalidation" );
    1194         [ #  # ]:          0 :             m_aClipboardInvalidation.Stop();
    1195                 :            :         }
    1196                 :            :         // no more active control
    1197                 :        227 :         m_xActiveControl.clear();
    1198                 :        227 :         m_xActiveTextComponent.clear();
    1199                 :        227 :         m_bActiveControlIsReadOnly = true;
    1200                 :        227 :         m_bActiveControlIsRichText = false;
    1201                 :        227 :         m_bActiveControl = false;
    1202                 :        227 :     }
    1203                 :            : 
    1204                 :            :     //------------------------------------------------------------------------
    1205                 :          0 :     void FmTextControlShell::controlDeactivated( )
    1206                 :            :     {
    1207                 :            :         DBG_ASSERT( IsActiveControl(), "FmTextControlShell::controlDeactivated: no active control!" );
    1208                 :            : 
    1209                 :          0 :         m_bActiveControl = false;
    1210                 :            : 
    1211                 :          0 :         m_rBindings.Invalidate( pTextControlSlots );
    1212                 :          0 :     }
    1213                 :            : 
    1214                 :            :     //------------------------------------------------------------------------
    1215                 :          6 :     void FmTextControlShell::controlActivated( const Reference< XControl >& _rxControl )
    1216                 :            :     {
    1217                 :            :         // ensure that all knittings with the previously active control are lost
    1218         [ +  + ]:          6 :         if ( m_xActiveControl.is() )
    1219                 :          4 :             implClearActiveControlRef();
    1220                 :            :         DBG_ASSERT( m_aControlFeatures.empty(), "FmTextControlShell::controlActivated: should have no dispatchers when I'm here!" );
    1221                 :            : 
    1222                 :            : #if OSL_DEBUG_LEVEL > 0
    1223                 :            :         {
    1224                 :            :             Sequence< Reference< XControl > > aActiveControls;
    1225                 :            :             if ( m_xActiveController.is() )
    1226                 :            :                 aActiveControls = m_xActiveController->getControls();
    1227                 :            : 
    1228                 :            :             bool bFoundThisControl = false;
    1229                 :            : 
    1230                 :            :             const Reference< XControl >* pControls = aActiveControls.getConstArray();
    1231                 :            :             const Reference< XControl >* pControlsEnd = pControls + aActiveControls.getLength();
    1232                 :            :             for ( ; ( pControls != pControlsEnd ) && !bFoundThisControl; ++pControls )
    1233                 :            :             {
    1234                 :            :                 if ( *pControls == _rxControl )
    1235                 :            :                     bFoundThisControl = true;
    1236                 :            :             }
    1237                 :            :             DBG_ASSERT( bFoundThisControl, "FmTextControlShell::controlActivated: only controls which belong to the active controller can be activated!" );
    1238                 :            :         }
    1239                 :            : #endif
    1240                 :            :         // ask the control for dispatchers for our text-related slots
    1241         [ +  - ]:          6 :         fillFeatureDispatchers( _rxControl, pTextControlSlots, m_aControlFeatures );
    1242                 :            : 
    1243                 :            :         // remember this control
    1244                 :          6 :         m_xActiveControl = _rxControl;
    1245         [ +  - ]:          6 :         m_xActiveTextComponent = m_xActiveTextComponent.query( _rxControl );
    1246                 :          6 :         m_bActiveControlIsReadOnly = lcl_determineReadOnly( m_xActiveControl );
    1247                 :          6 :         m_bActiveControlIsRichText = lcl_isRichText( m_xActiveControl );
    1248                 :            : 
    1249                 :            :         // if we found a rich text control, we need context menu support
    1250         [ -  + ]:          6 :         if ( m_bActiveControlIsRichText )
    1251                 :            :         {
    1252                 :            :             DBG_ASSERT( NULL == m_aContextMenuObserver.get(), "FmTextControlShell::controlActivated: already have an observer!" );
    1253 [ #  # ][ #  # ]:          0 :             m_aContextMenuObserver = MouseListenerAdapter( new FmMouseListenerAdapter( _rxControl, this ) );
    1254                 :            :         }
    1255                 :            : 
    1256         [ -  + ]:          6 :         if ( m_xActiveTextComponent.is() )
    1257                 :            :         {
    1258                 :            :             OSL_TRACE( "FmTextControlShell::ClipBoard: starting timer for clipboard invalidation" );
    1259                 :          0 :             m_aClipboardInvalidation.Start();
    1260                 :            :         }
    1261                 :            : 
    1262                 :          6 :         m_bActiveControl = true;
    1263                 :            : 
    1264                 :          6 :         m_rBindings.Invalidate( pTextControlSlots );
    1265                 :            : 
    1266         [ +  - ]:          6 :         if ( m_pViewFrame )
    1267                 :          6 :             m_pViewFrame->UIFeatureChanged();
    1268                 :            : 
    1269                 :            :         // don't call the activation handler if we don't have any slots we can serve
    1270                 :            :         // The activation handler is used to put the shell on the top of the dispatcher stack,
    1271                 :            :         // so it's preferred when slots are distributed.
    1272                 :            :         // Note that this is a slight hack, to prevent that we grab slots from the SfxDispatcher
    1273                 :            :         // which should be served by other shells (e.g. Cut/Copy/Paste).
    1274                 :            :         // A real solution would be a forwarding-mechanism for slots: We should be on the top
    1275                 :            :         // if we're active, but if we cannot handle the slot, then we need to tell the dispatcher
    1276                 :            :         // to skip our shell, and pass the slot to the next one. However, this mechanism is not
    1277                 :            :         // not in place in SFX.
    1278                 :            :         // Another possibility would be to have dedicated shells for the slots which we might
    1279                 :            :         // or might not be able to serve. However, this could probably increase the number of
    1280                 :            :         // shells too much (In theory, nearly every slot could have an own shell then).
    1281                 :            :         //
    1282                 :            :         // #i51621# / 2005-08-19 / frank.schoenheit@sun.com
    1283 [ +  - ][ -  + ]:          6 :         bool bHaveAnyServeableSlots = m_xActiveTextComponent.is() || !m_aControlFeatures.empty();
    1284 [ +  - ][ -  + ]:          6 :         if ( m_aControlActivationHandler.IsSet() && bHaveAnyServeableSlots )
                 [ -  + ]
    1285                 :          0 :             m_aControlActivationHandler.Call( NULL );
    1286                 :            : 
    1287                 :          6 :         m_bNeedClipboardInvalidation = true;
    1288                 :          6 :     }
    1289                 :            : 
    1290                 :            :     //------------------------------------------------------------------------
    1291                 :          6 :     void FmTextControlShell::fillFeatureDispatchers(  const Reference< XControl > _rxControl, SfxSlotId* _pZeroTerminatedSlots,
    1292                 :            :             ControlFeatures& _rDispatchers )
    1293                 :            :     {
    1294         [ +  - ]:          6 :         Reference< XDispatchProvider > xProvider( _rxControl, UNO_QUERY );
    1295         [ +  - ]:          6 :         SfxApplication* pApplication = SFX_APP();
    1296                 :            :         DBG_ASSERT( pApplication, "FmTextControlShell::fillFeatureDispatchers: no SfxApplication!" );
    1297 [ -  + ][ #  # ]:          6 :         if ( xProvider.is() && pApplication )
                 [ -  + ]
    1298                 :            :         {
    1299                 :          0 :             SfxSlotId* pSlots = _pZeroTerminatedSlots;
    1300         [ #  # ]:          0 :             while ( *pSlots )
    1301                 :            :             {
    1302         [ #  # ]:          0 :                 FmTextControlFeature* pDispatcher = implGetFeatureDispatcher( xProvider, pApplication, *pSlots );
    1303         [ #  # ]:          0 :                 if ( pDispatcher )
    1304 [ #  # ][ #  # ]:          0 :                     _rDispatchers.insert( ControlFeatures::value_type( *pSlots, ControlFeature( pDispatcher ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1305                 :            : 
    1306                 :          0 :                 ++pSlots;
    1307                 :            :             }
    1308                 :          6 :         }
    1309                 :          6 :     }
    1310                 :            : 
    1311                 :            :     //------------------------------------------------------------------------
    1312                 :          0 :     void FmTextControlShell::impl_parseURL_nothrow( URL& _rURL )
    1313                 :            :     {
    1314                 :            :         try
    1315                 :            :         {
    1316         [ #  # ]:          0 :             if ( !m_xURLTransformer.is() )
    1317                 :            :             {
    1318 [ #  # ][ #  # ]:          0 :                 m_xURLTransformer = util::URLTransformer::create( ::comphelper::getProcessComponentContext() );
         [ #  # ][ #  # ]
    1319                 :            :             }
    1320         [ #  # ]:          0 :             if ( m_xURLTransformer.is() )
    1321 [ #  # ][ #  # ]:          0 :                 m_xURLTransformer->parseStrict( _rURL );
    1322                 :            :         }
    1323                 :          0 :         catch( const Exception& )
    1324                 :            :         {
    1325                 :            :             DBG_UNHANDLED_EXCEPTION();
    1326                 :            :         }
    1327                 :          0 :     }
    1328                 :            : 
    1329                 :            :     //------------------------------------------------------------------------
    1330                 :          0 :     FmTextControlFeature* FmTextControlShell::implGetFeatureDispatcher( const Reference< XDispatchProvider >& _rxProvider, SfxApplication* _pApplication, SfxSlotId _nSlot )
    1331                 :            :     {
    1332                 :            :         OSL_PRECOND( _rxProvider.is() && _pApplication, "FmTextControlShell::implGetFeatureDispatcher: invalid arg(s)!" );
    1333                 :          0 :         URL aFeatureURL;
    1334         [ #  # ]:          0 :         aFeatureURL.Complete = lcl_getUnoSlotName( *_pApplication, _nSlot );
    1335         [ #  # ]:          0 :         impl_parseURL_nothrow( aFeatureURL );
    1336 [ #  # ][ #  # ]:          0 :         Reference< XDispatch > xDispatcher = _rxProvider->queryDispatch( aFeatureURL, ::rtl::OUString(), 0xFF );
    1337         [ #  # ]:          0 :         if ( xDispatcher.is() )
    1338         [ #  # ]:          0 :             return new FmTextControlFeature( xDispatcher, aFeatureURL, _nSlot, this );
    1339                 :          0 :         return NULL;
    1340                 :            :     }
    1341                 :            : 
    1342                 :            :     //------------------------------------------------------------------------
    1343                 :          0 :     void FmTextControlShell::Invalidate( SfxSlotId _nSlot )
    1344                 :            :     {
    1345                 :          0 :         m_rBindings.Invalidate( _nSlot );
    1346                 :            :         // despite this method being called "Invalidate", we also update here - this gives more immediate
    1347                 :            :         // feedback in the UI
    1348                 :          0 :         m_rBindings.Update( _nSlot );
    1349                 :          0 :     }
    1350                 :            : 
    1351                 :            :     //------------------------------------------------------------------------
    1352                 :          0 :     void FmTextControlShell::focusGained( const ::com::sun::star::awt::FocusEvent& _rEvent )
    1353                 :            :     {
    1354         [ #  # ]:          0 :         Reference< XControl > xControl( _rEvent.Source, UNO_QUERY );
    1355                 :            : 
    1356                 :            : #if OSL_DEBUG_LEVEL > 0
    1357                 :            :         ::rtl::OString sTrace( "FmTextControlShell::focusGained: 0x" );
    1358                 :            :         sTrace += ::rtl::OString::valueOf( (sal_IntPtr)xControl.get(), 16 );
    1359                 :            :         OSL_TRACE( "%s", sTrace.getStr() );
    1360                 :            : #endif
    1361                 :            : 
    1362                 :            :         DBG_ASSERT( xControl.is(), "FmTextControlShell::focusGained: suspicious focus event!" );
    1363         [ #  # ]:          0 :         if ( xControl.is() )
    1364         [ #  # ]:          0 :             controlActivated( xControl );
    1365                 :          0 :     }
    1366                 :            : 
    1367                 :            :     //------------------------------------------------------------------------
    1368                 :          6 :     void FmTextControlShell::focusLost( const ::com::sun::star::awt::FocusEvent& _rEvent )
    1369                 :            :     {
    1370         [ +  - ]:          6 :         Reference< XControl > xControl( _rEvent.Source, UNO_QUERY );
    1371                 :            : 
    1372                 :            : #if OSL_DEBUG_LEVEL > 0
    1373                 :            :         ::rtl::OString sTrace( "FmTextControlShell::focusLost: 0x" );
    1374                 :            :         sTrace += ::rtl::OString::valueOf( (sal_IntPtr)xControl.get(), 16 );
    1375                 :            :         OSL_TRACE( "%s", sTrace.getStr() );
    1376                 :            : #endif
    1377                 :            : 
    1378                 :          6 :         m_bActiveControl = false;
    1379                 :          6 :     }
    1380                 :            : 
    1381                 :            :     //------------------------------------------------------------------------
    1382                 :        223 :     void FmTextControlShell::ForgetActiveControl()
    1383                 :            :     {
    1384                 :        223 :         implClearActiveControlRef();
    1385                 :        223 :     }
    1386                 :            : 
    1387                 :            :     //------------------------------------------------------------------------
    1388                 :          0 :     void FmTextControlShell::contextMenuRequested( const awt::MouseEvent& /*_rEvent*/ )
    1389                 :            :     {
    1390         [ #  # ]:          0 :         m_rBindings.GetDispatcher()->ExecutePopup( SVX_RES( RID_FM_TEXTATTRIBUTE_MENU ) );
    1391                 :          0 :     }
    1392                 :            : 
    1393                 :            : //........................................................................
    1394                 :            : } // namespace svx
    1395                 :            : //........................................................................
    1396                 :            : 
    1397                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10