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