1*cdf0e10cSrcweir /************************************************************************* * 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2008 by Sun Microsystems, Inc. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * $RCSfile: $ 10*cdf0e10cSrcweir * $Revision: $ 11*cdf0e10cSrcweir * 12*cdf0e10cSrcweir * This file is part of OpenOffice.org. 13*cdf0e10cSrcweir * 14*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 15*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 16*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 17*cdf0e10cSrcweir * 18*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 19*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 20*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 22*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 23*cdf0e10cSrcweir * 24*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 25*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 26*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 27*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 28*cdf0e10cSrcweir * 29*cdf0e10cSrcweir ************************************************************************/ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "precompiled_sw.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <SidebarTxtControl.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <SidebarTxtControlAcc.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <SidebarWin.hxx> 39*cdf0e10cSrcweir #include <PostItMgr.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir #include <cmdid.h> 42*cdf0e10cSrcweir #include <docvw.hrc> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #include <unotools/securityoptions.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 47*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 48*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 49*cdf0e10cSrcweir #include <sfx2/mnumgr.hxx> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #include <vcl/svapp.hxx> 52*cdf0e10cSrcweir #include <vcl/help.hxx> 53*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 54*cdf0e10cSrcweir #include <vcl/gradient.hxx> 55*cdf0e10cSrcweir #include <vcl/scrbar.hxx> 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir #include <editeng/outliner.hxx> 58*cdf0e10cSrcweir #include <editeng/editeng.hxx> 59*cdf0e10cSrcweir #include <editeng/editview.hxx> 60*cdf0e10cSrcweir #include <editeng/flditem.hxx> 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #include <uitool.hxx> 63*cdf0e10cSrcweir #include <view.hxx> 64*cdf0e10cSrcweir #include <wrtsh.hxx> 65*cdf0e10cSrcweir #include <shellres.hxx> 66*cdf0e10cSrcweir #include <SwRewriter.hxx> 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir namespace css = ::com::sun::star; 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir namespace sw { namespace sidebarwindows { 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir SidebarTxtControl::SidebarTxtControl( SwSidebarWin& rSidebarWin, 73*cdf0e10cSrcweir WinBits nBits, 74*cdf0e10cSrcweir SwView& rDocView, 75*cdf0e10cSrcweir SwPostItMgr& rPostItMgr ) 76*cdf0e10cSrcweir : Control( &rSidebarWin, nBits ) 77*cdf0e10cSrcweir , mrSidebarWin( rSidebarWin ) 78*cdf0e10cSrcweir , mrDocView( rDocView ) 79*cdf0e10cSrcweir , mrPostItMgr( rPostItMgr ) 80*cdf0e10cSrcweir , mbMouseOver( false ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir AddEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) ); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir SidebarTxtControl::~SidebarTxtControl() 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir RemoveEventListener( LINK( &mrSidebarWin, SwSidebarWin, WindowEventListener ) ); 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir OutlinerView* SidebarTxtControl::GetTextView() const 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir return mrSidebarWin.GetOutlinerView(); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir void SidebarTxtControl::GetFocus() 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir Window::GetFocus(); 98*cdf0e10cSrcweir if ( !mrSidebarWin.IsMouseOver() ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir Invalidate(); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir void SidebarTxtControl::LoseFocus() 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir // write the visible text back into the SwField 107*cdf0e10cSrcweir mrSidebarWin.UpdateData(); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir Window::LoseFocus(); 110*cdf0e10cSrcweir if ( !mrSidebarWin.IsMouseOver() ) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir Invalidate(); 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir void SidebarTxtControl::RequestHelp(const HelpEvent &rEvt) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir sal_uInt16 nResId = 0; 119*cdf0e10cSrcweir switch( mrSidebarWin.GetLayoutStatus() ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir case SwPostItHelper::INSERTED: nResId = STR_REDLINE_INSERT; break; 122*cdf0e10cSrcweir case SwPostItHelper::DELETED: nResId = STR_REDLINE_DELETE; break; 123*cdf0e10cSrcweir default: nResId = 0; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE ); 127*cdf0e10cSrcweir if ( nResId && 128*cdf0e10cSrcweir mrDocView.GetWrtShell().GetContentAtPos( mrSidebarWin.GetAnchorPos(), aCntntAtPos ) ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir String sTxt; 131*cdf0e10cSrcweir sTxt = SW_RESSTR( nResId ); 132*cdf0e10cSrcweir sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM(": " )); 133*cdf0e10cSrcweir sTxt += aCntntAtPos.aFnd.pRedl->GetAuthorString(); 134*cdf0e10cSrcweir sTxt.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " )); 135*cdf0e10cSrcweir sTxt += GetAppLangDateTimeString( aCntntAtPos.aFnd.pRedl->GetTimeStamp() ); 136*cdf0e10cSrcweir Help::ShowQuickHelp( this,PixelToLogic(Rectangle(rEvt.GetMousePosPixel(),Size(50,10))),sTxt); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir void SidebarTxtControl::Paint( const Rectangle& rRect) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir if ( !Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir if ( mrSidebarWin.IsMouseOverSidebarWin() || 145*cdf0e10cSrcweir HasFocus() ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ), 148*cdf0e10cSrcweir Gradient( GRADIENT_LINEAR, 149*cdf0e10cSrcweir mrSidebarWin.ColorDark(), 150*cdf0e10cSrcweir mrSidebarWin.ColorDark() ) ); 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir else 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir DrawGradient( Rectangle( Point(0,0), PixelToLogic(GetSizePixel()) ), 155*cdf0e10cSrcweir Gradient( GRADIENT_LINEAR, 156*cdf0e10cSrcweir mrSidebarWin.ColorLight(), 157*cdf0e10cSrcweir mrSidebarWin.ColorDark())); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir if ( GetTextView() ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir GetTextView()->Paint( rRect ); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir if ( mrSidebarWin.GetLayoutStatus()==SwPostItHelper::DELETED ) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir SetLineColor(mrSidebarWin.GetChangeColor()); 169*cdf0e10cSrcweir DrawLine( PixelToLogic( GetPosPixel() ), 170*cdf0e10cSrcweir PixelToLogic( GetPosPixel() + 171*cdf0e10cSrcweir Point( GetSizePixel().Width(), 172*cdf0e10cSrcweir GetSizePixel().Height() ) ) ); 173*cdf0e10cSrcweir DrawLine( PixelToLogic( GetPosPixel() + 174*cdf0e10cSrcweir Point( GetSizePixel().Width(),0) ), 175*cdf0e10cSrcweir PixelToLogic( GetPosPixel() + 176*cdf0e10cSrcweir Point( 0, GetSizePixel().Height() ) ) ); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir void SidebarTxtControl::KeyInput( const KeyEvent& rKeyEvt ) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir const KeyCode& rKeyCode = rKeyEvt.GetKeyCode(); 183*cdf0e10cSrcweir sal_uInt16 nKey = rKeyCode.GetCode(); 184*cdf0e10cSrcweir if ( ( rKeyCode.IsMod1() && rKeyCode.IsMod2() ) && 185*cdf0e10cSrcweir ( (nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN) ) ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir mrSidebarWin.SwitchToPostIt(nKey); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir else if ( nKey == KEY_ESCAPE || 190*cdf0e10cSrcweir ( rKeyCode.IsMod1() && 191*cdf0e10cSrcweir ( nKey == KEY_PAGEUP || 192*cdf0e10cSrcweir nKey == KEY_PAGEDOWN ) ) ) 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir mrSidebarWin.SwitchToFieldPos(); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir else if ( nKey == KEY_INSERT ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir if ( !rKeyCode.IsMod1() && !rKeyCode.IsMod2() ) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir mrSidebarWin.ToggleInsMode(); 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir else 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir //let's make sure we see our note 206*cdf0e10cSrcweir mrPostItMgr.MakeVisible(&mrSidebarWin); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir long aOldHeight = mrSidebarWin.GetPostItTextHeight(); 209*cdf0e10cSrcweir bool bDone = false; 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir /// HACK: need to switch off processing of Undo/Redo in Outliner 212*cdf0e10cSrcweir if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir bool bIsProtected = mrSidebarWin.IsProtected(); 215*cdf0e10cSrcweir if ( !bIsProtected || 216*cdf0e10cSrcweir ( bIsProtected && 217*cdf0e10cSrcweir !mrSidebarWin.GetOutlinerView()->GetOutliner()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir bDone = GetTextView() && GetTextView()->PostKeyEvent( rKeyEvt ); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir else 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute(); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir if (bDone) 227*cdf0e10cSrcweir mrSidebarWin.ResizeIfNeccessary( aOldHeight, mrSidebarWin.GetPostItTextHeight() ); 228*cdf0e10cSrcweir else 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir // write back data first when showing navigator 231*cdf0e10cSrcweir if ( nKey==KEY_F5 ) 232*cdf0e10cSrcweir mrSidebarWin.UpdateData(); 233*cdf0e10cSrcweir if (!mrDocView.KeyInput(rKeyEvt)) 234*cdf0e10cSrcweir Window::KeyInput(rKeyEvt); 235*cdf0e10cSrcweir } 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir mrDocView.GetViewFrame()->GetBindings().InvalidateAll(sal_False); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir void SidebarTxtControl::MouseMove( const MouseEvent& rMEvt ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir if ( GetTextView() ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir OutlinerView* pOutlinerView( GetTextView() ); 246*cdf0e10cSrcweir pOutlinerView->MouseMove( rMEvt ); 247*cdf0e10cSrcweir // mba: why does OutlinerView not handle the modifier setting?! 248*cdf0e10cSrcweir // this forces the postit to handle *all* pointer types 249*cdf0e10cSrcweir SetPointer( pOutlinerView->GetPointer( rMEvt.GetPosPixel() ) ); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir const EditView& aEV = pOutlinerView->GetEditView(); 252*cdf0e10cSrcweir const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer(); 253*cdf0e10cSrcweir if ( pItem ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir const SvxFieldData* pFld = pItem->GetField(); 256*cdf0e10cSrcweir const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld ); 257*cdf0e10cSrcweir if ( pURL ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir String sURL( pURL->GetURL() ); 260*cdf0e10cSrcweir SvtSecurityOptions aSecOpts; 261*cdf0e10cSrcweir if ( aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK) ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir sURL.InsertAscii( ": ", 0 ); 264*cdf0e10cSrcweir sURL.Insert( ViewShell::GetShellRes()->aHyperlinkClick, 0 ); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir Help::ShowQuickHelp( this,PixelToLogic(Rectangle(GetPosPixel(),Size(50,10))),sURL); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir void SidebarTxtControl::MouseButtonDown( const MouseEvent& rMEvt ) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir if ( GetTextView() ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir SvtSecurityOptions aSecOpts; 277*cdf0e10cSrcweir bool bExecuteMod = aSecOpts.IsOptionSet( SvtSecurityOptions::E_CTRLCLICK_HYPERLINK); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir if ( !bExecuteMod || (bExecuteMod && rMEvt.GetModifier() == KEY_MOD1)) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir const EditView& aEV = GetTextView()->GetEditView(); 282*cdf0e10cSrcweir const SvxFieldItem* pItem = aEV.GetFieldUnderMousePointer(); 283*cdf0e10cSrcweir if ( pItem ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir const SvxFieldData* pFld = pItem->GetField(); 286*cdf0e10cSrcweir const SvxURLField* pURL = PTR_CAST( SvxURLField, pFld ); 287*cdf0e10cSrcweir if ( pURL ) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir GetTextView()->MouseButtonDown( rMEvt ); 290*cdf0e10cSrcweir SwWrtShell &rSh = mrDocView.GetWrtShell(); 291*cdf0e10cSrcweir String sURL( pURL->GetURL() ); 292*cdf0e10cSrcweir String sTarget( pURL->GetTargetFrame() ); 293*cdf0e10cSrcweir ::LoadURL( sURL, &rSh, URLLOAD_NOFILTER, &sTarget); 294*cdf0e10cSrcweir return; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir GrabFocus(); 301*cdf0e10cSrcweir if ( GetTextView() ) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir GetTextView()->MouseButtonDown( rMEvt ); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir mrDocView.GetViewFrame()->GetBindings().InvalidateAll(sal_False); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir void SidebarTxtControl::MouseButtonUp( const MouseEvent& rMEvt ) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir if ( GetTextView() ) 311*cdf0e10cSrcweir GetTextView()->MouseButtonUp( rMEvt ); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir IMPL_LINK( SidebarTxtControl, OnlineSpellCallback, SpellCallbackInfo*, pInfo ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir if ( pInfo->nCommand == SPELLCMD_STARTSPELLDLG ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir mrDocView.GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir return 0; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir IMPL_LINK( SidebarTxtControl, Select, Menu*, pSelMenu ) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir mrSidebarWin.ExecuteCommand( pSelMenu->GetCurItemId() ); 326*cdf0e10cSrcweir return 0; 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir void SidebarTxtControl::Command( const CommandEvent& rCEvt ) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir if ( !mrSidebarWin.IsProtected() && 334*cdf0e10cSrcweir GetTextView() && 335*cdf0e10cSrcweir GetTextView()->IsWrongSpelledWordAtPos( rCEvt.GetMousePosPixel(),sal_True )) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir Link aLink = LINK(this, SidebarTxtControl, OnlineSpellCallback); 338*cdf0e10cSrcweir GetTextView()->ExecuteSpellPopup(rCEvt.GetMousePosPixel(),&aLink); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir else 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir SfxPopupMenuManager* pMgr = mrDocView.GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel()); 343*cdf0e10cSrcweir ((PopupMenu*)pMgr->GetSVMenu())->SetSelectHdl( LINK(this, SidebarTxtControl, Select) ); 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir XubString aText = ((PopupMenu*)pMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR ); 347*cdf0e10cSrcweir SwRewriter aRewriter; 348*cdf0e10cSrcweir aRewriter.AddRule(UNDO_ARG1, mrSidebarWin.GetAuthor()); 349*cdf0e10cSrcweir aText = aRewriter.Apply(aText); 350*cdf0e10cSrcweir ((PopupMenu*)pMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir Point aPos; 354*cdf0e10cSrcweir if (rCEvt.IsMouseEvent()) 355*cdf0e10cSrcweir aPos = rCEvt.GetMousePosPixel(); 356*cdf0e10cSrcweir else 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir const Size aSize = GetSizePixel(); 359*cdf0e10cSrcweir aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 ); 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir //!! call different Execute function to get rid of the new thesaurus sub menu 363*cdf0e10cSrcweir //!! pointer created in the call to Popup. 364*cdf0e10cSrcweir //!! Otherwise we would have a memory leak (see also #i107205#) 365*cdf0e10cSrcweir //((PopupMenu*)pMgr->GetSVMenu())->Execute( this, aPos ); 366*cdf0e10cSrcweir pMgr->Execute( aPos, this ); 367*cdf0e10cSrcweir delete pMgr; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir else 371*cdf0e10cSrcweir if (rCEvt.GetCommand() == COMMAND_WHEEL) 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir if (mrSidebarWin.IsScrollbarVisible()) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir const CommandWheelData* pData = rCEvt.GetWheelData(); 376*cdf0e10cSrcweir if (pData->IsShift() || pData->IsMod1() || pData->IsMod2()) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir mrDocView.HandleWheelCommands(rCEvt); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir else 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir HandleScrollCommand( rCEvt, 0 , mrSidebarWin.Scrollbar()); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir else 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir mrDocView.HandleWheelCommands(rCEvt); 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir } 390*cdf0e10cSrcweir else 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir if ( GetTextView() ) 393*cdf0e10cSrcweir GetTextView()->Command( rCEvt ); 394*cdf0e10cSrcweir else 395*cdf0e10cSrcweir Window::Command(rCEvt); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir XubString SidebarTxtControl::GetSurroundingText() const 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir if( GetTextView() ) 402*cdf0e10cSrcweir return GetTextView()->GetSurroundingText(); 403*cdf0e10cSrcweir else 404*cdf0e10cSrcweir return XubString::EmptyString(); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir Selection SidebarTxtControl::GetSurroundingTextSelection() const 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir if( GetTextView() ) 410*cdf0e10cSrcweir return GetTextView()->GetSurroundingTextSelection(); 411*cdf0e10cSrcweir else 412*cdf0e10cSrcweir return Selection( 0, 0 ); 413*cdf0e10cSrcweir } 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir css::uno::Reference< css::accessibility::XAccessible > SidebarTxtControl::CreateAccessible() 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir SidebarTxtControlAccessible* pAcc( new SidebarTxtControlAccessible( *this ) ); 419*cdf0e10cSrcweir css::uno::Reference< css::awt::XWindowPeer > xWinPeer( pAcc ); 420*cdf0e10cSrcweir SetWindowPeer( xWinPeer, pAcc ); 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir css::uno::Reference< css::accessibility::XAccessible > xAcc( xWinPeer, css::uno::UNO_QUERY ); 423*cdf0e10cSrcweir return xAcc; 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir } } // end of namespace sw::sidebarwindows 427*cdf0e10cSrcweir 428