1*24acc546SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*24acc546SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*24acc546SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*24acc546SAndrew Rist * distributed with this work for additional information 6*24acc546SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*24acc546SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*24acc546SAndrew Rist * "License"); you may not use this file except in compliance 9*24acc546SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*24acc546SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*24acc546SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*24acc546SAndrew Rist * software distributed under the License is distributed on an 15*24acc546SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*24acc546SAndrew Rist * KIND, either express or implied. See the License for the 17*24acc546SAndrew Rist * specific language governing permissions and limitations 18*24acc546SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*24acc546SAndrew Rist *************************************************************/ 21*24acc546SAndrew Rist 22*24acc546SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_forms.hxx" 26cdf0e10cSrcweir #include "richtextcontrol.hxx" 27cdf0e10cSrcweir #include "frm_module.hxx" 28cdf0e10cSrcweir #ifndef _FRM_PROPERTY_HRC_ 29cdf0e10cSrcweir #include "property.hrc" 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir #include "services.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include "richtextmodel.hxx" 34cdf0e10cSrcweir #include "richtextvclcontrol.hxx" 35cdf0e10cSrcweir #include "clipboarddispatcher.hxx" 36cdf0e10cSrcweir #include "parametrizedattributedispatcher.hxx" 37cdf0e10cSrcweir #include "specialdispatchers.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir /** === begin UNO includes === **/ 40cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 41cdf0e10cSrcweir /** === end UNO includes === **/ 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 44cdf0e10cSrcweir #include <tools/diagnose_ex.h> 45cdf0e10cSrcweir #include <vcl/svapp.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir #include <svx/svxids.hrc> 48cdf0e10cSrcweir #include <editeng/editview.hxx> 49cdf0e10cSrcweir #include <svl/itemset.hxx> 50cdf0e10cSrcweir #include <svl/itempool.hxx> 51cdf0e10cSrcweir #include <sfx2/msgpool.hxx> 52cdf0e10cSrcweir 53cdf0e10cSrcweir //-------------------------------------------------------------------------- 54cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_ORichTextControl() 55cdf0e10cSrcweir { 56cdf0e10cSrcweir static ::frm::OMultiInstanceAutoRegistration< ::frm::ORichTextControl > aAutoRegistration; 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir //......................................................................... 60cdf0e10cSrcweir namespace frm 61cdf0e10cSrcweir { 62cdf0e10cSrcweir //......................................................................... 63cdf0e10cSrcweir 64cdf0e10cSrcweir using namespace ::com::sun::star::uno; 65cdf0e10cSrcweir using namespace ::com::sun::star::beans; 66cdf0e10cSrcweir using namespace ::com::sun::star::awt; 67cdf0e10cSrcweir using namespace ::com::sun::star::lang; 68cdf0e10cSrcweir using namespace ::com::sun::star::frame; 69cdf0e10cSrcweir 70cdf0e10cSrcweir #define FORWARD_TO_PEER_1( unoInterface, method, param1 ) \ 71cdf0e10cSrcweir Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \ 72cdf0e10cSrcweir if ( xTypedPeer.is() ) \ 73cdf0e10cSrcweir { \ 74cdf0e10cSrcweir xTypedPeer->method( param1 ); \ 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir #define FORWARD_TO_PEER_1_RET( returnType, unoInterface, method, param1 ) \ 78cdf0e10cSrcweir returnType aReturn; \ 79cdf0e10cSrcweir Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \ 80cdf0e10cSrcweir if ( xTypedPeer.is() ) \ 81cdf0e10cSrcweir { \ 82cdf0e10cSrcweir aReturn = xTypedPeer->method( param1 ); \ 83cdf0e10cSrcweir } \ 84cdf0e10cSrcweir return aReturn; 85cdf0e10cSrcweir 86cdf0e10cSrcweir #define FORWARD_TO_PEER_3( unoInterface, method, param1, param2, param3 ) \ 87cdf0e10cSrcweir Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \ 88cdf0e10cSrcweir if ( xTypedPeer.is() ) \ 89cdf0e10cSrcweir { \ 90cdf0e10cSrcweir xTypedPeer->method( param1, param2, param3 ); \ 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir #define FORWARD_TO_PEER_3_RET( returnType, unoInterface, method, param1, param2, param3 ) \ 94cdf0e10cSrcweir returnType aReturn; \ 95cdf0e10cSrcweir Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \ 96cdf0e10cSrcweir if ( xTypedPeer.is() ) \ 97cdf0e10cSrcweir { \ 98cdf0e10cSrcweir aReturn = xTypedPeer->method( param1, param2, param3 ); \ 99cdf0e10cSrcweir } \ 100cdf0e10cSrcweir return aReturn; 101cdf0e10cSrcweir 102cdf0e10cSrcweir //================================================================== 103cdf0e10cSrcweir // ORichTextControl 104cdf0e10cSrcweir //================================================================== 105cdf0e10cSrcweir DBG_NAME( ORichTextControl ) 106cdf0e10cSrcweir //------------------------------------------------------------------ 107cdf0e10cSrcweir ORichTextControl::ORichTextControl( const Reference< XMultiServiceFactory >& _rxORB ) 108cdf0e10cSrcweir :UnoEditControl( _rxORB ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir DBG_CTOR( ORichTextControl, NULL ); 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir //------------------------------------------------------------------ 114cdf0e10cSrcweir ORichTextControl::~ORichTextControl() 115cdf0e10cSrcweir { 116cdf0e10cSrcweir DBG_DTOR( ORichTextControl, NULL ); 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir //------------------------------------------------------------------ 120cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( ORichTextControl, UnoEditControl, ORichTextControl_Base ) 121cdf0e10cSrcweir 122cdf0e10cSrcweir //------------------------------------------------------------------ 123cdf0e10cSrcweir Any SAL_CALL ORichTextControl::queryAggregation( const Type& _rType ) throw ( RuntimeException ) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir Any aReturn = UnoEditControl::queryAggregation( _rType ); 126cdf0e10cSrcweir 127cdf0e10cSrcweir if ( !aReturn.hasValue() ) 128cdf0e10cSrcweir aReturn = ORichTextControl_Base::queryInterface( _rType ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir return aReturn; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir //------------------------------------------------------------------ 134cdf0e10cSrcweir namespace 135cdf0e10cSrcweir { 136cdf0e10cSrcweir //.............................................................. 137cdf0e10cSrcweir static void implAdjustTriStateFlag( const Reference< XPropertySet >& _rxProps, const ::rtl::OUString& _rPropertyName, 138cdf0e10cSrcweir WinBits& _rAllBits, WinBits _nPositiveFlag, WinBits nNegativeFlag ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir sal_Bool bFlagValue = sal_False; 141cdf0e10cSrcweir if ( _rxProps->getPropertyValue( _rPropertyName ) >>= bFlagValue ) 142cdf0e10cSrcweir _rAllBits |= ( bFlagValue ? _nPositiveFlag : nNegativeFlag ); 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir //.............................................................. 146cdf0e10cSrcweir static void implAdjustTwoStateFlag( const Any& _rValue, WinBits& _rAllBits, WinBits _nFlag, bool _bInvert = false ) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir sal_Bool bFlagValue = sal_False; 149cdf0e10cSrcweir if ( _rValue >>= bFlagValue ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir if ( _bInvert ) 152cdf0e10cSrcweir bFlagValue = !bFlagValue; 153cdf0e10cSrcweir if ( bFlagValue ) 154cdf0e10cSrcweir _rAllBits |= _nFlag; 155cdf0e10cSrcweir else 156cdf0e10cSrcweir _rAllBits &= ~_nFlag; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir //.............................................................. 161cdf0e10cSrcweir static void implAdjustTwoStateFlag( const Reference< XPropertySet >& _rxProps, const ::rtl::OUString& _rPropertyName, 162cdf0e10cSrcweir WinBits& _rAllBits, WinBits _nFlag, bool _bInvert = false ) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir implAdjustTwoStateFlag( _rxProps->getPropertyValue( _rPropertyName ), _rAllBits, _nFlag, _bInvert ); 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir //.............................................................. 168cdf0e10cSrcweir static void adjustTwoStateWinBit( Window* _pWindow, const Any& _rValue, WinBits _nFlag, bool _bInvert = false ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir WinBits nBits = _pWindow->GetStyle(); 171cdf0e10cSrcweir implAdjustTwoStateFlag( _rValue, nBits, _nFlag, _bInvert ); 172cdf0e10cSrcweir _pWindow->SetStyle( nBits ); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir //.............................................................. 176cdf0e10cSrcweir static WinBits getWinBits( const Reference< XControlModel >& _rxModel, WinBits nBaseBits = 0 ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir WinBits nBits = nBaseBits; 179cdf0e10cSrcweir try 180cdf0e10cSrcweir { 181cdf0e10cSrcweir Reference< XPropertySet > xProps( _rxModel, UNO_QUERY ); 182cdf0e10cSrcweir if ( xProps.is() ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir sal_Int16 nBorder = 0; 185cdf0e10cSrcweir xProps->getPropertyValue( PROPERTY_BORDER ) >>= nBorder; 186cdf0e10cSrcweir if ( nBorder ) 187cdf0e10cSrcweir nBits |= WB_BORDER; 188cdf0e10cSrcweir 189cdf0e10cSrcweir implAdjustTriStateFlag( xProps, PROPERTY_TABSTOP, nBits, WB_TABSTOP, WB_NOTABSTOP ); 190cdf0e10cSrcweir implAdjustTwoStateFlag( xProps, PROPERTY_HSCROLL, nBits, WB_HSCROLL ); 191cdf0e10cSrcweir implAdjustTwoStateFlag( xProps, PROPERTY_VSCROLL, nBits, WB_VSCROLL ); 192cdf0e10cSrcweir implAdjustTwoStateFlag( xProps, PROPERTY_HARDLINEBREAKS, nBits, WB_WORDBREAK, true ); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir } 195cdf0e10cSrcweir catch( const Exception& ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir return nBits; 200cdf0e10cSrcweir } 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir //------------------------------------------------------------------ 204cdf0e10cSrcweir void SAL_CALL ORichTextControl::createPeer( const Reference< XToolkit >& _rToolkit, const Reference< XWindowPeer >& _rParentPeer ) throw( RuntimeException ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir sal_Bool bReallyActAsRichText = sal_False; 207cdf0e10cSrcweir try 208cdf0e10cSrcweir { 209cdf0e10cSrcweir Reference< XPropertySet > xModelProps( getModel(), UNO_QUERY_THROW ); 210cdf0e10cSrcweir xModelProps->getPropertyValue( PROPERTY_RICH_TEXT ) >>= bReallyActAsRichText; 211cdf0e10cSrcweir } 212cdf0e10cSrcweir catch( const Exception& ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir if ( !bReallyActAsRichText ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir UnoEditControl::createPeer( _rToolkit, _rParentPeer ); 220cdf0e10cSrcweir OControl::initFormControlPeer( getPeer() ); 221cdf0e10cSrcweir return; 222cdf0e10cSrcweir } 223cdf0e10cSrcweir 224cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 225cdf0e10cSrcweir 226cdf0e10cSrcweir if (!getPeer().is()) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir mbCreatingPeer = sal_True; 229cdf0e10cSrcweir 230cdf0e10cSrcweir // determine the VLC window for the parent 231cdf0e10cSrcweir Window* pParentWin = NULL; 232cdf0e10cSrcweir if ( _rParentPeer.is() ) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir VCLXWindow* pParentXWin = VCLXWindow::GetImplementation( _rParentPeer ); 235cdf0e10cSrcweir if ( pParentXWin ) 236cdf0e10cSrcweir pParentWin = pParentXWin->GetWindow(); 237cdf0e10cSrcweir DBG_ASSERT( pParentWin, "ORichTextControl::createPeer: could not obtain the VCL-level parent window!" ); 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir // create the peer 241cdf0e10cSrcweir Reference< XControlModel > xModel( getModel() ); 242cdf0e10cSrcweir ORichTextPeer* pPeer = ORichTextPeer::Create( xModel, pParentWin, getWinBits( xModel ) ); 243cdf0e10cSrcweir DBG_ASSERT( pPeer, "ORichTextControl::createPeer: invalid peer returned!" ); 244cdf0e10cSrcweir if ( pPeer ) 245cdf0e10cSrcweir { 246cdf0e10cSrcweir // by definition, the returned component is aquired once 247cdf0e10cSrcweir pPeer->release(); 248cdf0e10cSrcweir 249cdf0e10cSrcweir // announce the peer to the base class 250cdf0e10cSrcweir setPeer( pPeer ); 251cdf0e10cSrcweir 252cdf0e10cSrcweir // initialize ourself (and thus the peer) with the model properties 253cdf0e10cSrcweir updateFromModel(); 254cdf0e10cSrcweir 255cdf0e10cSrcweir Reference< XView > xPeerView( getPeer(), UNO_QUERY ); 256cdf0e10cSrcweir if ( xPeerView.is() ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY ); 259cdf0e10cSrcweir xPeerView->setGraphics( mxGraphics ); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir // a lot of initial settings from our component infos 263cdf0e10cSrcweir setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, PosSize::POSSIZE ); 264cdf0e10cSrcweir 265cdf0e10cSrcweir pPeer->setVisible ( maComponentInfos.bVisible && !mbDesignMode ); 266cdf0e10cSrcweir pPeer->setEnable ( maComponentInfos.bEnable ); 267cdf0e10cSrcweir pPeer->setDesignMode( mbDesignMode ); 268cdf0e10cSrcweir 269cdf0e10cSrcweir peerCreated(); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir mbCreatingPeer = sal_False; 273cdf0e10cSrcweir 274cdf0e10cSrcweir OControl::initFormControlPeer( getPeer() ); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir //------------------------------------------------------------------ 279cdf0e10cSrcweir ::rtl::OUString SAL_CALL ORichTextControl::getImplementationName() throw( RuntimeException ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir return getImplementationName_Static(); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 284cdf0e10cSrcweir //------------------------------------------------------------------ 285cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ORichTextControl::getSupportedServiceNames() throw( RuntimeException ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir return getSupportedServiceNames_Static(); 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir //------------------------------------------------------------------ 291cdf0e10cSrcweir ::rtl::OUString SAL_CALL ORichTextControl::getImplementationName_Static() 292cdf0e10cSrcweir { 293cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.form.ORichTextControl" ) ); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir //------------------------------------------------------------------ 297cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ORichTextControl::getSupportedServiceNames_Static() 298cdf0e10cSrcweir { 299cdf0e10cSrcweir Sequence< ::rtl::OUString > aServices( 3 ); 300cdf0e10cSrcweir aServices[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControl" ) ); 301cdf0e10cSrcweir aServices[ 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEdit" ) ); 302cdf0e10cSrcweir aServices[ 2 ] = FRM_SUN_CONTROL_RICHTEXTCONTROL; 303cdf0e10cSrcweir return aServices; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir //------------------------------------------------------------------ 307cdf0e10cSrcweir Reference< XInterface > SAL_CALL ORichTextControl::Create( const Reference< XMultiServiceFactory >& _rxFactory ) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir return *( new ORichTextControl( _rxFactory ) ); 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir //-------------------------------------------------------------------- 313cdf0e10cSrcweir Reference< XDispatch > SAL_CALL ORichTextControl::queryDispatch( const ::com::sun::star::util::URL& _rURL, const ::rtl::OUString& _rTargetFrameName, sal_Int32 _nSearchFlags ) throw (RuntimeException) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir FORWARD_TO_PEER_3_RET( Reference< XDispatch >, XDispatchProvider, queryDispatch, _rURL, _rTargetFrameName, _nSearchFlags ); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir //-------------------------------------------------------------------- 319cdf0e10cSrcweir Sequence< Reference< XDispatch > > SAL_CALL ORichTextControl::queryDispatches( const Sequence< DispatchDescriptor >& _rRequests ) throw (RuntimeException) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir FORWARD_TO_PEER_1_RET( Sequence< Reference< XDispatch > >, XDispatchProvider, queryDispatches, _rRequests ); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir //-------------------------------------------------------------------- 325cdf0e10cSrcweir sal_Bool ORichTextControl::requiresNewPeer( const ::rtl::OUString& _rPropertyName ) const 326cdf0e10cSrcweir { 327cdf0e10cSrcweir return UnoControl::requiresNewPeer( _rPropertyName ) || _rPropertyName.equals( PROPERTY_RICH_TEXT ); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir //================================================================== 331cdf0e10cSrcweir // ORichTextPeer 332cdf0e10cSrcweir //================================================================== 333cdf0e10cSrcweir DBG_NAME( ORichTextPeer ) 334cdf0e10cSrcweir //------------------------------------------------------------------ 335cdf0e10cSrcweir ORichTextPeer* ORichTextPeer::Create( const Reference< XControlModel >& _rxModel, Window* _pParentWindow, WinBits _nStyle ) 336cdf0e10cSrcweir { 337cdf0e10cSrcweir DBG_TESTSOLARMUTEX(); 338cdf0e10cSrcweir 339cdf0e10cSrcweir // the EditEngine of the model 340cdf0e10cSrcweir RichTextEngine* pEngine = ORichTextModel::getEditEngine( _rxModel ); 341cdf0e10cSrcweir OSL_ENSURE( pEngine, "ORichTextPeer::Create: could not obtaine the edit engine from the model!" ); 342cdf0e10cSrcweir if ( !pEngine ) 343cdf0e10cSrcweir return NULL; 344cdf0e10cSrcweir 345cdf0e10cSrcweir // the peer itself 346cdf0e10cSrcweir ORichTextPeer* pPeer = new ORichTextPeer; 347cdf0e10cSrcweir pPeer->acquire(); // by definition, the returned object is aquired once 348cdf0e10cSrcweir 349cdf0e10cSrcweir // the VCL control for the peer 350cdf0e10cSrcweir RichTextControl* pRichTextControl = new RichTextControl( pEngine, _pParentWindow, _nStyle, NULL, pPeer ); 351cdf0e10cSrcweir 352cdf0e10cSrcweir // some knittings 353cdf0e10cSrcweir pRichTextControl->SetComponentInterface( pPeer ); 354cdf0e10cSrcweir 355cdf0e10cSrcweir // outta here 356cdf0e10cSrcweir return pPeer; 357cdf0e10cSrcweir } 358cdf0e10cSrcweir 359cdf0e10cSrcweir //------------------------------------------------------------------ 360cdf0e10cSrcweir ORichTextPeer::ORichTextPeer() 361cdf0e10cSrcweir { 362cdf0e10cSrcweir DBG_CTOR( ORichTextPeer, NULL ); 363cdf0e10cSrcweir } 364cdf0e10cSrcweir 365cdf0e10cSrcweir //------------------------------------------------------------------ 366cdf0e10cSrcweir ORichTextPeer::~ORichTextPeer() 367cdf0e10cSrcweir { 368cdf0e10cSrcweir DBG_DTOR( ORichTextPeer, NULL ); 369cdf0e10cSrcweir } 370cdf0e10cSrcweir 371cdf0e10cSrcweir //------------------------------------------------------------------ 372cdf0e10cSrcweir void ORichTextPeer::dispose( ) throw(RuntimeException) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir { 375cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 376cdf0e10cSrcweir RichTextControl* pRichTextControl = static_cast< RichTextControl* >( GetWindow() ); 377cdf0e10cSrcweir 378cdf0e10cSrcweir if ( pRichTextControl ) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir for ( AttributeDispatchers::iterator aDisposeLoop = m_aDispatchers.begin(); 381cdf0e10cSrcweir aDisposeLoop != m_aDispatchers.end(); 382cdf0e10cSrcweir ++aDisposeLoop 383cdf0e10cSrcweir ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir pRichTextControl->disableAttributeNotification( aDisposeLoop->first ); 386cdf0e10cSrcweir aDisposeLoop->second->dispose(); 387cdf0e10cSrcweir } 388cdf0e10cSrcweir } 389cdf0e10cSrcweir 390cdf0e10cSrcweir AttributeDispatchers aEmpty; 391cdf0e10cSrcweir m_aDispatchers.swap( aEmpty ); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir VCLXWindow::dispose(); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir 397cdf0e10cSrcweir //-------------------------------------------------------------------- 398cdf0e10cSrcweir void SAL_CALL ORichTextPeer::draw( sal_Int32 _nX, sal_Int32 _nY ) throw(::com::sun::star::uno::RuntimeException) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 401cdf0e10cSrcweir 402cdf0e10cSrcweir RichTextControl* pControl = static_cast< RichTextControl* >( GetWindow() ); 403cdf0e10cSrcweir if ( !pControl ) 404cdf0e10cSrcweir return; 405cdf0e10cSrcweir 406cdf0e10cSrcweir OutputDevice* pTargetDevice = VCLUnoHelper::GetOutputDevice( getGraphics() ); 407cdf0e10cSrcweir OSL_ENSURE( pTargetDevice != NULL, "ORichTextPeer::draw: no graphics -> no drawing!" ); 408cdf0e10cSrcweir if ( !pTargetDevice ) 409cdf0e10cSrcweir return; 410cdf0e10cSrcweir 411cdf0e10cSrcweir ::Size aSize = pControl->GetSizePixel(); 412cdf0e10cSrcweir const MapUnit eTargetUnit = pTargetDevice->GetMapMode().GetMapUnit(); 413cdf0e10cSrcweir if ( eTargetUnit != MAP_PIXEL ) 414cdf0e10cSrcweir aSize = pControl->PixelToLogic( aSize, eTargetUnit ); 415cdf0e10cSrcweir 416cdf0e10cSrcweir ::Point aPos( _nX, _nY ); 417cdf0e10cSrcweir // the XView::draw API talks about pixels, always ... 418cdf0e10cSrcweir if ( eTargetUnit != MAP_PIXEL ) 419cdf0e10cSrcweir aPos = pTargetDevice->PixelToLogic( aPos ); 420cdf0e10cSrcweir 421cdf0e10cSrcweir pControl->Draw( pTargetDevice, aPos, aSize, WINDOW_DRAW_NOCONTROLS ); 422cdf0e10cSrcweir } 423cdf0e10cSrcweir 424cdf0e10cSrcweir //-------------------------------------------------------------------- 425cdf0e10cSrcweir void SAL_CALL ORichTextPeer::setProperty( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (RuntimeException) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir if ( !GetWindow() ) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir VCLXWindow::setProperty( _rPropertyName, _rValue ); 430cdf0e10cSrcweir return; 431cdf0e10cSrcweir } 432cdf0e10cSrcweir 433cdf0e10cSrcweir if ( _rPropertyName.equals( PROPERTY_BACKGROUNDCOLOR ) ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir RichTextControl* pControl = static_cast< RichTextControl* >( GetWindow() ); 436cdf0e10cSrcweir if ( !_rValue.hasValue() ) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir pControl->SetBackgroundColor( ); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir else 441cdf0e10cSrcweir { 442cdf0e10cSrcweir sal_Int32 nColor = COL_TRANSPARENT; 443cdf0e10cSrcweir _rValue >>= nColor; 444cdf0e10cSrcweir pControl->SetBackgroundColor( Color( nColor ) ); 445cdf0e10cSrcweir } 446cdf0e10cSrcweir } 447cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_HSCROLL ) ) 448cdf0e10cSrcweir { 449cdf0e10cSrcweir adjustTwoStateWinBit( GetWindow(), _rValue, WB_HSCROLL ); 450cdf0e10cSrcweir } 451cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_VSCROLL ) ) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir adjustTwoStateWinBit( GetWindow(), _rValue, WB_VSCROLL ); 454cdf0e10cSrcweir } 455cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_HARDLINEBREAKS ) ) 456cdf0e10cSrcweir { 457cdf0e10cSrcweir adjustTwoStateWinBit( GetWindow(), _rValue, WB_WORDBREAK, true ); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_READONLY ) ) 460cdf0e10cSrcweir { 461cdf0e10cSrcweir RichTextControl* pControl = static_cast< RichTextControl* >( GetWindow() ); 462cdf0e10cSrcweir sal_Bool bReadOnly( pControl->IsReadOnly() ); 463cdf0e10cSrcweir OSL_VERIFY( _rValue >>= bReadOnly ); 464cdf0e10cSrcweir pControl->SetReadOnly( bReadOnly ); 465cdf0e10cSrcweir 466cdf0e10cSrcweir // update the dispatchers 467cdf0e10cSrcweir for ( AttributeDispatchers::iterator aDispatcherLoop = m_aDispatchers.begin(); 468cdf0e10cSrcweir aDispatcherLoop != m_aDispatchers.end(); 469cdf0e10cSrcweir ++aDispatcherLoop 470cdf0e10cSrcweir ) 471cdf0e10cSrcweir { 472cdf0e10cSrcweir aDispatcherLoop->second->invalidate(); 473cdf0e10cSrcweir } 474cdf0e10cSrcweir } 475cdf0e10cSrcweir else if ( _rPropertyName.equals( PROPERTY_HIDEINACTIVESELECTION ) ) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir RichTextControl* pRichTextControl = static_cast< RichTextControl* >( GetWindow() ); 478cdf0e10cSrcweir sal_Bool bHide = pRichTextControl->GetHideInactiveSelection(); 479cdf0e10cSrcweir OSL_VERIFY( _rValue >>= bHide ); 480cdf0e10cSrcweir pRichTextControl->SetHideInactiveSelection( bHide ); 481cdf0e10cSrcweir } 482cdf0e10cSrcweir else 483cdf0e10cSrcweir VCLXWindow::setProperty( _rPropertyName, _rValue ); 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir //------------------------------------------------------------------ 487cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( ORichTextPeer, VCLXWindow, ORichTextPeer_Base ) 488cdf0e10cSrcweir 489cdf0e10cSrcweir //------------------------------------------------------------------ 490cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( ORichTextPeer, VCLXWindow, ORichTextPeer_Base ) 491cdf0e10cSrcweir 492cdf0e10cSrcweir //-------------------------------------------------------------------- 493cdf0e10cSrcweir namespace 494cdf0e10cSrcweir { 495cdf0e10cSrcweir static SfxSlotId lcl_translateConflictingSlot( SfxSlotId _nIDFromPool ) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir // HACK HACK HACK 498cdf0e10cSrcweir // unfortunately, some of our applications have some conflicting slots, 499cdf0e10cSrcweir // i.e. slots which have the same UNO name as an existing other (common) 500cdf0e10cSrcweir // slot. 501cdf0e10cSrcweir // For instance, both the slots SID_SET_SUPER_SCRIPT (from SVX) and FN_SET_SUPER_SCRIPT 502cdf0e10cSrcweir // (from SW) have the UNO name "SuperScript". 503cdf0e10cSrcweir // Now, if the controls lives in a text document, and asks the SfxSlotPool for 504cdf0e10cSrcweir // the id belonging to "SuperScript", it gets the FN_SET_SUPER_SCRIPT - which 505cdf0e10cSrcweir // is completely unknown to the EditEngine. 506cdf0e10cSrcweir // So, we need to translate such conflicting ids. 507cdf0e10cSrcweir // 508cdf0e10cSrcweir // Note that the real solution would be to fix the applications to 509cdf0e10cSrcweir // *not* define conflicting slots. Alternatively, if SFX would provide a slot pool 510cdf0e10cSrcweir // which is *static* (i.e. independent on the active application), then we 511cdf0e10cSrcweir // would also never encounter such a conflict. 512cdf0e10cSrcweir SfxSlotId nReturn( _nIDFromPool ); 513cdf0e10cSrcweir switch ( _nIDFromPool ) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir case 20411: /* FM_SET_SUPER_SCRIPT, originating in SW */ 516cdf0e10cSrcweir nReturn = SID_SET_SUPER_SCRIPT; 517cdf0e10cSrcweir break; 518cdf0e10cSrcweir case 20412: /* FN_SET_SUB_SCRIPT, originating in SW */ 519cdf0e10cSrcweir nReturn = SID_SET_SUB_SCRIPT; 520cdf0e10cSrcweir break; 521cdf0e10cSrcweir } 522cdf0e10cSrcweir return nReturn; 523cdf0e10cSrcweir } 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir //-------------------------------------------------------------------- 527cdf0e10cSrcweir ORichTextPeer::SingleAttributeDispatcher ORichTextPeer::implCreateDispatcher( SfxSlotId _nSlotId, const ::com::sun::star::util::URL& _rURL ) 528cdf0e10cSrcweir { 529cdf0e10cSrcweir RichTextControl* pRichTextControl = static_cast< RichTextControl* >( GetWindow() ); 530cdf0e10cSrcweir OSL_PRECOND( pRichTextControl, "ORichTextPeer::implCreateDispatcher: invalid window!" ); 531cdf0e10cSrcweir if ( !pRichTextControl ) 532cdf0e10cSrcweir return SingleAttributeDispatcher( NULL ); 533cdf0e10cSrcweir 534cdf0e10cSrcweir ORichTextFeatureDispatcher* pDispatcher = NULL; 535cdf0e10cSrcweir OAttributeDispatcher* pAttributeDispatcher = NULL; 536cdf0e10cSrcweir switch ( _nSlotId ) 537cdf0e10cSrcweir { 538cdf0e10cSrcweir case SID_CUT: 539cdf0e10cSrcweir pDispatcher = new OClipboardDispatcher( pRichTextControl->getView(), OClipboardDispatcher::eCut ); 540cdf0e10cSrcweir break; 541cdf0e10cSrcweir 542cdf0e10cSrcweir case SID_COPY: 543cdf0e10cSrcweir pDispatcher = new OClipboardDispatcher( pRichTextControl->getView(), OClipboardDispatcher::eCopy ); 544cdf0e10cSrcweir break; 545cdf0e10cSrcweir 546cdf0e10cSrcweir case SID_PASTE: 547cdf0e10cSrcweir pDispatcher = new OPasteClipboardDispatcher( pRichTextControl->getView() ); 548cdf0e10cSrcweir break; 549cdf0e10cSrcweir 550cdf0e10cSrcweir case SID_SELECTALL: 551cdf0e10cSrcweir pDispatcher = new OSelectAllDispatcher( pRichTextControl->getView(), _rURL ); 552cdf0e10cSrcweir break; 553cdf0e10cSrcweir 554cdf0e10cSrcweir case SID_ATTR_PARA_LEFT_TO_RIGHT: 555cdf0e10cSrcweir case SID_ATTR_PARA_RIGHT_TO_LEFT: 556cdf0e10cSrcweir pAttributeDispatcher = new OParagraphDirectionDispatcher( pRichTextControl->getView(), _nSlotId, _rURL, pRichTextControl ); 557cdf0e10cSrcweir break; 558cdf0e10cSrcweir 559cdf0e10cSrcweir case SID_TEXTDIRECTION_TOP_TO_BOTTOM: 560cdf0e10cSrcweir case SID_TEXTDIRECTION_LEFT_TO_RIGHT: 561cdf0e10cSrcweir pDispatcher = new OTextDirectionDispatcher( pRichTextControl->getView(), _rURL ); 562cdf0e10cSrcweir break; 563cdf0e10cSrcweir 564cdf0e10cSrcweir case SID_ATTR_PARA_HANGPUNCTUATION: 565cdf0e10cSrcweir case SID_ATTR_PARA_FORBIDDEN_RULES: 566cdf0e10cSrcweir case SID_ATTR_PARA_SCRIPTSPACE: 567cdf0e10cSrcweir pAttributeDispatcher = new OAsianFontLayoutDispatcher( pRichTextControl->getView(), _nSlotId, _rURL, pRichTextControl ); 568cdf0e10cSrcweir break; 569cdf0e10cSrcweir 570cdf0e10cSrcweir default: 571cdf0e10cSrcweir { 572cdf0e10cSrcweir // is it a supported slot? 573cdf0e10cSrcweir bool bSupportedSlot = false; 574cdf0e10cSrcweir if ( !bSupportedSlot ) 575cdf0e10cSrcweir { 576cdf0e10cSrcweir const SfxItemPool& rPool = *pRichTextControl->getView().GetEmptyItemSet().GetPool(); 577cdf0e10cSrcweir bSupportedSlot = rPool.IsInRange( rPool.GetWhich( _nSlotId ) ); 578cdf0e10cSrcweir } 579cdf0e10cSrcweir if ( !bSupportedSlot ) 580cdf0e10cSrcweir bSupportedSlot = RichTextControl::isMappableSlot( _nSlotId ); 581cdf0e10cSrcweir 582cdf0e10cSrcweir if ( bSupportedSlot ) 583cdf0e10cSrcweir { // it's really a slot which is supported by the EditEngine 584cdf0e10cSrcweir 585cdf0e10cSrcweir bool bNeedParametrizedDispatcher = true; 586cdf0e10cSrcweir if ( ( _nSlotId == SID_ATTR_CHAR_POSTURE ) 587cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_CJK_POSTURE ) 588cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_CTL_POSTURE ) 589cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_LATIN_POSTURE ) 590cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_WEIGHT ) 591cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_CJK_WEIGHT ) 592cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_CTL_WEIGHT ) 593cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_LATIN_WEIGHT ) 594cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_LANGUAGE ) 595cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_CJK_LANGUAGE ) 596cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_CTL_LANGUAGE ) 597cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_LATIN_LANGUAGE ) 598cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_CONTOUR ) 599cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_SHADOWED ) 600cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_WORDLINEMODE ) 601cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_COLOR ) 602cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_RELIEF ) 603cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_KERNING ) 604cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_AUTOKERN ) 605cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_CHAR_SCALEWIDTH ) 606cdf0e10cSrcweir ) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir bNeedParametrizedDispatcher = true; 609cdf0e10cSrcweir } 610cdf0e10cSrcweir else if ( ( _nSlotId == SID_ATTR_PARA_HANGPUNCTUATION ) 611cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_PARA_FORBIDDEN_RULES ) 612cdf0e10cSrcweir || ( _nSlotId == SID_ATTR_PARA_SCRIPTSPACE ) 613cdf0e10cSrcweir ) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir bNeedParametrizedDispatcher = false; 616cdf0e10cSrcweir } 617cdf0e10cSrcweir else 618cdf0e10cSrcweir { 619cdf0e10cSrcweir SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( NULL ); 620cdf0e10cSrcweir const SfxSlot* pSlot = rSlotPool.GetSlot( _nSlotId ); 621cdf0e10cSrcweir const SfxType* pType = pSlot ? pSlot->GetType() : NULL; 622cdf0e10cSrcweir if ( pType ) 623cdf0e10cSrcweir { 624cdf0e10cSrcweir bNeedParametrizedDispatcher = ( pType->nAttribs > 0 ); 625cdf0e10cSrcweir } 626cdf0e10cSrcweir } 627cdf0e10cSrcweir 628cdf0e10cSrcweir if ( bNeedParametrizedDispatcher ) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 631cdf0e10cSrcweir ::rtl::OString sTrace( "ORichTextPeer::implCreateDispatcher: creating *parametrized* dispatcher for " ); 632cdf0e10cSrcweir sTrace += ::rtl::OString( _rURL.Complete.getStr(), _rURL.Complete.getLength(), RTL_TEXTENCODING_ASCII_US ); 633cdf0e10cSrcweir DBG_TRACE( sTrace.getStr() ); 634cdf0e10cSrcweir #endif 635cdf0e10cSrcweir pAttributeDispatcher = new OParametrizedAttributeDispatcher( pRichTextControl->getView(), _nSlotId, _rURL, pRichTextControl ); 636cdf0e10cSrcweir } 637cdf0e10cSrcweir else 638cdf0e10cSrcweir { 639cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 640cdf0e10cSrcweir ::rtl::OString sTrace( "ORichTextPeer::implCreateDispatcher: creating *normal* dispatcher for " ); 641cdf0e10cSrcweir sTrace += ::rtl::OString( _rURL.Complete.getStr(), _rURL.Complete.getLength(), RTL_TEXTENCODING_ASCII_US ); 642cdf0e10cSrcweir DBG_TRACE( sTrace.getStr() ); 643cdf0e10cSrcweir #endif 644cdf0e10cSrcweir pAttributeDispatcher = new OAttributeDispatcher( pRichTextControl->getView(), _nSlotId, _rURL, pRichTextControl ); 645cdf0e10cSrcweir } 646cdf0e10cSrcweir } 647cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 648cdf0e10cSrcweir else 649cdf0e10cSrcweir { 650cdf0e10cSrcweir ::rtl::OString sTrace( "ORichTextPeer::implCreateDispatcher: not creating dispatcher (unsupported slot) for " ); 651cdf0e10cSrcweir sTrace += ::rtl::OString( _rURL.Complete.getStr(), _rURL.Complete.getLength(), RTL_TEXTENCODING_ASCII_US ); 652cdf0e10cSrcweir DBG_TRACE( sTrace.getStr() ); 653cdf0e10cSrcweir } 654cdf0e10cSrcweir #endif 655cdf0e10cSrcweir } 656cdf0e10cSrcweir break; 657cdf0e10cSrcweir } 658cdf0e10cSrcweir 659cdf0e10cSrcweir SingleAttributeDispatcher xDispatcher( pDispatcher ); 660cdf0e10cSrcweir if ( pAttributeDispatcher ) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir xDispatcher = SingleAttributeDispatcher( pAttributeDispatcher ); 663cdf0e10cSrcweir pRichTextControl->enableAttributeNotification( _nSlotId, pAttributeDispatcher ); 664cdf0e10cSrcweir } 665cdf0e10cSrcweir 666cdf0e10cSrcweir return xDispatcher; 667cdf0e10cSrcweir } 668cdf0e10cSrcweir 669cdf0e10cSrcweir //-------------------------------------------------------------------- 670cdf0e10cSrcweir namespace 671cdf0e10cSrcweir { 672cdf0e10cSrcweir SfxSlotId lcl_getSlotFromUnoName( SfxSlotPool& _rSlotPool, const ::rtl::OUString& _rUnoSlotName ) 673cdf0e10cSrcweir { 674cdf0e10cSrcweir const SfxSlot* pSlot = _rSlotPool.GetUnoSlot( _rUnoSlotName ); 675cdf0e10cSrcweir if ( pSlot ) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir // okay, there's a slot with the given UNO name 678cdf0e10cSrcweir return lcl_translateConflictingSlot( pSlot->GetSlotId() ); 679cdf0e10cSrcweir } 680cdf0e10cSrcweir 681cdf0e10cSrcweir // some hard-coded slots, which do not have a UNO name at SFX level, but which 682cdf0e10cSrcweir // we nevertheless need to transport via UNO mechanisms, so we need a name 683cdf0e10cSrcweir if ( _rUnoSlotName.equalsAscii( "AllowHangingPunctuation" ) ) 684cdf0e10cSrcweir return SID_ATTR_PARA_HANGPUNCTUATION; 685cdf0e10cSrcweir if ( _rUnoSlotName.equalsAscii( "ApplyForbiddenCharacterRules" ) ) 686cdf0e10cSrcweir return SID_ATTR_PARA_FORBIDDEN_RULES; 687cdf0e10cSrcweir if ( _rUnoSlotName.equalsAscii( "UseScriptSpacing" ) ) 688cdf0e10cSrcweir return SID_ATTR_PARA_SCRIPTSPACE; 689cdf0e10cSrcweir 690cdf0e10cSrcweir OSL_ENSURE( pSlot, "lcl_getSlotFromUnoName: unknown UNO slot name!" ); 691cdf0e10cSrcweir return 0; 692cdf0e10cSrcweir } 693cdf0e10cSrcweir } 694cdf0e10cSrcweir 695cdf0e10cSrcweir //-------------------------------------------------------------------- 696cdf0e10cSrcweir Reference< XDispatch > SAL_CALL ORichTextPeer::queryDispatch( const ::com::sun::star::util::URL& _rURL, const ::rtl::OUString& /*_rTargetFrameName*/, sal_Int32 /*_nSearchFlags*/ ) throw (RuntimeException) 697cdf0e10cSrcweir { 698cdf0e10cSrcweir Reference< XDispatch > xReturn; 699cdf0e10cSrcweir if ( !GetWindow() ) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir OSL_ENSURE( sal_False, "ORichTextPeer::queryDispatch: already disposed?" ); 702cdf0e10cSrcweir return xReturn; 703cdf0e10cSrcweir } 704cdf0e10cSrcweir 705cdf0e10cSrcweir // is it an UNO slot? 706cdf0e10cSrcweir ::rtl::OUString sUnoProtocolPrefix( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) ); 707cdf0e10cSrcweir if ( 0 == _rURL.Complete.compareTo( sUnoProtocolPrefix, sUnoProtocolPrefix.getLength() ) ) 708cdf0e10cSrcweir { 709cdf0e10cSrcweir ::rtl::OUString sUnoSlotName = _rURL.Complete.copy( sUnoProtocolPrefix.getLength() ); 710cdf0e10cSrcweir SfxSlotId nSlotId = lcl_getSlotFromUnoName( SfxSlotPool::GetSlotPool( NULL ), sUnoSlotName ); 711cdf0e10cSrcweir if ( nSlotId > 0 ) 712cdf0e10cSrcweir { 713cdf0e10cSrcweir // do we already have a dispatcher for this? 714cdf0e10cSrcweir AttributeDispatchers::const_iterator aDispatcherPos = m_aDispatchers.find( nSlotId ); 715cdf0e10cSrcweir if ( aDispatcherPos == m_aDispatchers.end() ) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir SingleAttributeDispatcher pDispatcher = implCreateDispatcher( nSlotId, _rURL ); 718cdf0e10cSrcweir if ( pDispatcher.is() ) 719cdf0e10cSrcweir { 720cdf0e10cSrcweir aDispatcherPos = m_aDispatchers.insert( AttributeDispatchers::value_type( nSlotId, pDispatcher ) ).first; 721cdf0e10cSrcweir } 722cdf0e10cSrcweir } 723cdf0e10cSrcweir 724cdf0e10cSrcweir if ( aDispatcherPos != m_aDispatchers.end() ) 725cdf0e10cSrcweir xReturn = aDispatcherPos->second.getRef(); 726cdf0e10cSrcweir } 727cdf0e10cSrcweir } 728cdf0e10cSrcweir 729cdf0e10cSrcweir return xReturn; 730cdf0e10cSrcweir } 731cdf0e10cSrcweir 732cdf0e10cSrcweir //-------------------------------------------------------------------- 733cdf0e10cSrcweir Sequence< Reference< XDispatch > > SAL_CALL ORichTextPeer::queryDispatches( const Sequence< DispatchDescriptor >& _rRequests ) throw (RuntimeException) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir Sequence< Reference< XDispatch > > aReturn( _rRequests.getLength() ); 736cdf0e10cSrcweir Reference< XDispatch >* pReturn = aReturn.getArray(); 737cdf0e10cSrcweir 738cdf0e10cSrcweir const DispatchDescriptor* pRequest = _rRequests.getConstArray(); 739cdf0e10cSrcweir const DispatchDescriptor* pRequestEnd = pRequest + _rRequests.getLength(); 740cdf0e10cSrcweir for ( ; pRequest != pRequestEnd; ++pRequest, ++pReturn ) 741cdf0e10cSrcweir { 742cdf0e10cSrcweir *pReturn = queryDispatch( pRequest->FeatureURL, pRequest->FrameName, pRequest->SearchFlags ); 743cdf0e10cSrcweir } 744cdf0e10cSrcweir return aReturn; 745cdf0e10cSrcweir } 746cdf0e10cSrcweir 747cdf0e10cSrcweir //-------------------------------------------------------------------- 748cdf0e10cSrcweir void ORichTextPeer::onSelectionChanged( const ESelection& /*_rSelection*/ ) 749cdf0e10cSrcweir { 750cdf0e10cSrcweir AttributeDispatchers::iterator aDispatcherPos = m_aDispatchers.find( SID_COPY ); 751cdf0e10cSrcweir if ( aDispatcherPos != m_aDispatchers.end() ) 752cdf0e10cSrcweir aDispatcherPos->second.get()->invalidate(); 753cdf0e10cSrcweir 754cdf0e10cSrcweir aDispatcherPos = m_aDispatchers.find( SID_CUT ); 755cdf0e10cSrcweir if ( aDispatcherPos != m_aDispatchers.end() ) 756cdf0e10cSrcweir aDispatcherPos->second.get()->invalidate(); 757cdf0e10cSrcweir } 758cdf0e10cSrcweir 759cdf0e10cSrcweir //........................................................................ 760cdf0e10cSrcweir } // namespace frm 761cdf0e10cSrcweir //........................................................................ 762cdf0e10cSrcweir 763