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 <svx/svditer.hxx> 33*cdf0e10cSrcweir #include <svx/svdobj.hxx> 34*cdf0e10cSrcweir #include <svx/svdpagv.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include "fupoor.hxx" 37*cdf0e10cSrcweir #include "tabvwsh.hxx" 38*cdf0e10cSrcweir #include "drawview.hxx" 39*cdf0e10cSrcweir #include "detfunc.hxx" 40*cdf0e10cSrcweir #include "document.hxx" 41*cdf0e10cSrcweir #include <vcl/svapp.hxx> 42*cdf0e10cSrcweir #include <svx/sdrhittesthelper.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir /************************************************************************* 45*cdf0e10cSrcweir |* 46*cdf0e10cSrcweir |* Konstruktor 47*cdf0e10cSrcweir |* 48*cdf0e10cSrcweir \************************************************************************/ 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir FuPoor::FuPoor(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, 51*cdf0e10cSrcweir SdrModel* pDoc, SfxRequest& rReq) : 52*cdf0e10cSrcweir pView(pViewP), 53*cdf0e10cSrcweir pViewShell(pViewSh), 54*cdf0e10cSrcweir pWindow(pWin), 55*cdf0e10cSrcweir pDrDoc(pDoc), 56*cdf0e10cSrcweir aSfxRequest(rReq), 57*cdf0e10cSrcweir pDialog(NULL), 58*cdf0e10cSrcweir bIsInDragMode(sal_False), 59*cdf0e10cSrcweir // #95491# remember MouseButton state 60*cdf0e10cSrcweir mnCode(0) 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir aScrollTimer.SetTimeoutHdl( LINK(this, FuPoor, ScrollHdl) ); 63*cdf0e10cSrcweir aScrollTimer.SetTimeout(SELENG_AUTOREPEAT_INTERVAL); 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir aDragTimer.SetTimeoutHdl( LINK(this, FuPoor, DragTimerHdl) ); 66*cdf0e10cSrcweir aDragTimer.SetTimeout(SELENG_DRAGDROP_TIMEOUT); 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir /************************************************************************* 70*cdf0e10cSrcweir |* 71*cdf0e10cSrcweir |* Destruktor 72*cdf0e10cSrcweir |* 73*cdf0e10cSrcweir \************************************************************************/ 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir FuPoor::~FuPoor() 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir aDragTimer.Stop(); 78*cdf0e10cSrcweir aScrollTimer.Stop(); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir if (pDialog) 81*cdf0e10cSrcweir delete pDialog; 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir /************************************************************************* 85*cdf0e10cSrcweir |* 86*cdf0e10cSrcweir |* Function aktivieren 87*cdf0e10cSrcweir |* 88*cdf0e10cSrcweir \************************************************************************/ 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir void FuPoor::Activate() 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir if (pDialog) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir pDialog->Show(); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir /************************************************************************* 99*cdf0e10cSrcweir |* 100*cdf0e10cSrcweir |* Function deaktivieren 101*cdf0e10cSrcweir |* 102*cdf0e10cSrcweir \************************************************************************/ 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir void FuPoor::Deactivate() 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir aDragTimer.Stop(); 107*cdf0e10cSrcweir aScrollTimer.Stop(); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir if (pDialog) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir pDialog->Hide(); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir /************************************************************************* 116*cdf0e10cSrcweir |* 117*cdf0e10cSrcweir |* Scrollen bei Erreichen des Fensterrandes; wird von 118*cdf0e10cSrcweir |* MouseMove aufgerufen 119*cdf0e10cSrcweir |* 120*cdf0e10cSrcweir \************************************************************************/ 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir void FuPoor::ForceScroll(const Point& aPixPos) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir aScrollTimer.Stop(); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir Size aSize = pWindow->GetSizePixel(); 127*cdf0e10cSrcweir SCsCOL dx = 0; 128*cdf0e10cSrcweir SCsROW dy = 0; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir if ( aPixPos.X() <= 0 ) dx = -1; 131*cdf0e10cSrcweir if ( aPixPos.X() >= aSize.Width() ) dx = 1; 132*cdf0e10cSrcweir if ( aPixPos.Y() <= 0 ) dy = -1; 133*cdf0e10cSrcweir if ( aPixPos.Y() >= aSize.Height() ) dy = 1; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir ScViewData* pViewData = pViewShell->GetViewData(); 136*cdf0e10cSrcweir if ( pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() ) ) 137*cdf0e10cSrcweir dx = -dx; 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir ScSplitPos eWhich = pViewData->GetActivePart(); 140*cdf0e10cSrcweir if ( dx > 0 && pViewData->GetHSplitMode() == SC_SPLIT_FIX && WhichH(eWhich) == SC_SPLIT_LEFT ) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ? 143*cdf0e10cSrcweir SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT ); 144*cdf0e10cSrcweir dx = 0; 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir if ( dy > 0 && pViewData->GetVSplitMode() == SC_SPLIT_FIX && WhichV(eWhich) == SC_SPLIT_TOP ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ? 149*cdf0e10cSrcweir SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT ); 150*cdf0e10cSrcweir dy = 0; 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir if ( dx != 0 || dy != 0 ) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir ScrollStart(); // Scrollaktion in abgeleiteter Klasse 156*cdf0e10cSrcweir pViewShell->ScrollLines(2*dx, 4*dy); 157*cdf0e10cSrcweir ScrollEnd(); 158*cdf0e10cSrcweir aScrollTimer.Start(); 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir /************************************************************************* 163*cdf0e10cSrcweir |* 164*cdf0e10cSrcweir |* Timer-Handler fuer Fensterscrolling 165*cdf0e10cSrcweir |* 166*cdf0e10cSrcweir \************************************************************************/ 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir IMPL_LINK_INLINE_START( FuPoor, ScrollHdl, Timer *, EMPTYARG ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir Point aPosPixel = pWindow->GetPointerPosPixel(); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir // #95491# use remembered MouseButton state to create correct 173*cdf0e10cSrcweir // MouseEvents for this artifical MouseMove. 174*cdf0e10cSrcweir MouseMove(MouseEvent(aPosPixel, 1, 0, GetMouseButtonCode())); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir return 0; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir IMPL_LINK_INLINE_END( FuPoor, ScrollHdl, Timer *, pTimer ) 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir // #95491# moved from inline to *.cxx 181*cdf0e10cSrcweir sal_Bool FuPoor::MouseButtonUp(const MouseEvent& rMEvt) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir // #95491# remember button state for creation of own MouseEvents 184*cdf0e10cSrcweir SetMouseButtonCode(rMEvt.GetButtons()); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir return sal_False; 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir // #95491# moved from inline to *.cxx 190*cdf0e10cSrcweir sal_Bool FuPoor::MouseButtonDown(const MouseEvent& rMEvt) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir // #95491# remember button state for creation of own MouseEvents 193*cdf0e10cSrcweir SetMouseButtonCode(rMEvt.GetButtons()); 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir return sal_False; 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir /************************************************************************* 199*cdf0e10cSrcweir |* 200*cdf0e10cSrcweir |* String in Applikations-Statuszeile ausgeben 201*cdf0e10cSrcweir |* 202*cdf0e10cSrcweir \************************************************************************/ 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir // WriteStatus gibt's nicht mehr 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir /************************************************************************* 207*cdf0e10cSrcweir |* 208*cdf0e10cSrcweir |* Tastaturereignisse bearbeiten 209*cdf0e10cSrcweir |* 210*cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls 211*cdf0e10cSrcweir |* FALSE. 212*cdf0e10cSrcweir |* 213*cdf0e10cSrcweir \************************************************************************/ 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir sal_Bool FuPoor::KeyInput(const KeyEvent& /* rKEvt */) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir sal_Bool bReturn = sal_False; 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir return(bReturn); 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir sal_uInt8 FuPoor::Command(const CommandEvent& rCEvt) 223*cdf0e10cSrcweir { 224*cdf0e10cSrcweir if ( COMMAND_STARTDRAG == rCEvt.GetCommand() ) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir //!!! sollte Joe eigentlich machen: 227*cdf0e10cSrcweir // nur, wenn im Outliner was selektiert ist, darf 228*cdf0e10cSrcweir // Command sal_True zurueckliefern: 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir OutlinerView* pOutView = pView->GetTextEditOutlinerView(); 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir if ( pOutView ) 233*cdf0e10cSrcweir return pOutView->HasSelection() ? pView->Command(rCEvt,pWindow) : SC_CMD_NONE; 234*cdf0e10cSrcweir else 235*cdf0e10cSrcweir return pView->Command(rCEvt,pWindow); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir else 238*cdf0e10cSrcweir return pView->Command(rCEvt,pWindow); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir /************************************************************************* 242*cdf0e10cSrcweir |* 243*cdf0e10cSrcweir |* Cut object to clipboard 244*cdf0e10cSrcweir |* 245*cdf0e10cSrcweir \************************************************************************/ 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir void FuPoor::DoCut() 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir if (pView) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir //! pView->DoCut(pWindow); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir /************************************************************************* 256*cdf0e10cSrcweir |* 257*cdf0e10cSrcweir |* Copy object to clipboard 258*cdf0e10cSrcweir |* 259*cdf0e10cSrcweir \************************************************************************/ 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir void FuPoor::DoCopy() 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir if (pView) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir //! pView->DoCopy(pWindow); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir /************************************************************************* 270*cdf0e10cSrcweir |* 271*cdf0e10cSrcweir |* Paste object from clipboard 272*cdf0e10cSrcweir |* 273*cdf0e10cSrcweir \************************************************************************/ 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir void FuPoor::DoPaste() 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir if (pView) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir //! pView->DoPaste(pWindow); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir /************************************************************************* 284*cdf0e10cSrcweir |* 285*cdf0e10cSrcweir |* Timer-Handler fuer Drag&Drop 286*cdf0e10cSrcweir |* 287*cdf0e10cSrcweir \************************************************************************/ 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir IMPL_LINK( FuPoor, DragTimerHdl, Timer *, EMPTYARG ) 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir // ExecuteDrag (und das damit verbundene Reschedule) direkt aus dem Timer 292*cdf0e10cSrcweir // aufzurufen, bringt die VCL-Timer-Verwaltung durcheinander, wenn dabei 293*cdf0e10cSrcweir // (z.B. im Drop) wieder ein Timer gestartet wird (z.B. ComeBack-Timer der 294*cdf0e10cSrcweir // DrawView fuer Solid Handles / ModelHasChanged) - der neue Timer laeuft 295*cdf0e10cSrcweir // dann um die Dauer des Drag&Drop zu spaet ab. 296*cdf0e10cSrcweir // Darum Drag&Drop aus eigenem Event: 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir Application::PostUserEvent( LINK( this, FuPoor, DragHdl ) ); 299*cdf0e10cSrcweir return 0; 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir IMPL_LINK( FuPoor, DragHdl, void *, EMPTYARG ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir SdrHdl* pHdl = pView->PickHandle(aMDPos); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir if ( pHdl==NULL && pView->IsMarkedHit(aMDPos) ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir pWindow->ReleaseMouse(); 309*cdf0e10cSrcweir bIsInDragMode = sal_True; 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir // pView->BeginDrag(pWindow, aMDPos); 312*cdf0e10cSrcweir pViewShell->GetScDrawView()->BeginDrag(pWindow, aMDPos); 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir return 0; 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir // Detektiv-Linie 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir sal_Bool FuPoor::IsDetectiveHit( const Point& rLogicPos ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir SdrPageView* pPV = pView->GetSdrPageView(); 322*cdf0e10cSrcweir if (!pPV) 323*cdf0e10cSrcweir return sal_False; 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir sal_Bool bFound = sal_False; 326*cdf0e10cSrcweir SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT ); 327*cdf0e10cSrcweir SdrObject* pObject = aIter.Next(); 328*cdf0e10cSrcweir while (pObject && !bFound) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir if (ScDetectiveFunc::IsNonAlienArrow( pObject )) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir sal_uInt16 nHitLog = (sal_uInt16) pWindow->PixelToLogic( 333*cdf0e10cSrcweir Size(pView->GetHitTolerancePixel(),0)).Width(); 334*cdf0e10cSrcweir if(SdrObjectPrimitiveHit(*pObject, rLogicPos, nHitLog, *pPV, 0, false)) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir bFound = sal_True; 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir pObject = aIter.Next(); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir return bFound; 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir void FuPoor::StopDragTimer() 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir if (aDragTimer.IsActive() ) 348*cdf0e10cSrcweir aDragTimer.Stop(); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir /************************************************************************* 352*cdf0e10cSrcweir |* 353*cdf0e10cSrcweir |* #98185# Create default drawing objects via keyboard 354*cdf0e10cSrcweir |* 355*cdf0e10cSrcweir \************************************************************************/ 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& /* rRectangle */) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir // empty base implementation 360*cdf0e10cSrcweir return 0L; 361*cdf0e10cSrcweir } 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir void FuPoor::ImpForceQuadratic(Rectangle& rRect) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir if(rRect.GetWidth() > rRect.GetHeight()) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir rRect = Rectangle( 368*cdf0e10cSrcweir Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()), 369*cdf0e10cSrcweir Size(rRect.GetHeight(), rRect.GetHeight())); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir else 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir rRect = Rectangle( 374*cdf0e10cSrcweir Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)), 375*cdf0e10cSrcweir Size(rRect.GetWidth(), rRect.GetWidth())); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir // #i33136# 380*cdf0e10cSrcweir bool FuPoor::doConstructOrthogonal() const 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir return false; 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir // eof 386