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_sc.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <editeng/outliner.hxx> 32*cdf0e10cSrcweir #include <editeng/outlobj.hxx> 33*cdf0e10cSrcweir #include <svx/svdotext.hxx> 34*cdf0e10cSrcweir #include <svx/svdouno.hxx> 35*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include "fuconstr.hxx" 38*cdf0e10cSrcweir #include "fudraw.hxx" 39*cdf0e10cSrcweir #include "tabvwsh.hxx" 40*cdf0e10cSrcweir #include "futext.hxx" 41*cdf0e10cSrcweir #include "sc.hrc" 42*cdf0e10cSrcweir #include "drawview.hxx" 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir // Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten 45*cdf0e10cSrcweir //! fusel,fuconstr,futext - zusammenfassen! 46*cdf0e10cSrcweir #define SC_MAXDRAGMOVE 3 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir //------------------------------------------------------------------------ 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir /************************************************************************* 51*cdf0e10cSrcweir |* 52*cdf0e10cSrcweir |* Konstruktor 53*cdf0e10cSrcweir |* 54*cdf0e10cSrcweir \************************************************************************/ 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir FuConstruct::FuConstruct(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, 57*cdf0e10cSrcweir SdrModel* pDoc, SfxRequest& rReq) : 58*cdf0e10cSrcweir FuDraw(pViewSh, pWin, pViewP, pDoc, rReq) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir /************************************************************************* 63*cdf0e10cSrcweir |* 64*cdf0e10cSrcweir |* Destruktor 65*cdf0e10cSrcweir |* 66*cdf0e10cSrcweir \************************************************************************/ 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir FuConstruct::~FuConstruct() 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir sal_uInt8 FuConstruct::Command(const CommandEvent& rCEvt) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir // special code for non-VCL OS2/UNX removed 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir return FuDraw::Command( rCEvt ); 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir /************************************************************************* 80*cdf0e10cSrcweir |* 81*cdf0e10cSrcweir |* MouseButtonDown-event 82*cdf0e10cSrcweir |* 83*cdf0e10cSrcweir \************************************************************************/ 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir sal_Bool __EXPORT FuConstruct::MouseButtonDown(const MouseEvent& rMEvt) 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir // #95491# remember button state for creation of own MouseEvents 88*cdf0e10cSrcweir SetMouseButtonCode(rMEvt.GetButtons()); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir sal_Bool bReturn = FuDraw::MouseButtonDown(rMEvt); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir if ( pView->IsAction() ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir if ( rMEvt.IsRight() ) 95*cdf0e10cSrcweir pView->BckAction(); 96*cdf0e10cSrcweir return sal_True; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir aDragTimer.Start(); 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() ); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir if ( rMEvt.IsLeft() ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir pWindow->CaptureMouse(); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir SdrHdl* pHdl = pView->PickHandle(aMDPos); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, 1); 112*cdf0e10cSrcweir bReturn = sal_True; 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir else if ( pView->AreObjectsMarked() ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir pView->UnmarkAll(); 117*cdf0e10cSrcweir bReturn = sal_True; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir bIsInDragMode = sal_False; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir return bReturn; 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir /************************************************************************* 127*cdf0e10cSrcweir |* 128*cdf0e10cSrcweir |* MouseMove-event 129*cdf0e10cSrcweir |* 130*cdf0e10cSrcweir \************************************************************************/ 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir sal_Bool __EXPORT FuConstruct::MouseMove(const MouseEvent& rMEvt) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir FuDraw::MouseMove(rMEvt); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir if (aDragTimer.IsActive() ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir Point aOldPixel = pWindow->LogicToPixel( aMDPos ); 139*cdf0e10cSrcweir Point aNewPixel = rMEvt.GetPosPixel(); 140*cdf0e10cSrcweir if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE || 141*cdf0e10cSrcweir Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE ) 142*cdf0e10cSrcweir aDragTimer.Stop(); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir Point aPix(rMEvt.GetPosPixel()); 146*cdf0e10cSrcweir Point aPnt( pWindow->PixelToLogic(aPix) ); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir if ( pView->IsAction() ) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir ForceScroll(aPix); 151*cdf0e10cSrcweir pView->MovAction(aPnt); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir else 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir SdrHdl* pHdl=pView->PickHandle(aPnt); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir if ( pHdl != NULL ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir pViewShell->SetActivePointer(pHdl->GetPointer()); 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir else if ( pView->IsMarkedHit(aPnt) ) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir pViewShell->SetActivePointer(Pointer(POINTER_MOVE)); 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir else 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir pViewShell->SetActivePointer( aNewPointer ); 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir return sal_True; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir /************************************************************************* 174*cdf0e10cSrcweir |* 175*cdf0e10cSrcweir |* MouseButtonUp-event 176*cdf0e10cSrcweir |* 177*cdf0e10cSrcweir \************************************************************************/ 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir sal_Bool __EXPORT FuConstruct::MouseButtonUp(const MouseEvent& rMEvt) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir // #95491# remember button state for creation of own MouseEvents 182*cdf0e10cSrcweir SetMouseButtonCode(rMEvt.GetButtons()); 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir sal_Bool bReturn = SimpleMouseButtonUp( rMEvt ); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir // Doppelklick auf Textobjekt? (->fusel) 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir sal_uInt16 nClicks = rMEvt.GetClicks(); 189*cdf0e10cSrcweir if ( nClicks == 2 && rMEvt.IsLeft() ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir if ( pView->AreObjectsMarked() ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); 194*cdf0e10cSrcweir if (rMarkList.GetMarkCount() == 1) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir SdrMark* pMark = rMarkList.GetMark(0); 197*cdf0e10cSrcweir SdrObject* pObj = pMark->GetMarkedSdrObj(); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir // #49458# bei Uno-Controls nicht in Textmodus 200*cdf0e10cSrcweir if ( pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); 203*cdf0e10cSrcweir sal_Bool bVertical = ( pOPO && pOPO->IsVertical() ); 204*cdf0e10cSrcweir sal_uInt16 nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT; 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir pViewShell->GetViewData()->GetDispatcher(). 207*cdf0e10cSrcweir Execute(nTextSlotId, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir // jetzt den erzeugten FuText holen und in den EditModus setzen 210*cdf0e10cSrcweir FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr(); 211*cdf0e10cSrcweir if ( pPoor && pPoor->GetSlotID() == nTextSlotId ) // hat keine RTTI 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir FuText* pText = (FuText*)pPoor; 214*cdf0e10cSrcweir Point aMousePixel = rMEvt.GetPosPixel(); 215*cdf0e10cSrcweir pText->SetInEditMode( pObj, &aMousePixel ); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir bReturn = sal_True; 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir FuDraw::MouseButtonUp(rMEvt); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir return bReturn; 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir // SimpleMouseButtonUp - ohne Test auf Doppelklick 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir sal_Bool FuConstruct::SimpleMouseButtonUp(const MouseEvent& rMEvt) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir sal_Bool bReturn = sal_True; 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir if (aDragTimer.IsActive() ) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir aDragTimer.Stop(); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir if ( pView->IsDragObj() ) 242*cdf0e10cSrcweir pView->EndDragObj( rMEvt.IsMod1() ); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir else if ( pView->IsMarkObj() ) 245*cdf0e10cSrcweir pView->EndMarkObj(); 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir else bReturn = sal_False; 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir if ( !pView->IsAction() ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir pWindow->ReleaseMouse(); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 ) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir pView->MarkObj(aPnt, -2, sal_False, rMEvt.IsMod1()); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher(); 258*cdf0e10cSrcweir if ( pView->AreObjectsMarked() ) 259*cdf0e10cSrcweir rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); 260*cdf0e10cSrcweir else 261*cdf0e10cSrcweir rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir return bReturn; 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir /************************************************************************* 269*cdf0e10cSrcweir |* 270*cdf0e10cSrcweir |* Tastaturereignisse bearbeiten 271*cdf0e10cSrcweir |* 272*cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls 273*cdf0e10cSrcweir |* FALSE. 274*cdf0e10cSrcweir |* 275*cdf0e10cSrcweir \************************************************************************/ 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir sal_Bool __EXPORT FuConstruct::KeyInput(const KeyEvent& rKEvt) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir sal_Bool bReturn = sal_False; 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir switch ( rKEvt.GetKeyCode().GetCode() ) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir case KEY_ESCAPE: 284*cdf0e10cSrcweir if ( pView->IsAction() ) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir pView->BrkAction(); 287*cdf0e10cSrcweir pWindow->ReleaseMouse(); 288*cdf0e10cSrcweir bReturn = sal_True; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir else // Zeichenmodus beenden 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir pViewShell->GetViewData()->GetDispatcher(). 293*cdf0e10cSrcweir Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir break; 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir case KEY_DELETE: 298*cdf0e10cSrcweir pView->DeleteMarked(); 299*cdf0e10cSrcweir bReturn = sal_True; 300*cdf0e10cSrcweir break; 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir 303*cdf0e10cSrcweir if ( !bReturn ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir bReturn = FuDraw::KeyInput(rKEvt); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir return(bReturn); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir /************************************************************************* 312*cdf0e10cSrcweir |* 313*cdf0e10cSrcweir |* Function aktivieren 314*cdf0e10cSrcweir |* 315*cdf0e10cSrcweir \************************************************************************/ 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir void FuConstruct::Activate() 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir FuDraw::Activate(); 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir /************************************************************************* 323*cdf0e10cSrcweir |* 324*cdf0e10cSrcweir |* Function deaktivieren 325*cdf0e10cSrcweir |* 326*cdf0e10cSrcweir \************************************************************************/ 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir void FuConstruct::Deactivate() 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir FuDraw::Deactivate(); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir 336