lok: Don't attempt to select the exact text after a failed search.
[LibreOffice.git] / svx / source / form / fmtextcontrolshell.cxx
blobe19ff158d38a084be5747b082b2aee276691b214
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "fmprop.hrc"
22 #include "svx/fmresids.hrc"
23 #include "fmtextcontroldialogs.hxx"
24 #include "fmtextcontrolfeature.hxx"
25 #include "fmtextcontrolshell.hxx"
26 #include "editeng/crossedoutitem.hxx"
27 #include "svx/dialmgr.hxx"
28 #include "editeng/editeng.hxx"
29 #include "editeng/eeitem.hxx"
30 #include "svx/fmglob.hxx"
31 #include "editeng/scriptspaceitem.hxx"
32 #include "svx/svxids.hrc"
33 #include "editeng/udlnitem.hxx"
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/awt/FontDescriptor.hpp>
37 #include <com/sun/star/frame/XDispatchProvider.hpp>
38 #include <com/sun/star/form/XForm.hpp>
39 #include <com/sun/star/container/XChild.hpp>
40 #include <com/sun/star/awt/XFocusListener.hpp>
41 #include <com/sun/star/awt/XMouseListener.hpp>
42 #include <com/sun/star/util/URLTransformer.hpp>
44 #include <comphelper/processfactory.hxx>
45 #include <cppuhelper/implbase1.hxx>
46 #include <sfx2/app.hxx>
47 #include <sfx2/bindings.hxx>
48 #include <sfx2/dispatch.hxx>
49 #include <sfx2/msgpool.hxx>
50 #include <sfx2/objsh.hxx>
51 #include <sfx2/request.hxx>
52 #include <sfx2/sfxuno.hxx>
53 #include <sfx2/viewfrm.hxx>
54 #include <svl/eitem.hxx>
55 #include <svl/intitem.hxx>
56 #include <svl/itempool.hxx>
57 #include <svl/languageoptions.hxx>
58 #include <svtools/stringtransfer.hxx>
59 #include <svl/whiter.hxx>
60 #include <toolkit/helper/vclunohelper.hxx>
61 #include <tools/diagnose_ex.h>
62 #include <vcl/msgbox.hxx>
63 #include <vcl/outdev.hxx>
64 #include <osl/mutex.hxx>
67 namespace svx
71 using namespace ::com::sun::star;
72 using namespace ::com::sun::star::uno;
73 using namespace ::com::sun::star::awt;
74 using namespace ::com::sun::star::form;
75 using namespace ::com::sun::star::form::runtime;
76 using namespace ::com::sun::star::lang;
77 using namespace ::com::sun::star::frame;
78 using namespace ::com::sun::star::util;
79 using namespace ::com::sun::star::beans;
80 using namespace ::com::sun::star::container;
83 typedef sal_uInt16 WhichId;
86 static SfxSlotId pTextControlSlots[] =
88 SID_CLIPBOARD_FORMAT_ITEMS,
89 SID_CUT,
90 SID_COPY,
91 SID_PASTE,
92 SID_SELECTALL,
93 // SID_ATTR_TABSTOP, /* 2 */
94 SID_ATTR_CHAR_FONT,
95 SID_ATTR_CHAR_POSTURE,
96 SID_ATTR_CHAR_WEIGHT,
97 SID_ATTR_CHAR_SHADOWED,
98 SID_ATTR_CHAR_WORDLINEMODE,
99 SID_ATTR_CHAR_CONTOUR,
100 SID_ATTR_CHAR_STRIKEOUT,
101 SID_ATTR_CHAR_UNDERLINE,
102 SID_ATTR_CHAR_FONTHEIGHT,
103 SID_ATTR_CHAR_COLOR,
104 SID_ATTR_CHAR_KERNING,
105 SID_ATTR_CHAR_LANGUAGE, /* 20 */
106 SID_ATTR_CHAR_ESCAPEMENT,
107 SID_ATTR_PARA_ADJUST, /* 28 */
108 SID_ATTR_PARA_ADJUST_LEFT,
109 SID_ATTR_PARA_ADJUST_RIGHT,
110 SID_ATTR_PARA_ADJUST_CENTER,
111 SID_ATTR_PARA_ADJUST_BLOCK,
112 SID_ATTR_PARA_LINESPACE, /* 33 */
113 SID_ATTR_PARA_LINESPACE_10,
114 SID_ATTR_PARA_LINESPACE_15,
115 SID_ATTR_PARA_LINESPACE_20,
116 SID_ATTR_LRSPACE, /* 48 */
117 SID_ATTR_ULSPACE, /* 49 */
118 SID_ATTR_CHAR_AUTOKERN,
119 SID_SET_SUPER_SCRIPT,
120 SID_SET_SUB_SCRIPT,
121 SID_CHAR_DLG,
122 SID_PARA_DLG,
123 // SID_TEXTDIRECTION_LEFT_TO_RIGHT, /* 907 */
124 // SID_TEXTDIRECTION_TOP_TO_BOTTOM,
125 SID_ATTR_CHAR_SCALEWIDTH, /* 911 */
126 SID_ATTR_CHAR_RELIEF,
127 SID_ATTR_PARA_LEFT_TO_RIGHT, /* 950 */
128 SID_ATTR_PARA_RIGHT_TO_LEFT,
129 SID_ATTR_CHAR_OVERLINE,
133 // slots which we are not responsible for on the SfxShell level, but
134 // need to handle during the "paragraph attributes" and/or "character
135 // attributes" dialogs
136 static SfxSlotId pDialogSlots[] =
138 SID_ATTR_TABSTOP,
139 SID_ATTR_PARA_HANGPUNCTUATION,
140 SID_ATTR_PARA_FORBIDDEN_RULES,
141 SID_ATTR_PARA_SCRIPTSPACE,
142 SID_ATTR_CHAR_LATIN_LANGUAGE,
143 SID_ATTR_CHAR_CJK_LANGUAGE,
144 SID_ATTR_CHAR_CTL_LANGUAGE,
145 SID_ATTR_CHAR_LATIN_FONT,
146 SID_ATTR_CHAR_CJK_FONT,
147 SID_ATTR_CHAR_CTL_FONT,
148 SID_ATTR_CHAR_LATIN_FONTHEIGHT,
149 SID_ATTR_CHAR_CJK_FONTHEIGHT,
150 SID_ATTR_CHAR_CTL_FONTHEIGHT,
151 SID_ATTR_CHAR_LATIN_WEIGHT,
152 SID_ATTR_CHAR_CJK_WEIGHT,
153 SID_ATTR_CHAR_CTL_WEIGHT,
154 SID_ATTR_CHAR_LATIN_POSTURE,
155 SID_ATTR_CHAR_CJK_POSTURE,
156 SID_ATTR_CHAR_CTL_POSTURE,
157 SID_ATTR_CHAR_EMPHASISMARK,
161 typedef ::cppu::WeakImplHelper1 < XFocusListener
162 > FmFocusListenerAdapter_Base;
163 class FmFocusListenerAdapter : public FmFocusListenerAdapter_Base
165 private:
166 IFocusObserver* m_pObserver;
167 Reference< XWindow > m_xWindow;
169 public:
170 FmFocusListenerAdapter( const Reference< XControl >& _rxControl, IFocusObserver* _pObserver );
172 // clean up the instance
173 void dispose();
175 protected:
176 virtual ~FmFocusListenerAdapter();
178 protected:
179 virtual void SAL_CALL focusGained( const FocusEvent& e ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
180 virtual void SAL_CALL focusLost( const FocusEvent& e ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
181 virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
186 FmFocusListenerAdapter::FmFocusListenerAdapter( const Reference< XControl >& _rxControl, IFocusObserver* _pObserver )
187 :m_pObserver( _pObserver )
188 ,m_xWindow( _rxControl, UNO_QUERY )
191 DBG_ASSERT( m_xWindow.is(), "FmFocusListenerAdapter::FmFocusListenerAdapter: invalid control!" );
192 osl_atomic_increment( &m_refCount );
196 if ( m_xWindow.is() )
197 m_xWindow->addFocusListener( this );
199 catch( const Exception& )
201 DBG_UNHANDLED_EXCEPTION();
204 osl_atomic_decrement( &m_refCount );
208 FmFocusListenerAdapter::~FmFocusListenerAdapter()
210 acquire();
211 dispose();
216 void FmFocusListenerAdapter::dispose()
218 if ( m_xWindow.is() )
220 m_xWindow->removeFocusListener( this );
221 m_xWindow.clear();
226 void SAL_CALL FmFocusListenerAdapter::focusGained( const FocusEvent& e ) throw (RuntimeException, std::exception)
228 if ( m_pObserver )
229 m_pObserver->focusGained( e );
233 void SAL_CALL FmFocusListenerAdapter::focusLost( const FocusEvent& e ) throw (RuntimeException, std::exception)
235 if ( m_pObserver )
236 m_pObserver->focusLost( e );
240 void SAL_CALL FmFocusListenerAdapter::disposing( const EventObject& Source ) throw (RuntimeException, std::exception)
242 (void)Source;
243 DBG_ASSERT( Source.Source == m_xWindow, "FmFocusListenerAdapter::disposing: where did this come from?" );
244 m_xWindow.clear();
247 typedef ::cppu::WeakImplHelper1 < XMouseListener
248 > FmMouseListenerAdapter_Base;
249 class FmMouseListenerAdapter : public FmMouseListenerAdapter_Base
251 private:
252 IContextRequestObserver* m_pObserver;
253 Reference< XWindow > m_xWindow;
255 public:
256 FmMouseListenerAdapter( const Reference< XControl >& _rxControl, IContextRequestObserver* _pObserver );
258 // clean up the instance
259 void dispose();
261 protected:
262 virtual ~FmMouseListenerAdapter();
264 protected:
265 virtual void SAL_CALL mousePressed( const awt::MouseEvent& e ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
266 virtual void SAL_CALL mouseReleased( const awt::MouseEvent& e ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
267 virtual void SAL_CALL mouseEntered( const awt::MouseEvent& e ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
268 virtual void SAL_CALL mouseExited( const awt::MouseEvent& e ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
269 virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException, std::exception) SAL_OVERRIDE;
272 FmMouseListenerAdapter::FmMouseListenerAdapter( const Reference< XControl >& _rxControl, IContextRequestObserver* _pObserver )
273 :m_pObserver( _pObserver )
274 ,m_xWindow( _rxControl, UNO_QUERY )
277 DBG_ASSERT( m_xWindow.is(), "FmMouseListenerAdapter::FmMouseListenerAdapter: invalid control!" );
278 osl_atomic_increment( &m_refCount );
282 if ( m_xWindow.is() )
283 m_xWindow->addMouseListener( this );
285 catch( const Exception& )
287 DBG_UNHANDLED_EXCEPTION();
290 osl_atomic_decrement( &m_refCount );
294 FmMouseListenerAdapter::~FmMouseListenerAdapter()
296 acquire();
297 dispose();
302 void FmMouseListenerAdapter::dispose()
304 if ( m_xWindow.is() )
306 m_xWindow->removeMouseListener( this );
307 m_xWindow.clear();
312 void SAL_CALL FmMouseListenerAdapter::mousePressed( const awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException, std::exception)
314 SolarMutexGuard aGuard;
315 // is this a request for a context menu?
316 if ( _rEvent.PopupTrigger )
318 if ( m_pObserver )
319 m_pObserver->contextMenuRequested( _rEvent );
324 void SAL_CALL FmMouseListenerAdapter::mouseReleased( const awt::MouseEvent& /*e*/ ) throw (::com::sun::star::uno::RuntimeException, std::exception)
326 // not interested in
330 void SAL_CALL FmMouseListenerAdapter::mouseEntered( const awt::MouseEvent& /*e*/ ) throw (::com::sun::star::uno::RuntimeException, std::exception)
332 // not interested in
336 void SAL_CALL FmMouseListenerAdapter::mouseExited( const awt::MouseEvent& /*e*/ ) throw (::com::sun::star::uno::RuntimeException, std::exception)
338 // not interested in
342 void SAL_CALL FmMouseListenerAdapter::disposing( const EventObject& Source ) throw (RuntimeException, std::exception)
344 (void)Source;
345 DBG_ASSERT( Source.Source == m_xWindow, "FmMouseListenerAdapter::disposing: where did this come from?" );
346 m_xWindow.clear();
350 //= FmTextControlShell
353 namespace
356 void lcl_translateUnoStateToItem( SfxSlotId _nSlot, const Any& _rUnoState, SfxItemSet& _rSet )
358 WhichId nWhich = _rSet.GetPool()->GetWhich( _nSlot );
359 if ( !_rUnoState.hasValue() )
361 if ( ( _nSlot != SID_CUT )
362 && ( _nSlot != SID_COPY )
363 && ( _nSlot != SID_PASTE )
366 _rSet.InvalidateItem( nWhich );
369 else
371 switch ( _rUnoState.getValueType().getTypeClass() )
373 case TypeClass_BOOLEAN:
375 bool bState = false;
376 _rUnoState >>= bState;
377 if ( _nSlot == SID_ATTR_PARA_SCRIPTSPACE )
378 _rSet.Put( SvxScriptSpaceItem( bState, nWhich ) );
379 else
380 _rSet.Put( SfxBoolItem( nWhich, bState ) );
382 break;
384 default:
386 Sequence< PropertyValue > aComplexState;
387 if ( _rUnoState >>= aComplexState )
389 if ( !aComplexState.getLength() )
390 _rSet.InvalidateItem( nWhich );
391 else
393 SfxAllItemSet aAllItems( _rSet );
394 TransformParameters( _nSlot, aComplexState, aAllItems );
395 const SfxPoolItem* pTransformed = aAllItems.GetItem( nWhich );
396 OSL_ENSURE( pTransformed, "lcl_translateUnoStateToItem: non-empty parameter sequence leading to empty item?" );
397 if ( pTransformed )
398 _rSet.Put( *pTransformed );
399 else
400 _rSet.InvalidateItem( nWhich );
403 else
405 OSL_FAIL( "lcl_translateUnoStateToItem: invalid state!" );
413 OUString lcl_getUnoSlotName( SfxApplication&, SfxSlotId _nSlotId )
415 OUString sSlotUnoName;
417 SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( NULL );
418 const SfxSlot* pSlot = rSlotPool.GetSlot( _nSlotId );
420 const sal_Char* pAsciiUnoName = NULL;
421 if ( pSlot )
423 pAsciiUnoName = pSlot->GetUnoName();
425 else
427 // some hard-coded slots, which do not have a UNO name at SFX level, but which
428 // we nevertheless need to transport via UNO mechanisms, so we need a name
429 switch ( _nSlotId )
431 case SID_ATTR_PARA_HANGPUNCTUATION: pAsciiUnoName = "AllowHangingPunctuation"; break;
432 case SID_ATTR_PARA_FORBIDDEN_RULES: pAsciiUnoName = "ApplyForbiddenCharacterRules"; break;
433 case SID_ATTR_PARA_SCRIPTSPACE: pAsciiUnoName = "UseScriptSpacing"; break;
437 if ( pAsciiUnoName )
439 sSlotUnoName = ".uno:";
440 sSlotUnoName += OUString::createFromAscii( pAsciiUnoName );
442 #if OSL_DEBUG_LEVEL > 0
443 else
445 OString sMessage( "lcl_getUnoSlotName: invalid slot id, or invalid slot, or no UNO name!\n" );
446 sMessage += "(slot id: ";
447 sMessage += OString::number( _nSlotId );
448 sMessage += ")";
449 OSL_FAIL( sMessage.getStr() );
451 #endif
452 return sSlotUnoName;
456 bool lcl_determineReadOnly( const Reference< XControl >& _rxControl )
458 bool bIsReadOnlyModel = true;
461 Reference< XPropertySet > xModelProps;
462 if ( _rxControl.is() )
463 xModelProps.set(_rxControl->getModel(), css::uno::UNO_QUERY);
464 Reference< XPropertySetInfo > xModelPropInfo;
465 if ( xModelProps.is() )
466 xModelPropInfo = xModelProps->getPropertySetInfo();
468 if ( !xModelPropInfo.is() || !xModelPropInfo->hasPropertyByName( FM_PROP_READONLY ) )
469 bIsReadOnlyModel = true;
470 else
472 bool bReadOnly = true;
473 xModelProps->getPropertyValue( FM_PROP_READONLY ) >>= bReadOnly;
474 bIsReadOnlyModel = bReadOnly;
477 catch( const Exception& )
479 DBG_UNHANDLED_EXCEPTION();
481 return bIsReadOnlyModel;
485 static vcl::Window* lcl_getWindow( const Reference< XControl >& _rxControl )
487 vcl::Window* pWindow = NULL;
490 Reference< XWindowPeer > xControlPeer;
491 if ( _rxControl.is() )
492 xControlPeer = _rxControl->getPeer();
493 if ( xControlPeer.is() )
494 pWindow = VCLUnoHelper::GetWindow( xControlPeer );
496 catch( const Exception& )
498 DBG_UNHANDLED_EXCEPTION();
501 return pWindow;
505 bool lcl_isRichText( const Reference< XControl >& _rxControl )
507 if ( !_rxControl.is() )
508 return false;
510 bool bIsRichText = false;
513 Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY );
514 Reference< XPropertySetInfo > xPSI;
515 if ( xModelProps.is() )
516 xPSI = xModelProps->getPropertySetInfo();
517 OUString sRichTextPropertyName = "RichText";
518 if ( xPSI.is() && xPSI->hasPropertyByName( sRichTextPropertyName ) )
520 OSL_VERIFY( xModelProps->getPropertyValue( sRichTextPropertyName ) >>= bIsRichText );
523 catch( const Exception& )
525 DBG_UNHANDLED_EXCEPTION();
527 return bIsRichText;
532 FmTextControlShell::FmTextControlShell( SfxViewFrame* _pFrame )
533 :m_bActiveControl( false )
534 ,m_bActiveControlIsReadOnly( true )
535 ,m_bActiveControlIsRichText( false )
536 ,m_pViewFrame( _pFrame )
537 ,m_rBindings( _pFrame->GetBindings() )
538 ,m_bNeedClipboardInvalidation( true )
540 m_aClipboardInvalidation.SetTimeoutHdl( LINK( this, FmTextControlShell, OnInvalidateClipboard ) );
541 m_aClipboardInvalidation.SetTimeout( 200 );
545 FmTextControlShell::~FmTextControlShell()
547 dispose();
551 IMPL_LINK_NOARG_TYPED( FmTextControlShell, OnInvalidateClipboard, Timer*, void )
553 if ( m_bNeedClipboardInvalidation )
555 OSL_TRACE( "FmTextControlShell::ClipBoard: invalidating clipboard slots" );
556 m_rBindings.Invalidate( SID_CUT );
557 m_rBindings.Invalidate( SID_COPY );
558 m_rBindings.Invalidate( SID_PASTE );
559 m_bNeedClipboardInvalidation = false;
564 void FmTextControlShell::transferFeatureStatesToItemSet( ControlFeatures& _rDispatchers, SfxAllItemSet& _rSet, bool _bTranslateLatin )
566 SfxItemPool& rPool = *_rSet.GetPool();
568 for ( ControlFeatures::const_iterator aFeature = _rDispatchers.begin();
569 aFeature != _rDispatchers.end();
570 ++aFeature
573 SfxSlotId nSlotId( aFeature->first );
574 #if OSL_DEBUG_LEVEL > 0
575 OUString sUnoSlotName;
576 if ( SfxGetpApp() )
577 sUnoSlotName = lcl_getUnoSlotName( *SfxGetpApp(), nSlotId );
578 else
579 sUnoSlotName = "<unknown>";
580 OString sUnoSlotNameAscii( "\"" );
581 sUnoSlotNameAscii += OString( sUnoSlotName.getStr(), sUnoSlotName.getLength(), RTL_TEXTENCODING_ASCII_US );
582 sUnoSlotNameAscii += "\"";
583 #endif
585 if ( _bTranslateLatin )
587 // A rich text control offers a dispatcher for the "Font" slot/feature.
588 // Sadly, the semantics of the dispatches is that the feature "Font" depends
589 // on the current cursor position: If it's on latin text, it's the "latin font"
590 // which is set up at the control. If it's on CJK text, it's the "CJK font", and
591 // aequivalent for "CTL font".
592 // The same holds for some other font related features/slots.
593 // Thus, we have separate dispatches for "Latin Font", "Latin Font Size", etc,
594 // which are only "virtual", in a sense that there exist no item with this id.
595 // So when we encounter such a dispatcher for, say, "Latin Font", we need to
596 // put an item into the set which has the "Font" id.
598 switch ( nSlotId )
600 case SID_ATTR_CHAR_LATIN_FONT: nSlotId = SID_ATTR_CHAR_FONT; break;
601 case SID_ATTR_CHAR_LATIN_FONTHEIGHT:nSlotId = SID_ATTR_CHAR_FONTHEIGHT; break;
602 case SID_ATTR_CHAR_LATIN_LANGUAGE: nSlotId = SID_ATTR_CHAR_LANGUAGE; break;
603 case SID_ATTR_CHAR_LATIN_POSTURE: nSlotId = SID_ATTR_CHAR_POSTURE; break;
604 case SID_ATTR_CHAR_LATIN_WEIGHT: nSlotId = SID_ATTR_CHAR_WEIGHT; break;
608 WhichId nWhich = rPool.GetWhich( nSlotId );
609 bool bIsInPool = rPool.IsInRange( nWhich );
610 if ( bIsInPool )
612 #if OSL_DEBUG_LEVEL > 0
613 bool bFeatureIsEnabled = aFeature->second->isFeatureEnabled();
614 OString sMessage( "FmTextControlShell::transferFeatureStatesToItemSet: found a feature state for " );
615 sMessage += sUnoSlotNameAscii;
616 if ( !bFeatureIsEnabled )
617 sMessage += " (disabled)";
618 OSL_TRACE( "%s", sMessage.getStr() );
619 #endif
621 lcl_translateUnoStateToItem( nSlotId, aFeature->second->getFeatureState(), _rSet );
623 #if OSL_DEBUG_LEVEL > 0
624 else
626 OString sMessage( "FmTextControlShell::transferFeatureStatesToItemSet: found a feature state for " );
627 sMessage += sUnoSlotNameAscii;
628 sMessage += ", but could not translate it into an item!";
629 OSL_TRACE( "%s", sMessage.getStr() );
631 #endif
636 void FmTextControlShell::executeAttributeDialog( AttributeSet _eSet, SfxRequest& _rReq )
638 const SvxFontListItem* pFontList = PTR_CAST( SvxFontListItem, m_pViewFrame->GetObjectShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
639 DBG_ASSERT( pFontList, "FmTextControlShell::executeAttributeDialog: no font list item!" );
640 if ( !pFontList )
641 return;
643 SfxItemPool* pPool = EditEngine::CreatePool();
644 pPool->FreezeIdRanges();
645 boost::scoped_ptr< SfxItemSet > xPureItems( new SfxItemSet( *pPool ) );
647 // put the current states of the items into the set
648 boost::scoped_ptr<SfxAllItemSet> xCurrentItems( new SfxAllItemSet( *xPureItems ) );
649 transferFeatureStatesToItemSet( m_aControlFeatures, *xCurrentItems );
651 // additional items, which we are not responsible for at the SfxShell level,
652 // but which need to be forwarded to the dialog, anyway
653 ControlFeatures aAdditionalFestures;
654 fillFeatureDispatchers( m_xActiveControl, pDialogSlots, aAdditionalFestures );
655 transferFeatureStatesToItemSet( aAdditionalFestures, *xCurrentItems, true );
657 VclPtr<SfxTabDialog> xDialog;
658 if ( _eSet == eCharAttribs)
659 xDialog = VclPtr<TextControlCharAttribDialog>::Create( nullptr, *xCurrentItems, *pFontList );
660 else
661 xDialog = VclPtr<TextControlParaAttribDialog>::Create( nullptr, *xCurrentItems );
662 if ( RET_OK == xDialog->Execute() )
664 const SfxItemSet& rModifiedItems = *xDialog->GetOutputItemSet();
665 for ( WhichId nWhich = pPool->GetFirstWhich(); nWhich <= pPool->GetLastWhich(); ++nWhich )
667 if ( rModifiedItems.GetItemState( nWhich ) == SfxItemState::SET )
669 SfxSlotId nSlotForItemSet = pPool->GetSlotId( nWhich );
670 const SfxPoolItem* pModifiedItem = rModifiedItems.GetItem( nWhich );
673 SfxSlotId nSlotForDispatcher = nSlotForItemSet;
674 switch ( nSlotForDispatcher )
676 case SID_ATTR_CHAR_FONT: nSlotForDispatcher = SID_ATTR_CHAR_LATIN_FONT; break;
677 case SID_ATTR_CHAR_FONTHEIGHT:nSlotForDispatcher = SID_ATTR_CHAR_LATIN_FONTHEIGHT; break;
678 case SID_ATTR_CHAR_LANGUAGE: nSlotForDispatcher = SID_ATTR_CHAR_LATIN_LANGUAGE; break;
679 case SID_ATTR_CHAR_POSTURE: nSlotForDispatcher = SID_ATTR_CHAR_LATIN_POSTURE; break;
680 case SID_ATTR_CHAR_WEIGHT: nSlotForDispatcher = SID_ATTR_CHAR_LATIN_WEIGHT; break;
683 // do we already have a dispatcher for this slot/feature?
684 ControlFeatures::const_iterator aFeaturePos = m_aControlFeatures.find( nSlotForDispatcher );
685 bool bFound = aFeaturePos != m_aControlFeatures.end( );
687 if ( !bFound )
689 aFeaturePos = aAdditionalFestures.find( nSlotForDispatcher );
690 bFound = aFeaturePos != aAdditionalFestures.end( );
693 if ( bFound )
695 Sequence< PropertyValue > aArgs;
696 // temporarily put the modified item into a "clean" set,
697 // and let TransformItems calc the respective UNO parameters
698 xPureItems->Put( *pModifiedItem );
699 TransformItems( nSlotForItemSet, *xPureItems, aArgs );
700 xPureItems->ClearItem( nWhich );
702 if ( ( nSlotForItemSet == SID_ATTR_PARA_HANGPUNCTUATION )
703 || ( nSlotForItemSet == SID_ATTR_PARA_FORBIDDEN_RULES )
704 || ( nSlotForItemSet == SID_ATTR_PARA_SCRIPTSPACE )
707 // these are no UNO slots, they need special handling since TransformItems cannot
708 // handle them
709 DBG_ASSERT( aArgs.getLength() == 0, "FmTextControlShell::executeAttributeDialog: these are no UNO slots - are they?" );
711 const SfxBoolItem* pBoolItem = PTR_CAST( SfxBoolItem, pModifiedItem );
712 DBG_ASSERT( pBoolItem, "FmTextControlShell::executeAttributeDialog: no bool item?!" );
713 if ( pBoolItem )
715 aArgs.realloc( 1 );
716 aArgs[ 0 ].Name = "Enable";
717 aArgs[ 0 ].Value <<= pBoolItem->GetValue();
721 // dispatch this
722 aFeaturePos->second->dispatch( aArgs );
724 #if OSL_DEBUG_LEVEL > 0
725 else
727 OString sError( "FmTextControShell::executeAttributeDialog: Could not handle the following item:" );
728 sError += "\n SlotID: "; sError += OString::number( nSlotForItemSet );
729 sError += "\n WhichID: "; sError += OString::number( nWhich );
730 sError += "\n UNO name: ";
732 OUString sUnoSlotName = lcl_getUnoSlotName( *SfxGetpApp(), nSlotForItemSet );
733 if ( !sUnoSlotName.isEmpty() )
734 sError += OString( sUnoSlotName.getStr(), sUnoSlotName.getLength(), RTL_TEXTENCODING_ASCII_US );
735 else
736 sError += "unknown (no SfxSlot)";
737 OSL_FAIL( sError.getStr() );
739 #endif
742 _rReq.Done( rModifiedItems );
745 xDialog.reset();
746 xCurrentItems.reset();
747 xPureItems.reset();
748 SfxItemPool::Free(pPool);
752 bool FmTextControlShell::executeSelectAll( )
756 if ( m_xActiveTextComponent.is() )
758 sal_Int32 nTextLen = m_xActiveTextComponent->getText().getLength();
759 m_xActiveTextComponent->setSelection( awt::Selection( 0, nTextLen ) );
760 return true;
763 catch( const Exception& )
765 DBG_UNHANDLED_EXCEPTION();
767 return false; // not handled
771 bool FmTextControlShell::executeClipboardSlot( SfxSlotId _nSlot )
775 if ( m_xActiveTextComponent.is() )
777 switch ( _nSlot )
779 case SID_COPY:
780 case SID_CUT:
782 OUString sSelectedText( m_xActiveTextComponent->getSelectedText() );
783 ::svt::OStringTransfer::CopyString( sSelectedText, lcl_getWindow( m_xActiveControl ) );
784 if ( SID_CUT == _nSlot )
786 awt::Selection aSelection( m_xActiveTextComponent->getSelection() );
787 m_xActiveTextComponent->insertText( aSelection, OUString() );
790 break;
791 case SID_PASTE:
793 OUString sClipboardContent;
794 OSL_VERIFY( ::svt::OStringTransfer::PasteString( sClipboardContent, lcl_getWindow( m_xActiveControl ) ) );
795 awt::Selection aSelection( m_xActiveTextComponent->getSelection() );
796 m_xActiveTextComponent->insertText( aSelection, sClipboardContent );
798 break;
799 default:
800 OSL_FAIL( "FmTextControlShell::executeClipboardSlot: invalid slot!" );
802 return true;
805 catch( const Exception& )
807 DBG_UNHANDLED_EXCEPTION();
809 return false; // not handled
813 void FmTextControlShell::ExecuteTextAttribute( SfxRequest& _rReq )
815 SfxSlotId nSlot = _rReq.GetSlot();
817 ControlFeatures::const_iterator aFeaturePos = m_aControlFeatures.find( nSlot );
818 if ( aFeaturePos == m_aControlFeatures.end() )
820 // special slots
821 switch ( nSlot )
823 case SID_CHAR_DLG:
824 executeAttributeDialog( eCharAttribs, _rReq );
825 break;
827 case SID_PARA_DLG:
828 executeAttributeDialog( eParaAttribs, _rReq );
829 break;
831 case SID_SELECTALL:
832 executeSelectAll();
833 break;
835 case SID_CUT:
836 case SID_COPY:
837 case SID_PASTE:
838 executeClipboardSlot( nSlot );
839 break;
841 default:
842 DBG_ASSERT( aFeaturePos != m_aControlFeatures.end(), "FmTextControShell::ExecuteTextAttribute: I have no such dispatcher, and cannot handle it at all!" );
843 return;
846 else
848 // slots which are dispatched to the control
850 switch ( nSlot )
852 case SID_ATTR_CHAR_STRIKEOUT:
853 case SID_ATTR_CHAR_UNDERLINE:
854 case SID_ATTR_CHAR_OVERLINE:
856 SfxItemSet aToggled( *_rReq.GetArgs() );
858 lcl_translateUnoStateToItem( nSlot, aFeaturePos->second->getFeatureState(), aToggled );
859 WhichId nWhich = aToggled.GetPool()->GetWhich( nSlot );
860 const SfxPoolItem* pItem = aToggled.GetItem( nWhich );
861 if ( ( SID_ATTR_CHAR_UNDERLINE == nSlot ) || ( SID_ATTR_CHAR_OVERLINE == nSlot ) )
863 const SvxOverlineItem* pTextLine = PTR_CAST( SvxOverlineItem, pItem );
864 DBG_ASSERT( pTextLine, "FmTextControlShell::ExecuteTextAttribute: ooops - no underline/overline item!" );
865 if ( pTextLine )
867 FontUnderline eTL = pTextLine->GetLineStyle();
868 if ( SID_ATTR_CHAR_UNDERLINE == nSlot ) {
869 aToggled.Put( SvxUnderlineItem( eTL == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, nWhich ) );
870 } else {
871 aToggled.Put( SvxOverlineItem( eTL == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, nWhich ) );
875 else
877 const SvxCrossedOutItem* pCrossedOut = PTR_CAST( SvxCrossedOutItem, pItem );
878 DBG_ASSERT( pCrossedOut, "FmTextControlShell::ExecuteTextAttribute: ooops - no CrossedOut item!" );
879 if ( pCrossedOut )
881 FontStrikeout eFS = pCrossedOut->GetStrikeout();
882 aToggled.Put( SvxCrossedOutItem( eFS == STRIKEOUT_SINGLE ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, nWhich ) );
886 Sequence< PropertyValue > aArguments;
887 TransformItems( nSlot, aToggled, aArguments );
888 aFeaturePos->second->dispatch( aArguments );
890 break;
892 case SID_ATTR_CHAR_FONTHEIGHT:
893 case SID_ATTR_CHAR_FONT:
894 case SID_ATTR_CHAR_POSTURE:
895 case SID_ATTR_CHAR_WEIGHT:
896 case SID_ATTR_CHAR_SHADOWED:
897 case SID_ATTR_CHAR_CONTOUR:
898 case SID_SET_SUPER_SCRIPT:
899 case SID_SET_SUB_SCRIPT:
901 const SfxItemSet* pArgs = _rReq.GetArgs();
902 Sequence< PropertyValue > aArgs;
903 if ( pArgs )
904 TransformItems( nSlot, *pArgs, aArgs );
905 aFeaturePos->second->dispatch( aArgs );
907 break;
909 default:
910 if ( aFeaturePos->second->isFeatureEnabled() )
911 aFeaturePos->second->dispatch();
912 break;
915 _rReq.Done();
919 void FmTextControlShell::GetTextAttributeState( SfxItemSet& _rSet )
921 SfxWhichIter aIter( _rSet );
922 sal_uInt16 nSlot = aIter.FirstWhich();
923 while ( nSlot )
925 if ( ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT )
926 || ( nSlot == SID_ATTR_PARA_RIGHT_TO_LEFT )
929 if ( !SvtLanguageOptions().IsCTLFontEnabled() )
931 _rSet.DisableItem( nSlot );
932 nSlot = aIter.NextWhich();
933 continue;
937 ControlFeatures::const_iterator aFeaturePos = m_aControlFeatures.find( nSlot );
938 if ( aFeaturePos != m_aControlFeatures.end() )
940 if ( aFeaturePos->second->isFeatureEnabled() )
941 lcl_translateUnoStateToItem( nSlot, aFeaturePos->second->getFeatureState(), _rSet );
942 else
943 _rSet.DisableItem( nSlot );
945 else
947 bool bDisable = false;
949 bool bNeedWriteableControl = false;
950 bool bNeedTextComponent = false;
951 bool bNeedSelection = false;
953 switch ( nSlot )
955 case SID_CHAR_DLG:
956 case SID_PARA_DLG:
957 bDisable |= m_aControlFeatures.empty();
958 bNeedWriteableControl = true;
959 break;
961 case SID_CUT:
962 bNeedSelection = true;
963 bNeedTextComponent = true;
964 bNeedWriteableControl = true;
965 OSL_TRACE( "FmTextControlShell::ClipBoard: need to invalidate again" );
966 m_bNeedClipboardInvalidation = true;
967 break;
969 case SID_PASTE:
971 vcl::Window* pActiveControlVCLWindow = lcl_getWindow( m_xActiveControl );
972 if ( pActiveControlVCLWindow )
974 TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pActiveControlVCLWindow) );
975 bDisable |= !aDataHelper.HasFormat( SotClipboardFormatId::STRING );
977 else
978 bDisable |= true;
980 bNeedTextComponent = true;
981 bNeedWriteableControl = true;
983 break;
985 case SID_COPY:
986 bNeedTextComponent = true;
987 bNeedSelection = true;
988 break;
990 case SID_SELECTALL:
991 bNeedTextComponent = true;
992 break;
994 default:
995 // slot is unknown at all
996 bDisable |= true;
997 break;
999 SAL_WARN_IF( bNeedSelection && !bNeedTextComponent, "svx.form", "FmTextControlShell::GetTextAttributeState: bNeedSelection should imply bNeedTextComponent!" );
1001 if ( !bDisable && bNeedWriteableControl )
1002 bDisable |= !IsActiveControl( ) || m_bActiveControlIsReadOnly;
1004 if ( !bDisable && bNeedTextComponent )
1005 bDisable |= !m_xActiveTextComponent.is();
1007 if ( !bDisable && bNeedSelection )
1009 awt::Selection aSelection = m_xActiveTextComponent->getSelection();
1010 bDisable |= aSelection.Min == aSelection.Max;
1013 if ( bDisable )
1014 _rSet.DisableItem( nSlot );
1017 nSlot = aIter.NextWhich();
1022 bool FmTextControlShell::IsActiveControl( bool _bCountRichTextOnly ) const
1024 if ( _bCountRichTextOnly && !m_bActiveControlIsRichText )
1025 return false;
1027 return m_bActiveControl;
1031 void FmTextControlShell::dispose()
1033 if ( IsActiveControl() )
1034 controlDeactivated();
1035 if ( isControllerListening() )
1036 stopControllerListening();
1040 void FmTextControlShell::designModeChanged( bool /*_bNewDesignMode*/ )
1042 m_rBindings.Invalidate( pTextControlSlots );
1046 void FmTextControlShell::formActivated( const Reference< runtime::XFormController >& _rxController )
1048 #if OSL_DEBUG_LEVEL > 0
1049 OString sTrace( "FmTextControlShell::formActivated: 0x" );
1050 sTrace += OString::number( reinterpret_cast<sal_IntPtr>(_rxController.get()), 16 );
1051 OSL_TRACE( "%s", sTrace.getStr() );
1052 #endif
1054 DBG_ASSERT( _rxController.is(), "FmTextControlShell::formActivated: invalid controller!" );
1055 if ( !_rxController.is() )
1056 return;
1058 // sometimes, a form controller notifies activations, even if it's already activated
1059 if ( m_xActiveController == _rxController )
1060 return;
1064 startControllerListening( _rxController );
1065 controlActivated( _rxController->getCurrentControl() );
1067 catch( const Exception& )
1069 DBG_UNHANDLED_EXCEPTION();
1074 void FmTextControlShell::formDeactivated( const Reference< runtime::XFormController >& _rxController )
1076 #if OSL_DEBUG_LEVEL > 0
1077 OString sTrace( "FmTextControlShell::formDeactivated: 0x" );
1078 sTrace += OString::number( reinterpret_cast<sal_IntPtr>(_rxController.get()), 16 );
1079 OSL_TRACE( "%s", sTrace.getStr() );
1080 #endif
1081 (void)_rxController;
1083 if ( IsActiveControl() )
1084 controlDeactivated();
1085 if ( isControllerListening() )
1086 stopControllerListening();
1090 void FmTextControlShell::startControllerListening( const Reference< runtime::XFormController >& _rxController )
1092 OSL_PRECOND( _rxController.is(), "FmTextControlShell::startControllerListening: invalid controller!" );
1093 if ( !_rxController.is() )
1094 return;
1096 OSL_PRECOND( !isControllerListening(), "FmTextControlShell::startControllerListening: already listening!" );
1097 if ( isControllerListening() )
1098 stopControllerListening( );
1099 DBG_ASSERT( !isControllerListening(), "FmTextControlShell::startControllerListening: inconsistence!" );
1103 Sequence< Reference< XControl > > aControls( _rxController->getControls() );
1104 m_aControlObservers.resize( 0 );
1105 m_aControlObservers.reserve( aControls.getLength() );
1107 const Reference< XControl >* pControls = aControls.getConstArray();
1108 const Reference< XControl >* pControlsEnd = pControls + aControls.getLength();
1109 for ( ; pControls != pControlsEnd; ++pControls )
1111 m_aControlObservers.push_back( FocusListenerAdapter( new FmFocusListenerAdapter( *pControls, this ) ) );
1114 catch( const Exception& )
1116 DBG_UNHANDLED_EXCEPTION();
1119 m_xActiveController = _rxController;
1123 void FmTextControlShell::stopControllerListening( )
1125 OSL_PRECOND( isControllerListening(), "FmTextControlShell::stopControllerListening: inconsistence!" );
1127 // dispose all listeners associated with the controls of the active controller
1128 for ( FocusListenerAdapters::iterator aLoop = m_aControlObservers.begin();
1129 aLoop != m_aControlObservers.end();
1130 ++aLoop
1133 (*aLoop)->dispose();
1136 FocusListenerAdapters aEmpty;
1137 m_aControlObservers.swap( aEmpty );
1139 m_xActiveController.clear();
1143 void FmTextControlShell::implClearActiveControlRef()
1145 // no more features for this control
1146 for ( ControlFeatures::iterator aLoop = m_aControlFeatures.begin();
1147 aLoop != m_aControlFeatures.end();
1148 ++aLoop
1151 aLoop->second->dispose();
1154 ControlFeatures aEmpty;
1155 m_aControlFeatures.swap( aEmpty );
1157 if ( m_aContextMenuObserver.get() )
1159 m_aContextMenuObserver->dispose();
1160 m_aContextMenuObserver = MouseListenerAdapter();
1163 if ( m_xActiveTextComponent.is() )
1165 OSL_TRACE( "FmTextControlShell::ClipBoard: stopping timer for clipboard invalidation" );
1166 m_aClipboardInvalidation.Stop();
1168 // no more active control
1169 m_xActiveControl.clear();
1170 m_xActiveTextComponent.clear();
1171 m_bActiveControlIsReadOnly = true;
1172 m_bActiveControlIsRichText = false;
1173 m_bActiveControl = false;
1177 void FmTextControlShell::controlDeactivated( )
1179 DBG_ASSERT( IsActiveControl(), "FmTextControlShell::controlDeactivated: no active control!" );
1181 m_bActiveControl = false;
1183 m_rBindings.Invalidate( pTextControlSlots );
1187 void FmTextControlShell::controlActivated( const Reference< XControl >& _rxControl )
1189 // ensure that all knittings with the previously active control are lost
1190 if ( m_xActiveControl.is() )
1191 implClearActiveControlRef();
1192 DBG_ASSERT( m_aControlFeatures.empty(), "FmTextControlShell::controlActivated: should have no dispatchers when I'm here!" );
1194 #if OSL_DEBUG_LEVEL > 0
1196 Sequence< Reference< XControl > > aActiveControls;
1197 if ( m_xActiveController.is() )
1198 aActiveControls = m_xActiveController->getControls();
1200 bool bFoundThisControl = false;
1202 const Reference< XControl >* pControls = aActiveControls.getConstArray();
1203 const Reference< XControl >* pControlsEnd = pControls + aActiveControls.getLength();
1204 for ( ; ( pControls != pControlsEnd ) && !bFoundThisControl; ++pControls )
1206 if ( *pControls == _rxControl )
1207 bFoundThisControl = true;
1209 DBG_ASSERT( bFoundThisControl, "FmTextControlShell::controlActivated: only controls which belong to the active controller can be activated!" );
1211 #endif
1212 // ask the control for dispatchers for our text-related slots
1213 fillFeatureDispatchers( _rxControl, pTextControlSlots, m_aControlFeatures );
1215 // remember this control
1216 m_xActiveControl = _rxControl;
1217 m_xActiveTextComponent.set(_rxControl, css::uno::UNO_QUERY);
1218 m_bActiveControlIsReadOnly = lcl_determineReadOnly( m_xActiveControl );
1219 m_bActiveControlIsRichText = lcl_isRichText( m_xActiveControl );
1221 // if we found a rich text control, we need context menu support
1222 if ( m_bActiveControlIsRichText )
1224 DBG_ASSERT( NULL == m_aContextMenuObserver.get(), "FmTextControlShell::controlActivated: already have an observer!" );
1225 m_aContextMenuObserver = MouseListenerAdapter( new FmMouseListenerAdapter( _rxControl, this ) );
1228 if ( m_xActiveTextComponent.is() )
1230 OSL_TRACE( "FmTextControlShell::ClipBoard: starting timer for clipboard invalidation" );
1231 m_aClipboardInvalidation.Start();
1234 m_bActiveControl = true;
1236 m_rBindings.Invalidate( pTextControlSlots );
1238 if ( m_pViewFrame )
1239 m_pViewFrame->UIFeatureChanged();
1241 // don't call the activation handler if we don't have any slots we can serve
1242 // The activation handler is used to put the shell on the top of the dispatcher stack,
1243 // so it's preferred when slots are distributed.
1244 // Note that this is a slight hack, to prevent that we grab slots from the SfxDispatcher
1245 // which should be served by other shells (e.g. Cut/Copy/Paste).
1246 // A real solution would be a forwarding-mechanism for slots: We should be on the top
1247 // if we're active, but if we cannot handle the slot, then we need to tell the dispatcher
1248 // to skip our shell, and pass the slot to the next one. However, this mechanism is not
1249 // not in place in SFX.
1250 // Another possibility would be to have dedicated shells for the slots which we might
1251 // or might not be able to serve. However, this could probably increase the number of
1252 // shells too much (In theory, nearly every slot could have an own shell then).
1254 // #i51621# / 2005-08-19 / frank.schoenheit@sun.com
1255 // bool bHaveAnyServeableSlots = m_xActiveTextComponent.is() || !m_aControlFeatures.empty();
1256 // LEM: not calling m_aControlActivatonHandler causes fdo#63695, so disable this hack for now.
1257 if ( m_aControlActivationHandler.IsSet() /* && bHaveAnyServeableSlots */ )
1258 m_aControlActivationHandler.Call( NULL );
1260 m_bNeedClipboardInvalidation = true;
1264 void FmTextControlShell::fillFeatureDispatchers(const Reference< XControl >& _rxControl, SfxSlotId* _pZeroTerminatedSlots,
1265 ControlFeatures& _rDispatchers)
1267 Reference< XDispatchProvider > xProvider( _rxControl, UNO_QUERY );
1268 SfxApplication* pApplication = SfxGetpApp();
1269 DBG_ASSERT( pApplication, "FmTextControlShell::fillFeatureDispatchers: no SfxApplication!" );
1270 if ( xProvider.is() && pApplication )
1272 SfxSlotId* pSlots = _pZeroTerminatedSlots;
1273 while ( *pSlots )
1275 FmTextControlFeature* pDispatcher = implGetFeatureDispatcher( xProvider, pApplication, *pSlots );
1276 if ( pDispatcher )
1277 _rDispatchers.insert( ControlFeatures::value_type( *pSlots, ControlFeature( pDispatcher ) ) );
1279 ++pSlots;
1285 void FmTextControlShell::impl_parseURL_nothrow( URL& _rURL )
1289 if ( !m_xURLTransformer.is() )
1291 m_xURLTransformer = util::URLTransformer::create( ::comphelper::getProcessComponentContext() );
1293 if ( m_xURLTransformer.is() )
1294 m_xURLTransformer->parseStrict( _rURL );
1296 catch( const Exception& )
1298 DBG_UNHANDLED_EXCEPTION();
1303 FmTextControlFeature* FmTextControlShell::implGetFeatureDispatcher( const Reference< XDispatchProvider >& _rxProvider, SfxApplication* _pApplication, SfxSlotId _nSlot )
1305 OSL_PRECOND( _rxProvider.is() && _pApplication, "FmTextControlShell::implGetFeatureDispatcher: invalid arg(s)!" );
1306 URL aFeatureURL;
1307 aFeatureURL.Complete = lcl_getUnoSlotName( *_pApplication, _nSlot );
1308 impl_parseURL_nothrow( aFeatureURL );
1309 Reference< XDispatch > xDispatcher = _rxProvider->queryDispatch( aFeatureURL, OUString(), 0xFF );
1310 if ( xDispatcher.is() )
1311 return new FmTextControlFeature( xDispatcher, aFeatureURL, _nSlot, this );
1312 return NULL;
1316 void FmTextControlShell::Invalidate( SfxSlotId _nSlot )
1318 m_rBindings.Invalidate( _nSlot );
1319 // despite this method being called "Invalidate", we also update here - this gives more immediate
1320 // feedback in the UI
1321 m_rBindings.Update( _nSlot );
1325 void FmTextControlShell::focusGained( const ::com::sun::star::awt::FocusEvent& _rEvent )
1327 Reference< XControl > xControl( _rEvent.Source, UNO_QUERY );
1329 #if OSL_DEBUG_LEVEL > 0
1330 OString sTrace( "FmTextControlShell::focusGained: 0x" );
1331 sTrace += OString::number( reinterpret_cast<sal_IntPtr>(xControl.get()), 16 );
1332 OSL_TRACE( "%s", sTrace.getStr() );
1333 #endif
1335 DBG_ASSERT( xControl.is(), "FmTextControlShell::focusGained: suspicious focus event!" );
1336 if ( xControl.is() )
1337 controlActivated( xControl );
1341 void FmTextControlShell::focusLost( const ::com::sun::star::awt::FocusEvent& _rEvent )
1343 Reference< XControl > xControl( _rEvent.Source, UNO_QUERY );
1345 #if OSL_DEBUG_LEVEL > 0
1346 OString sTrace( "FmTextControlShell::focusLost: 0x" );
1347 sTrace += OString::number( reinterpret_cast<sal_IntPtr>(xControl.get()), 16 );
1348 OSL_TRACE( "%s", sTrace.getStr() );
1349 #endif
1351 m_bActiveControl = false;
1355 void FmTextControlShell::ForgetActiveControl()
1357 implClearActiveControlRef();
1361 void FmTextControlShell::contextMenuRequested( const awt::MouseEvent& /*_rEvent*/ )
1363 m_rBindings.GetDispatcher()->ExecutePopup( SVX_RES( RID_FM_TEXTATTRIBUTE_MENU ) );
1370 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */