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 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir // INCLUDE --------------------------------------------------------------- 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <tools/urlobj.hxx> 36*cdf0e10cSrcweir #include <vcl/sound.hxx> 37*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include "select.hxx" 40*cdf0e10cSrcweir #include "sc.hrc" 41*cdf0e10cSrcweir #include "tabvwsh.hxx" 42*cdf0e10cSrcweir #include "scmod.hxx" 43*cdf0e10cSrcweir #include "document.hxx" 44*cdf0e10cSrcweir //#include "dataobj.hxx" 45*cdf0e10cSrcweir #include "transobj.hxx" 46*cdf0e10cSrcweir #include "docsh.hxx" 47*cdf0e10cSrcweir #include "tabprotection.hxx" 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir extern sal_uInt16 nScFillModeMouseModifier; // global.cxx 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using namespace com::sun::star; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir // STATIC DATA ----------------------------------------------------------- 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir static Point aSwitchPos; //! Member 56*cdf0e10cSrcweir static sal_Bool bDidSwitch = sal_False; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir // ----------------------------------------------------------------------- 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir // 61*cdf0e10cSrcweir // View (Gridwin / Tastatur) 62*cdf0e10cSrcweir // 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir ScViewFunctionSet::ScViewFunctionSet( ScViewData* pNewViewData ) : 65*cdf0e10cSrcweir pViewData( pNewViewData ), 66*cdf0e10cSrcweir pEngine( NULL ), 67*cdf0e10cSrcweir bAnchor( sal_False ), 68*cdf0e10cSrcweir bStarted( sal_False ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir DBG_ASSERT(pViewData, "ViewData==0 bei FunctionSet"); 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir ScSplitPos ScViewFunctionSet::GetWhich() 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir if (pEngine) 76*cdf0e10cSrcweir return pEngine->GetWhich(); 77*cdf0e10cSrcweir else 78*cdf0e10cSrcweir return pViewData->GetActivePart(); 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir void ScViewFunctionSet::SetSelectionEngine( ScViewSelectionEngine* pSelEngine ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir pEngine = pSelEngine; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // Drag & Drop 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir void __EXPORT ScViewFunctionSet::BeginDrag() 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir SCsCOL nPosX; 93*cdf0e10cSrcweir SCsROW nPosY; 94*cdf0e10cSrcweir if (pEngine) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir Point aMPos = pEngine->GetMousePosPixel(); 97*cdf0e10cSrcweir pViewData->GetPosFromPixel( aMPos.X(), aMPos.Y(), GetWhich(), nPosX, nPosY ); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir else 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir nPosX = pViewData->GetCurX(); 102*cdf0e10cSrcweir nPosY = pViewData->GetCurY(); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 106*cdf0e10cSrcweir sal_Bool bRefMode = pScMod->IsFormulaMode(); 107*cdf0e10cSrcweir if (!bRefMode) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir pViewData->GetView()->FakeButtonUp( GetWhich() ); // ButtonUp wird verschluckt 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir ScMarkData& rMark = pViewData->GetMarkData(); 112*cdf0e10cSrcweir // rMark.SetMarking(sal_False); // es fehlt ein ButtonUp 113*cdf0e10cSrcweir rMark.MarkToSimple(); 114*cdf0e10cSrcweir if ( rMark.IsMarked() && !rMark.IsMultiMarked() ) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP ); 117*cdf0e10cSrcweir // bApi = sal_True -> no error mesages 118*cdf0e10cSrcweir sal_Bool bCopied = pViewData->GetView()->CopyToClip( pClipDoc, sal_False, sal_True ); 119*cdf0e10cSrcweir if ( bCopied ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir sal_Int8 nDragActions = pViewData->GetView()->SelectionEditable() ? 122*cdf0e10cSrcweir ( DND_ACTION_COPYMOVE | DND_ACTION_LINK ) : 123*cdf0e10cSrcweir ( DND_ACTION_COPY | DND_ACTION_LINK ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir ScDocShell* pDocSh = pViewData->GetDocShell(); 126*cdf0e10cSrcweir TransferableObjectDescriptor aObjDesc; 127*cdf0e10cSrcweir pDocSh->FillTransferableObjectDescriptor( aObjDesc ); 128*cdf0e10cSrcweir aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); 129*cdf0e10cSrcweir // maSize is set in ScTransferObj ctor 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc ); 132*cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj ); 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // set position of dragged cell within range 135*cdf0e10cSrcweir ScRange aMarkRange = pTransferObj->GetRange(); 136*cdf0e10cSrcweir SCCOL nStartX = aMarkRange.aStart.Col(); 137*cdf0e10cSrcweir SCROW nStartY = aMarkRange.aStart.Row(); 138*cdf0e10cSrcweir SCCOL nHandleX = (nPosX >= (SCsCOL) nStartX) ? nPosX - nStartX : 0; 139*cdf0e10cSrcweir SCROW nHandleY = (nPosY >= (SCsROW) nStartY) ? nPosY - nStartY : 0; 140*cdf0e10cSrcweir pTransferObj->SetDragHandlePos( nHandleX, nHandleY ); 141*cdf0e10cSrcweir pTransferObj->SetVisibleTab( nTab ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir pTransferObj->SetDragSource( pDocSh, rMark ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir Window* pWindow = pViewData->GetActiveWin(); 146*cdf0e10cSrcweir if ( pWindow->IsTracking() ) 147*cdf0e10cSrcweir pWindow->EndTracking( ENDTRACK_CANCEL ); // abort selecting 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir SC_MOD()->SetDragObject( pTransferObj, NULL ); // for internal D&D 150*cdf0e10cSrcweir pTransferObj->StartDrag( pWindow, nDragActions ); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir return; // dragging started 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir else 155*cdf0e10cSrcweir delete pClipDoc; 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir Sound::Beep(); // can't drag 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir // Selektion 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir void __EXPORT ScViewFunctionSet::CreateAnchor() 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir if (bAnchor) return; 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir sal_Bool bRefMode = SC_MOD()->IsFormulaMode(); 169*cdf0e10cSrcweir if (bRefMode) 170*cdf0e10cSrcweir SetAnchor( pViewData->GetRefStartX(), pViewData->GetRefStartY() ); 171*cdf0e10cSrcweir else 172*cdf0e10cSrcweir SetAnchor( pViewData->GetCurX(), pViewData->GetCurY() ); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir void ScViewFunctionSet::SetAnchor( SCCOL nPosX, SCROW nPosY ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir sal_Bool bRefMode = SC_MOD()->IsFormulaMode(); 178*cdf0e10cSrcweir ScTabView* pView = pViewData->GetView(); 179*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir if (bRefMode) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir pView->DoneRefMode( sal_False ); 184*cdf0e10cSrcweir aAnchorPos.Set( nPosX, nPosY, nTab ); 185*cdf0e10cSrcweir pView->InitRefMode( aAnchorPos.Col(), aAnchorPos.Row(), aAnchorPos.Tab(), 186*cdf0e10cSrcweir SC_REFTYPE_REF ); 187*cdf0e10cSrcweir bStarted = sal_True; 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir else if (pViewData->IsAnyFillMode()) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir aAnchorPos.Set( nPosX, nPosY, nTab ); 192*cdf0e10cSrcweir bStarted = sal_True; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir else 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir // nicht weg und gleich wieder hin 197*cdf0e10cSrcweir if ( bStarted && pView->IsMarking( nPosX, nPosY, nTab ) ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir // nix 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir else 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir pView->DoneBlockMode( sal_True ); 204*cdf0e10cSrcweir aAnchorPos.Set( nPosX, nPosY, nTab ); 205*cdf0e10cSrcweir ScMarkData& rMark = pViewData->GetMarkData(); 206*cdf0e10cSrcweir if ( rMark.IsMarked() || rMark.IsMultiMarked() ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir pView->InitBlockMode( aAnchorPos.Col(), aAnchorPos.Row(), 209*cdf0e10cSrcweir aAnchorPos.Tab(), sal_True ); 210*cdf0e10cSrcweir bStarted = sal_True; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir else 213*cdf0e10cSrcweir bStarted = sal_False; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir bAnchor = sal_True; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir void __EXPORT ScViewFunctionSet::DestroyAnchor() 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir sal_Bool bRefMode = SC_MOD()->IsFormulaMode(); 222*cdf0e10cSrcweir if (bRefMode) 223*cdf0e10cSrcweir pViewData->GetView()->DoneRefMode( sal_True ); 224*cdf0e10cSrcweir else 225*cdf0e10cSrcweir pViewData->GetView()->DoneBlockMode( sal_True ); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir bAnchor = sal_False; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir void ScViewFunctionSet::SetAnchorFlag( sal_Bool bSet ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir bAnchor = bSet; 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir sal_Bool __EXPORT ScViewFunctionSet::SetCursorAtPoint( const Point& rPointPixel, sal_Bool /* bDontSelectAtCursor */ ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir if ( bDidSwitch ) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir if ( rPointPixel == aSwitchPos ) 240*cdf0e10cSrcweir return sal_False; // nicht auf falschem Fenster scrollen 241*cdf0e10cSrcweir else 242*cdf0e10cSrcweir bDidSwitch = sal_False; 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir aSwitchPos = rPointPixel; // nur wichtig, wenn bDidSwitch 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir // treat position 0 as -1, so scrolling is always possible 247*cdf0e10cSrcweir // (with full screen and hidden headers, the top left border may be at 0) 248*cdf0e10cSrcweir // (moved from ScViewData::GetPosFromPixel) 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir Point aEffPos = rPointPixel; 251*cdf0e10cSrcweir if ( aEffPos.X() == 0 ) 252*cdf0e10cSrcweir aEffPos.X() = -1; 253*cdf0e10cSrcweir if ( aEffPos.Y() == 0 ) 254*cdf0e10cSrcweir aEffPos.Y() = -1; 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir // Scrolling 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir Size aWinSize = pEngine->GetWindow()->GetOutputSizePixel(); 259*cdf0e10cSrcweir sal_Bool bRightScroll = ( aEffPos.X() >= aWinSize.Width() ); 260*cdf0e10cSrcweir sal_Bool bBottomScroll = ( aEffPos.Y() >= aWinSize.Height() ); 261*cdf0e10cSrcweir sal_Bool bNegScroll = ( aEffPos.X() < 0 || aEffPos.Y() < 0 ); 262*cdf0e10cSrcweir sal_Bool bScroll = bRightScroll || bBottomScroll || bNegScroll; 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir SCsCOL nPosX; 265*cdf0e10cSrcweir SCsROW nPosY; 266*cdf0e10cSrcweir pViewData->GetPosFromPixel( aEffPos.X(), aEffPos.Y(), GetWhich(), 267*cdf0e10cSrcweir nPosX, nPosY, sal_True, sal_True ); // mit Repair 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir // fuer AutoFill in der Mitte der Zelle umschalten 270*cdf0e10cSrcweir // dabei aber nicht das Scrolling nach rechts/unten verhindern 271*cdf0e10cSrcweir if ( pViewData->IsFillMode() || pViewData->GetFillMode() == SC_FILL_MATRIX ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir sal_Bool bLeft, bTop; 274*cdf0e10cSrcweir pViewData->GetMouseQuadrant( aEffPos, GetWhich(), nPosX, nPosY, bLeft, bTop ); 275*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 276*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 277*cdf0e10cSrcweir if ( bLeft && !bRightScroll ) 278*cdf0e10cSrcweir do --nPosX; while ( nPosX>=0 && pDoc->ColHidden( nPosX, nTab ) ); 279*cdf0e10cSrcweir if ( bTop && !bBottomScroll ) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir if (--nPosY >= 0) 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir nPosY = pDoc->LastVisibleRow(0, nPosY, nTab); 284*cdf0e10cSrcweir if (!ValidRow(nPosY)) 285*cdf0e10cSrcweir nPosY = -1; 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir // negativ ist erlaubt 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir // ueber Fixier-Grenze bewegt? 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir ScSplitPos eWhich = GetWhich(); 294*cdf0e10cSrcweir if ( eWhich == pViewData->GetActivePart() ) 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ) 297*cdf0e10cSrcweir if ( aEffPos.X() >= aWinSize.Width() ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir if ( eWhich == SC_SPLIT_TOPLEFT ) 300*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT ), bScroll = sal_False, bDidSwitch = sal_True; 301*cdf0e10cSrcweir else if ( eWhich == SC_SPLIT_BOTTOMLEFT ) 302*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bScroll = sal_False, bDidSwitch = sal_True; 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX ) 306*cdf0e10cSrcweir if ( aEffPos.Y() >= aWinSize.Height() ) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir if ( eWhich == SC_SPLIT_TOPLEFT ) 309*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT ), bScroll = sal_False, bDidSwitch = sal_True; 310*cdf0e10cSrcweir else if ( eWhich == SC_SPLIT_TOPRIGHT ) 311*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bScroll = sal_False, bDidSwitch = sal_True; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir pViewData->ResetOldCursor(); 316*cdf0e10cSrcweir return SetCursorAtCell( nPosX, nPosY, bScroll ); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir sal_Bool ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, sal_Bool bScroll ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir ScTabView* pView = pViewData->GetView(); 322*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 323*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir if ( pDoc->IsTabProtected(nTab) ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir if (nPosX < 0 || nPosY < 0) 328*cdf0e10cSrcweir return false; 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); 331*cdf0e10cSrcweir bool bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); 332*cdf0e10cSrcweir bool bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir if ( bSkipProtected && bSkipUnprotected ) 335*cdf0e10cSrcweir return sal_False; 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir bool bCellProtected = pDoc->HasAttrib(nPosX, nPosY, nTab, nPosX, nPosY, nTab, HASATTR_PROTECTED); 338*cdf0e10cSrcweir if ( (bCellProtected && bSkipProtected) || (!bCellProtected && bSkipUnprotected) ) 339*cdf0e10cSrcweir // Don't select this cell! 340*cdf0e10cSrcweir return sal_False; 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 344*cdf0e10cSrcweir ScTabViewShell* pViewShell = pViewData->GetViewShell(); 345*cdf0e10cSrcweir bool bRefMode = ( pViewShell ? pViewShell->IsRefInputMode() : false ); 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir sal_Bool bHide = !bRefMode && !pViewData->IsAnyFillMode() && 348*cdf0e10cSrcweir ( nPosX != (SCsCOL) pViewData->GetCurX() || nPosY != (SCsROW) pViewData->GetCurY() ); 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir if (bHide) 351*cdf0e10cSrcweir pView->HideAllCursors(); 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir if (bScroll) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir if (bRefMode) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir ScSplitPos eWhich = GetWhich(); 358*cdf0e10cSrcweir pView->AlignToCursor( nPosX, nPosY, SC_FOLLOW_LINE, &eWhich ); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir else 361*cdf0e10cSrcweir pView->AlignToCursor( nPosX, nPosY, SC_FOLLOW_LINE ); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir if (bRefMode) 365*cdf0e10cSrcweir { 366*cdf0e10cSrcweir // #90910# if no input is possible from this doc, don't move the reference cursor around 367*cdf0e10cSrcweir if ( !pScMod->IsModalMode(pViewData->GetSfxDocShell()) ) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir if (!bAnchor) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir pView->DoneRefMode( sal_True ); 372*cdf0e10cSrcweir pView->InitRefMode( nPosX, nPosY, pViewData->GetTabNo(), SC_REFTYPE_REF ); 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir pView->UpdateRef( nPosX, nPosY, pViewData->GetTabNo() ); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir else if (pViewData->IsFillMode() || 379*cdf0e10cSrcweir (pViewData->GetFillMode() == SC_FILL_MATRIX && (nScFillModeMouseModifier & KEY_MOD1) )) 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir // Wenn eine Matrix angefasst wurde, kann mit Ctrl auf AutoFill zurueckgeschaltet werden 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir SCCOL nStartX, nEndX; 384*cdf0e10cSrcweir SCROW nStartY, nEndY; // Block 385*cdf0e10cSrcweir SCTAB nDummy; 386*cdf0e10cSrcweir pViewData->GetSimpleArea( nStartX, nStartY, nDummy, nEndX, nEndY, nDummy ); 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir if (pViewData->GetRefType() != SC_REFTYPE_FILL) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir pView->InitRefMode( nStartX, nStartY, nTab, SC_REFTYPE_FILL ); 391*cdf0e10cSrcweir CreateAnchor(); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir ScRange aDelRange; 395*cdf0e10cSrcweir sal_Bool bOldDelMark = pViewData->GetDelMark( aDelRange ); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir if ( nPosX+1 >= (SCsCOL) nStartX && nPosX <= (SCsCOL) nEndX && 398*cdf0e10cSrcweir nPosY+1 >= (SCsROW) nStartY && nPosY <= (SCsROW) nEndY && 399*cdf0e10cSrcweir ( nPosX != nEndX || nPosY != nEndY ) ) // verkleinern ? 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir // Richtung (links oder oben) 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir long nSizeX = 0; 404*cdf0e10cSrcweir for (SCCOL i=nPosX+1; i<=nEndX; i++) 405*cdf0e10cSrcweir nSizeX += pDoc->GetColWidth( i, nTab ); 406*cdf0e10cSrcweir long nSizeY = (long) pDoc->GetRowHeight( nPosY+1, nEndY, nTab ); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir SCCOL nDelStartX = nStartX; 409*cdf0e10cSrcweir SCROW nDelStartY = nStartY; 410*cdf0e10cSrcweir if ( nSizeX > nSizeY ) 411*cdf0e10cSrcweir nDelStartX = nPosX + 1; 412*cdf0e10cSrcweir else 413*cdf0e10cSrcweir nDelStartY = nPosY + 1; 414*cdf0e10cSrcweir // 0 braucht nicht mehr getrennt abgefragt zu werden, weil nPosX/Y auch negativ wird 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir if ( nDelStartX < nStartX ) 417*cdf0e10cSrcweir nDelStartX = nStartX; 418*cdf0e10cSrcweir if ( nDelStartY < nStartY ) 419*cdf0e10cSrcweir nDelStartY = nStartY; 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir // Bereich setzen 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir pViewData->SetDelMark( ScRange( nDelStartX,nDelStartY,nTab, 424*cdf0e10cSrcweir nEndX,nEndY,nTab ) ); 425*cdf0e10cSrcweir pViewData->GetView()->UpdateShrinkOverlay(); 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir #if 0 428*cdf0e10cSrcweir if ( bOldDelMark ) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir ScUpdateRect aRect( aDelRange.aStart.Col(), aDelRange.aStart.Row(), 431*cdf0e10cSrcweir aDelRange.aEnd.Col(), aDelRange.aEnd.Row() ); 432*cdf0e10cSrcweir aRect.SetNew( nDelStartX,nDelStartY, nEndX,nEndY ); 433*cdf0e10cSrcweir SCCOL nPaintStartX; 434*cdf0e10cSrcweir SCROW nPaintStartY; 435*cdf0e10cSrcweir SCCOL nPaintEndX; 436*cdf0e10cSrcweir SCROW nPaintEndY; 437*cdf0e10cSrcweir if (aRect.GetDiff( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY )) 438*cdf0e10cSrcweir pViewData->GetView()-> 439*cdf0e10cSrcweir PaintArea( nPaintStartX, nPaintStartY, 440*cdf0e10cSrcweir nPaintEndX, nPaintEndY, SC_UPDATE_MARKS ); 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir else 443*cdf0e10cSrcweir #endif 444*cdf0e10cSrcweir pViewData->GetView()-> 445*cdf0e10cSrcweir PaintArea( nStartX,nDelStartY, nEndX,nEndY, SC_UPDATE_MARKS ); 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir nPosX = nEndX; // roten Rahmen um ganzen Bereich lassen 448*cdf0e10cSrcweir nPosY = nEndY; 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir // Referenz wieder richtigherum, falls unten umgedreht 451*cdf0e10cSrcweir if ( nStartX != pViewData->GetRefStartX() || nStartY != pViewData->GetRefStartY() ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir pViewData->GetView()->DoneRefMode(); 454*cdf0e10cSrcweir pViewData->GetView()->InitRefMode( nStartX, nStartY, nTab, SC_REFTYPE_FILL ); 455*cdf0e10cSrcweir } 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir else 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir if ( bOldDelMark ) 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir pViewData->ResetDelMark(); 462*cdf0e10cSrcweir pViewData->GetView()->UpdateShrinkOverlay(); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir #if 0 465*cdf0e10cSrcweir pViewData->GetView()-> 466*cdf0e10cSrcweir PaintArea( aDelRange.aStart.Col(), aDelRange.aStart.Row(), 467*cdf0e10cSrcweir aDelRange.aEnd.Col(), aDelRange.aEnd.Row(), SC_UPDATE_MARKS ); 468*cdf0e10cSrcweir #endif 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir sal_Bool bNegX = ( nPosX < (SCsCOL) nStartX ); 472*cdf0e10cSrcweir sal_Bool bNegY = ( nPosY < (SCsROW) nStartY ); 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir long nSizeX = 0; 475*cdf0e10cSrcweir if ( bNegX ) 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir // #94321# in SetCursorAtPoint hidden columns are skipped. 478*cdf0e10cSrcweir // They must be skipped here too, or the result will always be the first hidden column. 479*cdf0e10cSrcweir do ++nPosX; while ( nPosX<nStartX && pDoc->ColHidden(nPosX, nTab) ); 480*cdf0e10cSrcweir for (SCCOL i=nPosX; i<nStartX; i++) 481*cdf0e10cSrcweir nSizeX += pDoc->GetColWidth( i, nTab ); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir else 484*cdf0e10cSrcweir for (SCCOL i=nEndX+1; i<=nPosX; i++) 485*cdf0e10cSrcweir nSizeX += pDoc->GetColWidth( i, nTab ); 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir long nSizeY = 0; 488*cdf0e10cSrcweir if ( bNegY ) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir // #94321# in SetCursorAtPoint hidden rows are skipped. 491*cdf0e10cSrcweir // They must be skipped here too, or the result will always be the first hidden row. 492*cdf0e10cSrcweir if (++nPosY < nStartY) 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir nPosY = pDoc->FirstVisibleRow(nPosY, nStartY-1, nTab); 495*cdf0e10cSrcweir if (!ValidRow(nPosY)) 496*cdf0e10cSrcweir nPosY = nStartY; 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir nSizeY += pDoc->GetRowHeight( nPosY, nStartY-1, nTab ); 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir else 501*cdf0e10cSrcweir nSizeY += pDoc->GetRowHeight( nEndY+1, nPosY, nTab ); 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir if ( nSizeX > nSizeY ) // Fill immer nur in einer Richtung 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir nPosY = nEndY; 506*cdf0e10cSrcweir bNegY = sal_False; 507*cdf0e10cSrcweir } 508*cdf0e10cSrcweir else 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir nPosX = nEndX; 511*cdf0e10cSrcweir bNegX = sal_False; 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir 514*cdf0e10cSrcweir SCCOL nRefStX = bNegX ? nEndX : nStartX; 515*cdf0e10cSrcweir SCROW nRefStY = bNegY ? nEndY : nStartY; 516*cdf0e10cSrcweir if ( nRefStX != pViewData->GetRefStartX() || nRefStY != pViewData->GetRefStartY() ) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir pViewData->GetView()->DoneRefMode(); 519*cdf0e10cSrcweir pViewData->GetView()->InitRefMode( nRefStX, nRefStY, nTab, SC_REFTYPE_FILL ); 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir pView->UpdateRef( nPosX, nPosY, nTab ); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir else if (pViewData->IsAnyFillMode()) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir sal_uInt8 nMode = pViewData->GetFillMode(); 528*cdf0e10cSrcweir if ( nMode == SC_FILL_EMBED_LT || nMode == SC_FILL_EMBED_RB ) 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir DBG_ASSERT( pDoc->IsEmbedded(), "!pDoc->IsEmbedded()" ); 531*cdf0e10cSrcweir ScRange aRange; 532*cdf0e10cSrcweir pDoc->GetEmbedded( aRange); 533*cdf0e10cSrcweir ScRefType eRefMode = (nMode == SC_FILL_EMBED_LT) ? SC_REFTYPE_EMBED_LT : SC_REFTYPE_EMBED_RB; 534*cdf0e10cSrcweir if (pViewData->GetRefType() != eRefMode) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir if ( nMode == SC_FILL_EMBED_LT ) 537*cdf0e10cSrcweir pView->InitRefMode( aRange.aEnd.Col(), aRange.aEnd.Row(), nTab, eRefMode ); 538*cdf0e10cSrcweir else 539*cdf0e10cSrcweir pView->InitRefMode( aRange.aStart.Col(), aRange.aStart.Row(), nTab, eRefMode ); 540*cdf0e10cSrcweir CreateAnchor(); 541*cdf0e10cSrcweir } 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir pView->UpdateRef( nPosX, nPosY, nTab ); 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir else if ( nMode == SC_FILL_MATRIX ) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir SCCOL nStartX, nEndX; 548*cdf0e10cSrcweir SCROW nStartY, nEndY; // Block 549*cdf0e10cSrcweir SCTAB nDummy; 550*cdf0e10cSrcweir pViewData->GetSimpleArea( nStartX, nStartY, nDummy, nEndX, nEndY, nDummy ); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir if (pViewData->GetRefType() != SC_REFTYPE_FILL) 553*cdf0e10cSrcweir { 554*cdf0e10cSrcweir pView->InitRefMode( nStartX, nStartY, nTab, SC_REFTYPE_FILL ); 555*cdf0e10cSrcweir CreateAnchor(); 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir if ( nPosX < nStartX ) nPosX = nStartX; 559*cdf0e10cSrcweir if ( nPosY < nStartY ) nPosY = nStartY; 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir pView->UpdateRef( nPosX, nPosY, nTab ); 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir // else neue Modi 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir else // normales Markieren 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir sal_Bool bHideCur = bAnchor && ( (SCCOL)nPosX != pViewData->GetCurX() || 568*cdf0e10cSrcweir (SCROW)nPosY != pViewData->GetCurY() ); 569*cdf0e10cSrcweir if (bHideCur) 570*cdf0e10cSrcweir pView->HideAllCursors(); // sonst zweimal: Block und SetCursor 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir if (bAnchor) 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir if (!bStarted) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir sal_Bool bMove = ( nPosX != (SCsCOL) aAnchorPos.Col() || 577*cdf0e10cSrcweir nPosY != (SCsROW) aAnchorPos.Row() ); 578*cdf0e10cSrcweir if ( bMove || ( pEngine && pEngine->GetMouseEvent().IsShift() ) ) 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir pView->InitBlockMode( aAnchorPos.Col(), aAnchorPos.Row(), 581*cdf0e10cSrcweir aAnchorPos.Tab(), sal_True ); 582*cdf0e10cSrcweir bStarted = sal_True; 583*cdf0e10cSrcweir } 584*cdf0e10cSrcweir } 585*cdf0e10cSrcweir if (bStarted) 586*cdf0e10cSrcweir pView->MarkCursor( (SCCOL) nPosX, (SCROW) nPosY, nTab, sal_False, sal_False, sal_True ); 587*cdf0e10cSrcweir } 588*cdf0e10cSrcweir else 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir ScMarkData& rMark = pViewData->GetMarkData(); 591*cdf0e10cSrcweir if (rMark.IsMarked() || rMark.IsMultiMarked()) 592*cdf0e10cSrcweir { 593*cdf0e10cSrcweir pView->DoneBlockMode(sal_True); 594*cdf0e10cSrcweir pView->InitBlockMode( nPosX, nPosY, nTab, sal_True ); 595*cdf0e10cSrcweir pView->MarkCursor( (SCCOL) nPosX, (SCROW) nPosY, nTab ); 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir aAnchorPos.Set( nPosX, nPosY, nTab ); 598*cdf0e10cSrcweir bStarted = sal_True; 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir // #i3875# *Hack* When a new cell is Ctrl-clicked with no pre-selected cells, 601*cdf0e10cSrcweir // it highlights that new cell as well as the old cell where the cursor is 602*cdf0e10cSrcweir // positioned prior to the click. A selection mode via Shift-F8 should also 603*cdf0e10cSrcweir // follow the same behavior. 604*cdf0e10cSrcweir else if ( pViewData->IsSelCtrlMouseClick() ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir SCCOL nOldX = pViewData->GetCurX(); 607*cdf0e10cSrcweir SCROW nOldY = pViewData->GetCurY(); 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir pView->InitBlockMode( nOldX, nOldY, nTab, sal_True ); 610*cdf0e10cSrcweir pView->MarkCursor( (SCCOL) nOldX, (SCROW) nOldY, nTab ); 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir if ( nOldX != nPosX || nOldY != nPosY ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir pView->DoneBlockMode( sal_True ); 615*cdf0e10cSrcweir pView->InitBlockMode( nPosX, nPosY, nTab, sal_True ); 616*cdf0e10cSrcweir pView->MarkCursor( (SCCOL) nPosX, (SCROW) nPosY, nTab ); 617*cdf0e10cSrcweir aAnchorPos.Set( nPosX, nPosY, nTab ); 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir 620*cdf0e10cSrcweir bStarted = sal_True; 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir } 623*cdf0e10cSrcweir 624*cdf0e10cSrcweir pView->SetCursor( (SCCOL) nPosX, (SCROW) nPosY ); 625*cdf0e10cSrcweir pViewData->SetRefStart( nPosX, nPosY, nTab ); 626*cdf0e10cSrcweir if (bHideCur) 627*cdf0e10cSrcweir pView->ShowAllCursors(); 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir if (bHide) 631*cdf0e10cSrcweir pView->ShowAllCursors(); 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir return sal_True; 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir sal_Bool __EXPORT ScViewFunctionSet::IsSelectionAtPoint( const Point& rPointPixel ) 637*cdf0e10cSrcweir { 638*cdf0e10cSrcweir sal_Bool bRefMode = SC_MOD()->IsFormulaMode(); 639*cdf0e10cSrcweir if (bRefMode) 640*cdf0e10cSrcweir return sal_False; 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir if (pViewData->IsAnyFillMode()) 643*cdf0e10cSrcweir return sal_False; 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir ScMarkData& rMark = pViewData->GetMarkData(); 646*cdf0e10cSrcweir if (bAnchor || !rMark.IsMultiMarked()) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir SCsCOL nPosX; 649*cdf0e10cSrcweir SCsROW nPosY; 650*cdf0e10cSrcweir pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), GetWhich(), nPosX, nPosY ); 651*cdf0e10cSrcweir return pViewData->GetMarkData().IsCellMarked( (SCCOL) nPosX, (SCROW) nPosY ); 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir return sal_False; 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir void __EXPORT ScViewFunctionSet::DeselectAtPoint( const Point& /* rPointPixel */ ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir // gibt's nicht 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir void __EXPORT ScViewFunctionSet::DeselectAll() 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir if (pViewData->IsAnyFillMode()) 665*cdf0e10cSrcweir return; 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir sal_Bool bRefMode = SC_MOD()->IsFormulaMode(); 668*cdf0e10cSrcweir if (bRefMode) 669*cdf0e10cSrcweir { 670*cdf0e10cSrcweir pViewData->GetView()->DoneRefMode( sal_False ); 671*cdf0e10cSrcweir } 672*cdf0e10cSrcweir else 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir pViewData->GetView()->DoneBlockMode( sal_False ); 675*cdf0e10cSrcweir pViewData->GetViewShell()->UpdateInputHandler(); 676*cdf0e10cSrcweir } 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir bAnchor = sal_False; 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir //------------------------------------------------------------------------ 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir ScViewSelectionEngine::ScViewSelectionEngine( Window* pWindow, ScTabView* pView, 684*cdf0e10cSrcweir ScSplitPos eSplitPos ) : 685*cdf0e10cSrcweir SelectionEngine( pWindow, pView->GetFunctionSet() ), 686*cdf0e10cSrcweir eWhich( eSplitPos ) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir // Parameter einstellen 689*cdf0e10cSrcweir SetSelectionMode( MULTIPLE_SELECTION ); 690*cdf0e10cSrcweir EnableDrag( sal_True ); 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir //------------------------------------------------------------------------ 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir // 697*cdf0e10cSrcweir // Spalten- / Zeilenheader 698*cdf0e10cSrcweir // 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir ScHeaderFunctionSet::ScHeaderFunctionSet( ScViewData* pNewViewData ) : 701*cdf0e10cSrcweir pViewData( pNewViewData ), 702*cdf0e10cSrcweir bColumn( sal_False ), 703*cdf0e10cSrcweir eWhich( SC_SPLIT_TOPLEFT ), 704*cdf0e10cSrcweir bAnchor( sal_False ), 705*cdf0e10cSrcweir nCursorPos( 0 ) 706*cdf0e10cSrcweir { 707*cdf0e10cSrcweir DBG_ASSERT(pViewData, "ViewData==0 bei FunctionSet"); 708*cdf0e10cSrcweir } 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir void ScHeaderFunctionSet::SetColumn( sal_Bool bSet ) 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir bColumn = bSet; 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir void ScHeaderFunctionSet::SetWhich( ScSplitPos eNew ) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir eWhich = eNew; 718*cdf0e10cSrcweir } 719*cdf0e10cSrcweir 720*cdf0e10cSrcweir void __EXPORT ScHeaderFunctionSet::BeginDrag() 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir // gippsnich 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir void __EXPORT ScHeaderFunctionSet::CreateAnchor() 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir if (bAnchor) 728*cdf0e10cSrcweir return; 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir ScTabView* pView = pViewData->GetView(); 731*cdf0e10cSrcweir pView->DoneBlockMode( sal_True ); 732*cdf0e10cSrcweir if (bColumn) 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir pView->InitBlockMode( static_cast<SCCOL>(nCursorPos), 0, pViewData->GetTabNo(), sal_True, sal_True, sal_False ); 735*cdf0e10cSrcweir pView->MarkCursor( static_cast<SCCOL>(nCursorPos), MAXROW, pViewData->GetTabNo() ); 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir else 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir pView->InitBlockMode( 0, nCursorPos, pViewData->GetTabNo(), sal_True, sal_False, sal_True ); 740*cdf0e10cSrcweir pView->MarkCursor( MAXCOL, nCursorPos, pViewData->GetTabNo() ); 741*cdf0e10cSrcweir } 742*cdf0e10cSrcweir bAnchor = sal_True; 743*cdf0e10cSrcweir } 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir void __EXPORT ScHeaderFunctionSet::DestroyAnchor() 746*cdf0e10cSrcweir { 747*cdf0e10cSrcweir pViewData->GetView()->DoneBlockMode( sal_True ); 748*cdf0e10cSrcweir bAnchor = sal_False; 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir sal_Bool __EXPORT ScHeaderFunctionSet::SetCursorAtPoint( const Point& rPointPixel, sal_Bool /* bDontSelectAtCursor */ ) 752*cdf0e10cSrcweir { 753*cdf0e10cSrcweir if ( bDidSwitch ) 754*cdf0e10cSrcweir { 755*cdf0e10cSrcweir // die naechste gueltige Position muss vom anderen Fenster kommen 756*cdf0e10cSrcweir if ( rPointPixel == aSwitchPos ) 757*cdf0e10cSrcweir return sal_False; // nicht auf falschem Fenster scrollen 758*cdf0e10cSrcweir else 759*cdf0e10cSrcweir bDidSwitch = sal_False; 760*cdf0e10cSrcweir } 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir // Scrolling 763*cdf0e10cSrcweir 764*cdf0e10cSrcweir Size aWinSize = pViewData->GetActiveWin()->GetOutputSizePixel(); 765*cdf0e10cSrcweir sal_Bool bScroll; 766*cdf0e10cSrcweir if (bColumn) 767*cdf0e10cSrcweir bScroll = ( rPointPixel.X() < 0 || rPointPixel.X() >= aWinSize.Width() ); 768*cdf0e10cSrcweir else 769*cdf0e10cSrcweir bScroll = ( rPointPixel.Y() < 0 || rPointPixel.Y() >= aWinSize.Height() ); 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir // ueber Fixier-Grenze bewegt? 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir sal_Bool bSwitched = sal_False; 774*cdf0e10cSrcweir if ( bColumn ) 775*cdf0e10cSrcweir { 776*cdf0e10cSrcweir if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ) 777*cdf0e10cSrcweir { 778*cdf0e10cSrcweir if ( rPointPixel.X() > aWinSize.Width() ) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir if ( eWhich == SC_SPLIT_TOPLEFT ) 781*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT ), bSwitched = sal_True; 782*cdf0e10cSrcweir else if ( eWhich == SC_SPLIT_BOTTOMLEFT ) 783*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bSwitched = sal_True; 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir else // Zeilenkoepfe 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX ) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir if ( rPointPixel.Y() > aWinSize.Height() ) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir if ( eWhich == SC_SPLIT_TOPLEFT ) 794*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT ), bSwitched = sal_True; 795*cdf0e10cSrcweir else if ( eWhich == SC_SPLIT_TOPRIGHT ) 796*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bSwitched = sal_True; 797*cdf0e10cSrcweir } 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir if (bSwitched) 801*cdf0e10cSrcweir { 802*cdf0e10cSrcweir aSwitchPos = rPointPixel; 803*cdf0e10cSrcweir bDidSwitch = sal_True; 804*cdf0e10cSrcweir return sal_False; // nicht mit falschen Positionen rechnen 805*cdf0e10cSrcweir } 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir // 808*cdf0e10cSrcweir 809*cdf0e10cSrcweir SCsCOL nPosX; 810*cdf0e10cSrcweir SCsROW nPosY; 811*cdf0e10cSrcweir pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), pViewData->GetActivePart(), 812*cdf0e10cSrcweir nPosX, nPosY, sal_False ); 813*cdf0e10cSrcweir if (bColumn) 814*cdf0e10cSrcweir { 815*cdf0e10cSrcweir nCursorPos = static_cast<SCCOLROW>(nPosX); 816*cdf0e10cSrcweir nPosY = pViewData->GetPosY(WhichV(pViewData->GetActivePart())); 817*cdf0e10cSrcweir } 818*cdf0e10cSrcweir else 819*cdf0e10cSrcweir { 820*cdf0e10cSrcweir nCursorPos = static_cast<SCCOLROW>(nPosY); 821*cdf0e10cSrcweir nPosX = pViewData->GetPosX(WhichH(pViewData->GetActivePart())); 822*cdf0e10cSrcweir } 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir ScTabView* pView = pViewData->GetView(); 825*cdf0e10cSrcweir sal_Bool bHide = pViewData->GetCurX() != nPosX || 826*cdf0e10cSrcweir pViewData->GetCurY() != nPosY; 827*cdf0e10cSrcweir if (bHide) 828*cdf0e10cSrcweir pView->HideAllCursors(); 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir if (bScroll) 831*cdf0e10cSrcweir pView->AlignToCursor( nPosX, nPosY, SC_FOLLOW_LINE ); 832*cdf0e10cSrcweir pView->SetCursor( nPosX, nPosY ); 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir if ( !bAnchor || !pView->IsBlockMode() ) 835*cdf0e10cSrcweir { 836*cdf0e10cSrcweir pView->DoneBlockMode( sal_True ); 837*cdf0e10cSrcweir pViewData->GetMarkData().MarkToMulti(); //! wer verstellt das ??? 838*cdf0e10cSrcweir pView->InitBlockMode( nPosX, nPosY, pViewData->GetTabNo(), sal_True, bColumn, !bColumn ); 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir bAnchor = sal_True; 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir 843*cdf0e10cSrcweir pView->MarkCursor( nPosX, nPosY, pViewData->GetTabNo(), bColumn, !bColumn ); 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir // SelectionChanged innerhalb von HideCursor wegen UpdateAutoFillMark 846*cdf0e10cSrcweir pView->SelectionChanged(); 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir if (bHide) 849*cdf0e10cSrcweir pView->ShowAllCursors(); 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir return sal_True; 852*cdf0e10cSrcweir } 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir sal_Bool __EXPORT ScHeaderFunctionSet::IsSelectionAtPoint( const Point& rPointPixel ) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir SCsCOL nPosX; 857*cdf0e10cSrcweir SCsROW nPosY; 858*cdf0e10cSrcweir pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), pViewData->GetActivePart(), 859*cdf0e10cSrcweir nPosX, nPosY, sal_False ); 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir ScMarkData& rMark = pViewData->GetMarkData(); 862*cdf0e10cSrcweir if (bColumn) 863*cdf0e10cSrcweir return rMark.IsColumnMarked( nPosX ); 864*cdf0e10cSrcweir else 865*cdf0e10cSrcweir return rMark.IsRowMarked( nPosY ); 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir void __EXPORT ScHeaderFunctionSet::DeselectAtPoint( const Point& /* rPointPixel */ ) 869*cdf0e10cSrcweir { 870*cdf0e10cSrcweir } 871*cdf0e10cSrcweir 872*cdf0e10cSrcweir void __EXPORT ScHeaderFunctionSet::DeselectAll() 873*cdf0e10cSrcweir { 874*cdf0e10cSrcweir pViewData->GetView()->DoneBlockMode( sal_False ); 875*cdf0e10cSrcweir bAnchor = sal_False; 876*cdf0e10cSrcweir } 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir //------------------------------------------------------------------------ 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir ScHeaderSelectionEngine::ScHeaderSelectionEngine( Window* pWindow, ScHeaderFunctionSet* pFuncSet ) : 881*cdf0e10cSrcweir SelectionEngine( pWindow, pFuncSet ) 882*cdf0e10cSrcweir { 883*cdf0e10cSrcweir // Parameter einstellen 884*cdf0e10cSrcweir SetSelectionMode( MULTIPLE_SELECTION ); 885*cdf0e10cSrcweir EnableDrag( sal_False ); 886*cdf0e10cSrcweir } 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir 892