1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2011 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 "scitems.hxx" 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <memory> //auto_ptr 34*cdf0e10cSrcweir #include <editeng/adjitem.hxx> 35*cdf0e10cSrcweir #include <svx/algitem.hxx> 36*cdf0e10cSrcweir #include <svx/dbexch.hrc> 37*cdf0e10cSrcweir #include <editeng/editview.hxx> 38*cdf0e10cSrcweir #include <editeng/editstat.hxx> 39*cdf0e10cSrcweir #include <editeng/flditem.hxx> 40*cdf0e10cSrcweir #include <svx/svdetc.hxx> 41*cdf0e10cSrcweir #include <editeng/editobj.hxx> 42*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 43*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 44*cdf0e10cSrcweir #include <sfx2/docfile.hxx> 45*cdf0e10cSrcweir #include <svl/stritem.hxx> 46*cdf0e10cSrcweir #include <svtools/svlbox.hxx> 47*cdf0e10cSrcweir #include <svtools/svtabbx.hxx> 48*cdf0e10cSrcweir #include <svl/urlbmk.hxx> 49*cdf0e10cSrcweir #include <tools/urlobj.hxx> 50*cdf0e10cSrcweir #include <vcl/cursor.hxx> 51*cdf0e10cSrcweir #include <vcl/sound.hxx> 52*cdf0e10cSrcweir #include <vcl/graph.hxx> 53*cdf0e10cSrcweir #include <vcl/hatch.hxx> 54*cdf0e10cSrcweir #include <sot/formats.hxx> 55*cdf0e10cSrcweir #include <sot/clsids.hxx> 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir #include <svx/svdview.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT) 58*cdf0e10cSrcweir #include <editeng/outliner.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT) 59*cdf0e10cSrcweir #include <svx/svditer.hxx> 60*cdf0e10cSrcweir #include <svx/svdocapt.hxx> 61*cdf0e10cSrcweir #include <svx/svdpagv.hxx> 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir #include <com/sun/star/sheet/DataPilotFieldFilter.hpp> 64*cdf0e10cSrcweir #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> 65*cdf0e10cSrcweir #include <com/sun/star/sheet/DataPilotTableHeaderData.hpp> 66*cdf0e10cSrcweir #include <com/sun/star/sheet/DataPilotTableResultData.hpp> 67*cdf0e10cSrcweir #include <com/sun/star/sheet/DataPilotTablePositionData.hpp> 68*cdf0e10cSrcweir #include <com/sun/star/sheet/DataPilotTablePositionType.hpp> 69*cdf0e10cSrcweir #include <com/sun/star/sheet/MemberResultFlags.hpp> 70*cdf0e10cSrcweir #include <com/sun/star/awt/KeyModifier.hpp> 71*cdf0e10cSrcweir #include <com/sun/star/awt/MouseButton.hpp> 72*cdf0e10cSrcweir #include <com/sun/star/script/vba/VBAEventId.hpp> 73*cdf0e10cSrcweir #include <com/sun/star/script/vba/XVBAEventProcessor.hpp> 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir #include "gridwin.hxx" 76*cdf0e10cSrcweir #include "tabvwsh.hxx" 77*cdf0e10cSrcweir #include "docsh.hxx" 78*cdf0e10cSrcweir #include "viewdata.hxx" 79*cdf0e10cSrcweir #include "tabview.hxx" 80*cdf0e10cSrcweir #include "select.hxx" 81*cdf0e10cSrcweir #include "scmod.hxx" 82*cdf0e10cSrcweir #include "document.hxx" 83*cdf0e10cSrcweir #include "attrib.hxx" 84*cdf0e10cSrcweir #include "dbcolect.hxx" 85*cdf0e10cSrcweir #include "stlpool.hxx" 86*cdf0e10cSrcweir #include "printfun.hxx" 87*cdf0e10cSrcweir #include "cbutton.hxx" 88*cdf0e10cSrcweir #include "sc.hrc" 89*cdf0e10cSrcweir #include "globstr.hrc" 90*cdf0e10cSrcweir #include "editutil.hxx" 91*cdf0e10cSrcweir #include "scresid.hxx" 92*cdf0e10cSrcweir #include "inputhdl.hxx" 93*cdf0e10cSrcweir #include "uiitems.hxx" // Filter-Dialog - auslagern !!! 94*cdf0e10cSrcweir #include "filtdlg.hxx" 95*cdf0e10cSrcweir #include "impex.hxx" // Sylk-ID fuer CB 96*cdf0e10cSrcweir #include "cell.hxx" // fuer Edit-Felder 97*cdf0e10cSrcweir #include "patattr.hxx" 98*cdf0e10cSrcweir #include "notemark.hxx" 99*cdf0e10cSrcweir #include "rfindlst.hxx" 100*cdf0e10cSrcweir #include "docpool.hxx" 101*cdf0e10cSrcweir #include "output.hxx" 102*cdf0e10cSrcweir #include "docfunc.hxx" 103*cdf0e10cSrcweir #include "dbdocfun.hxx" 104*cdf0e10cSrcweir #include "dpobject.hxx" 105*cdf0e10cSrcweir #include "dpoutput.hxx" 106*cdf0e10cSrcweir #include "transobj.hxx" 107*cdf0e10cSrcweir #include "drwtrans.hxx" 108*cdf0e10cSrcweir #include "seltrans.hxx" 109*cdf0e10cSrcweir #include "sizedev.hxx" 110*cdf0e10cSrcweir #include "AccessibilityHints.hxx" 111*cdf0e10cSrcweir #include "dpsave.hxx" 112*cdf0e10cSrcweir #include "viewuno.hxx" 113*cdf0e10cSrcweir #include "compiler.hxx" 114*cdf0e10cSrcweir #include "editable.hxx" 115*cdf0e10cSrcweir #include "fillinfo.hxx" 116*cdf0e10cSrcweir #include "scitems.hxx" 117*cdf0e10cSrcweir #include "userdat.hxx" 118*cdf0e10cSrcweir #include "drwlayer.hxx" 119*cdf0e10cSrcweir #include "attrib.hxx" 120*cdf0e10cSrcweir #include "validat.hxx" 121*cdf0e10cSrcweir #include "tabprotection.hxx" 122*cdf0e10cSrcweir #include "postit.hxx" 123*cdf0e10cSrcweir #include "dpcontrol.hxx" 124*cdf0e10cSrcweir #include "cellsuno.hxx" 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir #include "drawview.hxx" 127*cdf0e10cSrcweir #include <svx/sdrpagewindow.hxx> 128*cdf0e10cSrcweir #include <svx/sdr/overlay/overlaymanager.hxx> 129*cdf0e10cSrcweir #include <vcl/svapp.hxx> 130*cdf0e10cSrcweir #include <svx/sdr/overlay/overlayselection.hxx> 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir using namespace com::sun::star; 133*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 134*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir const sal_uInt8 SC_NESTEDBUTTON_NONE = 0; 137*cdf0e10cSrcweir const sal_uInt8 SC_NESTEDBUTTON_DOWN = 1; 138*cdf0e10cSrcweir const sal_uInt8 SC_NESTEDBUTTON_UP = 2; 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir #define SC_AUTOFILTER_ALL 0 141*cdf0e10cSrcweir #define SC_AUTOFILTER_TOP10 1 142*cdf0e10cSrcweir #define SC_AUTOFILTER_CUSTOM 2 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir // Modi fuer die FilterListBox 145*cdf0e10cSrcweir enum ScFilterBoxMode 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir SC_FILTERBOX_FILTER, 148*cdf0e10cSrcweir SC_FILTERBOX_DATASELECT, 149*cdf0e10cSrcweir SC_FILTERBOX_SCENARIO, 150*cdf0e10cSrcweir SC_FILTERBOX_PAGEFIELD 151*cdf0e10cSrcweir }; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir extern SfxViewShell* pScActiveViewShell; // global.cxx 154*cdf0e10cSrcweir extern sal_uInt16 nScClickMouseModifier; // global.cxx 155*cdf0e10cSrcweir extern sal_uInt16 nScFillModeMouseModifier; // global.cxx 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir #define SC_FILTERLISTBOX_LINES 12 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir // ============================================================================ 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir ScGridWindow::VisibleRange::VisibleRange() : 162*cdf0e10cSrcweir mnCol1(0), mnCol2(MAXCOL), mnRow1(0), mnRow2(MAXROW) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir bool ScGridWindow::VisibleRange::isInside(SCCOL nCol, SCROW nRow) const 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir return mnCol1 <= nCol && nCol <= mnCol2 && mnRow1 <= nRow && nRow <= mnRow2; 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir // ============================================================================ 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir class ScFilterListBox : public ListBox 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir private: 176*cdf0e10cSrcweir ScGridWindow* pGridWin; 177*cdf0e10cSrcweir SCCOL nCol; 178*cdf0e10cSrcweir SCROW nRow; 179*cdf0e10cSrcweir sal_Bool bButtonDown; 180*cdf0e10cSrcweir sal_Bool bInit; 181*cdf0e10cSrcweir sal_Bool bCancelled; 182*cdf0e10cSrcweir sal_Bool bInSelect; 183*cdf0e10cSrcweir bool mbListHasDates; 184*cdf0e10cSrcweir sal_uLong nSel; 185*cdf0e10cSrcweir ScFilterBoxMode eMode; 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir protected: 188*cdf0e10cSrcweir virtual void LoseFocus(); 189*cdf0e10cSrcweir void SelectHdl(); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir public: 192*cdf0e10cSrcweir ScFilterListBox( Window* pParent, ScGridWindow* pGrid, 193*cdf0e10cSrcweir SCCOL nNewCol, SCROW nNewRow, ScFilterBoxMode eNewMode ); 194*cdf0e10cSrcweir ~ScFilterListBox(); 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir virtual long PreNotify( NotifyEvent& rNEvt ); 197*cdf0e10cSrcweir virtual void Select(); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir SCCOL GetCol() const { return nCol; } 200*cdf0e10cSrcweir SCROW GetRow() const { return nRow; } 201*cdf0e10cSrcweir ScFilterBoxMode GetMode() const { return eMode; } 202*cdf0e10cSrcweir sal_Bool IsDataSelect() const { return (eMode == SC_FILTERBOX_DATASELECT); } 203*cdf0e10cSrcweir void EndInit(); 204*cdf0e10cSrcweir sal_Bool IsInInit() const { return bInit; } 205*cdf0e10cSrcweir void SetCancelled() { bCancelled = sal_True; } 206*cdf0e10cSrcweir sal_Bool IsInSelect() const { return bInSelect; } 207*cdf0e10cSrcweir void SetListHasDates(bool b) { mbListHasDates = b; } 208*cdf0e10cSrcweir bool HasDates() const { return mbListHasDates; } 209*cdf0e10cSrcweir }; 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir //------------------------------------------------------------------- 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir // ListBox in einem FloatingWindow (pParent) 214*cdf0e10cSrcweir ScFilterListBox::ScFilterListBox( Window* pParent, ScGridWindow* pGrid, 215*cdf0e10cSrcweir SCCOL nNewCol, SCROW nNewRow, ScFilterBoxMode eNewMode ) : 216*cdf0e10cSrcweir ListBox( pParent, WB_AUTOHSCROLL ), 217*cdf0e10cSrcweir pGridWin( pGrid ), 218*cdf0e10cSrcweir nCol( nNewCol ), 219*cdf0e10cSrcweir nRow( nNewRow ), 220*cdf0e10cSrcweir bButtonDown( sal_False ), 221*cdf0e10cSrcweir bInit( sal_True ), 222*cdf0e10cSrcweir bCancelled( sal_False ), 223*cdf0e10cSrcweir bInSelect( sal_False ), 224*cdf0e10cSrcweir mbListHasDates(false), 225*cdf0e10cSrcweir nSel( 0 ), 226*cdf0e10cSrcweir eMode( eNewMode ) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir __EXPORT ScFilterListBox::~ScFilterListBox() 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir if (IsMouseCaptured()) 233*cdf0e10cSrcweir ReleaseMouse(); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir void ScFilterListBox::EndInit() 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir sal_uInt16 nPos = GetSelectEntryPos(); 239*cdf0e10cSrcweir if ( LISTBOX_ENTRY_NOTFOUND == nPos ) 240*cdf0e10cSrcweir nSel = 0; 241*cdf0e10cSrcweir else 242*cdf0e10cSrcweir nSel = nPos; 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir bInit = sal_False; 245*cdf0e10cSrcweir } 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir void __EXPORT ScFilterListBox::LoseFocus() 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir #ifndef UNX 250*cdf0e10cSrcweir Hide(); 251*cdf0e10cSrcweir #endif 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir // ----------------------------------------------------------------------- 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir long ScFilterListBox::PreNotify( NotifyEvent& rNEvt ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir long nDone = 0; 259*cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_KEYINPUT ) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir KeyEvent aKeyEvt = *rNEvt.GetKeyEvent(); 262*cdf0e10cSrcweir KeyCode aCode = aKeyEvt.GetKeyCode(); 263*cdf0e10cSrcweir if ( !aCode.GetModifier() ) // ohne alle Modifiers 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir sal_uInt16 nKey = aCode.GetCode(); 266*cdf0e10cSrcweir if ( nKey == KEY_RETURN ) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir SelectHdl(); // auswaehlen 269*cdf0e10cSrcweir nDone = 1; 270*cdf0e10cSrcweir } 271*cdf0e10cSrcweir else if ( nKey == KEY_ESCAPE ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir pGridWin->ClickExtern(); // loescht die List-Box !!! 274*cdf0e10cSrcweir nDone = 1; 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir return nDone ? nDone : ListBox::PreNotify( rNEvt ); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir void __EXPORT ScFilterListBox::Select() 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir ListBox::Select(); 285*cdf0e10cSrcweir SelectHdl(); 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir void __EXPORT ScFilterListBox::SelectHdl() 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir if ( !IsTravelSelect() && !bInit && !bCancelled ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir sal_uInt16 nPos = GetSelectEntryPos(); 293*cdf0e10cSrcweir if ( LISTBOX_ENTRY_NOTFOUND != nPos ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir nSel = nPos; 296*cdf0e10cSrcweir if (!bButtonDown) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir // #i81298# set bInSelect flag, so the box isn't deleted from modifications within FilterSelect 299*cdf0e10cSrcweir bInSelect = sal_True; 300*cdf0e10cSrcweir pGridWin->FilterSelect( nSel ); 301*cdf0e10cSrcweir bInSelect = sal_False; 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir // ============================================================================ 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir // use a System floating window for the above filter listbox 310*cdf0e10cSrcweir class ScFilterFloatingWindow : public FloatingWindow 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir public: 313*cdf0e10cSrcweir ScFilterFloatingWindow( Window* pParent, WinBits nStyle = WB_STDFLOATWIN ); 314*cdf0e10cSrcweir virtual ~ScFilterFloatingWindow(); 315*cdf0e10cSrcweir // required for System FloatingWindows that will not process KeyInput by themselves 316*cdf0e10cSrcweir virtual Window* GetPreferredKeyInputWindow(); 317*cdf0e10cSrcweir }; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir ScFilterFloatingWindow::ScFilterFloatingWindow( Window* pParent, WinBits nStyle ) : 320*cdf0e10cSrcweir FloatingWindow( pParent, nStyle|WB_SYSTEMWINDOW ) // make it a system floater 321*cdf0e10cSrcweir {} 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir ScFilterFloatingWindow::~ScFilterFloatingWindow() 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir EndPopupMode(); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir Window* ScFilterFloatingWindow::GetPreferredKeyInputWindow() 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir // redirect keyinput in the child window 331*cdf0e10cSrcweir return GetWindow(WINDOW_FIRSTCHILD) ? GetWindow(WINDOW_FIRSTCHILD)->GetPreferredKeyInputWindow() : NULL; // will be the FilterBox 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir // ============================================================================ 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir sal_Bool lcl_IsEditableMatrix( ScDocument* pDoc, const ScRange& rRange ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir // wenn es ein editierbarer Bereich ist, und rechts unten eine Matrix-Zelle 339*cdf0e10cSrcweir // mit Origin links oben liegt, enthaelt der Bereich genau die Matrix. 340*cdf0e10cSrcweir //! Direkt die MatrixEdges Funktionen von der Column herausreichen ??? 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir if ( !pDoc->IsBlockEditable( rRange.aStart.Tab(), rRange.aStart.Col(),rRange.aStart.Row(), 343*cdf0e10cSrcweir rRange.aEnd.Col(),rRange.aEnd.Row() ) ) 344*cdf0e10cSrcweir return sal_False; 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir ScAddress aPos; 347*cdf0e10cSrcweir const ScBaseCell* pCell = pDoc->GetCell( rRange.aEnd ); 348*cdf0e10cSrcweir return ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA && 349*cdf0e10cSrcweir ((ScFormulaCell*)pCell)->GetMatrixOrigin(aPos) && aPos == rRange.aStart ); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pDrDoc, const Point& rPos, ScViewData* pViewData ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir if (!pView && !pPV && !pDrDoc && !pViewData) 356*cdf0e10cSrcweir return; 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir ScDocument& rDoc = *pViewData->GetDocument(); 359*cdf0e10cSrcweir ScAddress aCellPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ); 360*cdf0e10cSrcweir ScPostIt* pNote = rDoc.GetNote( aCellPos ); 361*cdf0e10cSrcweir SdrObject* pObj = pNote ? pNote->GetCaption() : 0; 362*cdf0e10cSrcweir if( pObj && pObj->GetLogicRect().IsInside( rPos ) && ScDrawLayer::IsNoteCaption( pObj ) ) 363*cdf0e10cSrcweir { 364*cdf0e10cSrcweir const ScProtectionAttr* pProtAttr = static_cast< const ScProtectionAttr* > (rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_PROTECTION ) ); 365*cdf0e10cSrcweir bool bProtectAttr = pProtAttr->GetProtection() || pProtAttr->GetHideCell() ; 366*cdf0e10cSrcweir bool bProtectDoc = rDoc.IsTabProtected( aCellPos.Tab() ) || pViewData->GetSfxDocShell()->IsReadOnly() ; 367*cdf0e10cSrcweir // unlock internal layer (if not protected), will be relocked in ScDrawView::MarkListHasChanged() 368*cdf0e10cSrcweir pView->LockInternalLayer( bProtectDoc && bProtectAttr ); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell ) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir sal_Bool bFound = sal_False; 375*cdf0e10cSrcweir do 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir pDoc->GetCell( rPosX, rPosY, nTab, rpCell ); 378*cdf0e10cSrcweir if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir if ( rPosX <= 0 ) 381*cdf0e10cSrcweir return sal_False; // alles leer bis links 382*cdf0e10cSrcweir else 383*cdf0e10cSrcweir --rPosX; // weitersuchen 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir else if ( rpCell->GetCellType() == CELLTYPE_EDIT) 386*cdf0e10cSrcweir bFound = sal_True; 387*cdf0e10cSrcweir else if (rpCell->GetCellType() == CELLTYPE_FORMULA && 388*cdf0e10cSrcweir static_cast<ScFormulaCell*>(rpCell)->IsHyperLinkCell()) 389*cdf0e10cSrcweir bFound = sal_True; 390*cdf0e10cSrcweir else 391*cdf0e10cSrcweir return sal_False; // andere Zelle 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir while ( !bFound ); 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir return bFound; 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir // --------------------------------------------------------------------------- 399*cdf0e10cSrcweir // WB_DIALOGCONTROL noetig fuer UNO-Controls 400*cdf0e10cSrcweir ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos ) 401*cdf0e10cSrcweir : Window( pParent, WB_CLIPCHILDREN | WB_DIALOGCONTROL ), 402*cdf0e10cSrcweir DropTargetHelper( this ), 403*cdf0e10cSrcweir DragSourceHelper( this ), 404*cdf0e10cSrcweir mpOOCursors( NULL ), 405*cdf0e10cSrcweir mpOOSelection( NULL ), 406*cdf0e10cSrcweir mpOOAutoFill( NULL ), 407*cdf0e10cSrcweir mpOODragRect( NULL ), 408*cdf0e10cSrcweir mpOOHeader( NULL ), 409*cdf0e10cSrcweir mpOOShrink( NULL ), 410*cdf0e10cSrcweir mpAutoFillRect(static_cast<Rectangle*>(NULL)), 411*cdf0e10cSrcweir pViewData( pData ), 412*cdf0e10cSrcweir eWhich( eWhichPos ), 413*cdf0e10cSrcweir pNoteMarker( NULL ), 414*cdf0e10cSrcweir pFilterBox( NULL ), 415*cdf0e10cSrcweir pFilterFloat( NULL ), 416*cdf0e10cSrcweir mpDPFieldPopup(NULL), 417*cdf0e10cSrcweir mpFilterButton(NULL), 418*cdf0e10cSrcweir nCursorHideCount( 0 ), 419*cdf0e10cSrcweir bMarking( sal_False ), 420*cdf0e10cSrcweir nButtonDown( 0 ), 421*cdf0e10cSrcweir bEEMouse( sal_False ), 422*cdf0e10cSrcweir nMouseStatus( SC_GM_NONE ), 423*cdf0e10cSrcweir nNestedButtonState( SC_NESTEDBUTTON_NONE ), 424*cdf0e10cSrcweir bDPMouse( sal_False ), 425*cdf0e10cSrcweir bRFMouse( sal_False ), 426*cdf0e10cSrcweir nPagebreakMouse( SC_PD_NONE ), 427*cdf0e10cSrcweir bPagebreakDrawn( sal_False ), 428*cdf0e10cSrcweir nPageScript( 0 ), 429*cdf0e10cSrcweir bDragRect( sal_False ), 430*cdf0e10cSrcweir meDragInsertMode( INS_NONE ), 431*cdf0e10cSrcweir nCurrentPointer( 0 ), 432*cdf0e10cSrcweir bIsInScroll( sal_False ), 433*cdf0e10cSrcweir bIsInPaint( sal_False ), 434*cdf0e10cSrcweir aComboButton( this ), 435*cdf0e10cSrcweir aCurMousePos( 0,0 ), 436*cdf0e10cSrcweir nPaintCount( 0 ), 437*cdf0e10cSrcweir bNeedsRepaint( sal_False ), 438*cdf0e10cSrcweir bAutoMarkVisible( sal_False ), 439*cdf0e10cSrcweir bListValButton( sal_False ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir switch(eWhich) 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir case SC_SPLIT_TOPLEFT: 444*cdf0e10cSrcweir eHWhich = SC_SPLIT_LEFT; 445*cdf0e10cSrcweir eVWhich = SC_SPLIT_TOP; 446*cdf0e10cSrcweir break; 447*cdf0e10cSrcweir case SC_SPLIT_TOPRIGHT: 448*cdf0e10cSrcweir eHWhich = SC_SPLIT_RIGHT; 449*cdf0e10cSrcweir eVWhich = SC_SPLIT_TOP; 450*cdf0e10cSrcweir break; 451*cdf0e10cSrcweir case SC_SPLIT_BOTTOMLEFT: 452*cdf0e10cSrcweir eHWhich = SC_SPLIT_LEFT; 453*cdf0e10cSrcweir eVWhich = SC_SPLIT_BOTTOM; 454*cdf0e10cSrcweir break; 455*cdf0e10cSrcweir case SC_SPLIT_BOTTOMRIGHT: 456*cdf0e10cSrcweir eHWhich = SC_SPLIT_RIGHT; 457*cdf0e10cSrcweir eVWhich = SC_SPLIT_BOTTOM; 458*cdf0e10cSrcweir break; 459*cdf0e10cSrcweir default: 460*cdf0e10cSrcweir DBG_ERROR("GridWindow: falsche Position"); 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir SetBackground(); 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir SetMapMode(pViewData->GetLogicMode(eWhich)); 466*cdf0e10cSrcweir // EnableDrop(); 467*cdf0e10cSrcweir EnableChildTransparentMode(); 468*cdf0e10cSrcweir SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS ); 469*cdf0e10cSrcweir 470*cdf0e10cSrcweir SetHelpId( HID_SC_WIN_GRIDWIN ); 471*cdf0e10cSrcweir SetUniqueId( HID_SC_WIN_GRIDWIN ); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() ); 474*cdf0e10cSrcweir EnableRTL( sal_False ); 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir __EXPORT ScGridWindow::~ScGridWindow() 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir // #114409# 480*cdf0e10cSrcweir ImpDestroyOverlayObjects(); 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir delete pFilterBox; 483*cdf0e10cSrcweir delete pFilterFloat; 484*cdf0e10cSrcweir delete pNoteMarker; 485*cdf0e10cSrcweir } 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir void __EXPORT ScGridWindow::Resize( const Size& ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir // gar nix 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir void ScGridWindow::ClickExtern() 493*cdf0e10cSrcweir { 494*cdf0e10cSrcweir do 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir // #i81298# don't delete the filter box when called from its select handler 497*cdf0e10cSrcweir // (possible through row header size update) 498*cdf0e10cSrcweir // #i84277# when initializing the filter box, a Basic error can deactivate the view 499*cdf0e10cSrcweir if ( pFilterBox && ( pFilterBox->IsInSelect() || pFilterBox->IsInInit() ) ) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir break; 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir 504*cdf0e10cSrcweir DELETEZ(pFilterBox); 505*cdf0e10cSrcweir DELETEZ(pFilterFloat); 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir while (false); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir if (mpDPFieldPopup.get()) 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir mpDPFieldPopup->close(false); 512*cdf0e10cSrcweir mpDPFieldPopup.reset(); 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir IMPL_LINK( ScGridWindow, PopupModeEndHdl, FloatingWindow*, EMPTYARG ) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir if (pFilterBox) 519*cdf0e10cSrcweir pFilterBox->SetCancelled(); // nicht mehr auswaehlen 520*cdf0e10cSrcweir GrabFocus(); 521*cdf0e10cSrcweir return 0; 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir IMPL_LINK( ScGridWindow, PopupSpellingHdl, SpellCallbackInfo*, pInfo ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir if( pInfo->nCommand == SPELLCMD_STARTSPELLDLG ) 527*cdf0e10cSrcweir pViewData->GetDispatcher().Execute( SID_SPELL_DIALOG, SFX_CALLMODE_ASYNCHRON ); 528*cdf0e10cSrcweir return 0; 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir void ScGridWindow::ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSelection, const String& rStr ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir //! gridwin2 ? 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 536*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 537*cdf0e10cSrcweir ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab); 538*cdf0e10cSrcweir if ( pDPObj && nCol > 0 ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir // look for the dimension header left of the drop-down arrow 541*cdf0e10cSrcweir sal_uInt16 nOrient = sheet::DataPilotFieldOrientation_HIDDEN; 542*cdf0e10cSrcweir long nField = pDPObj->GetHeaderDim( ScAddress( nCol-1, nRow, nTab ), nOrient ); 543*cdf0e10cSrcweir if ( nField >= 0 && nOrient == sheet::DataPilotFieldOrientation_PAGE ) 544*cdf0e10cSrcweir { 545*cdf0e10cSrcweir ScDPSaveData aSaveData( *pDPObj->GetSaveData() ); 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir sal_Bool bIsDataLayout; 548*cdf0e10cSrcweir String aDimName = pDPObj->GetDimName( nField, bIsDataLayout ); 549*cdf0e10cSrcweir if ( !bIsDataLayout ) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir ScDPSaveDimension* pDim = aSaveData.GetDimensionByName(aDimName); 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir if ( bHasSelection ) 554*cdf0e10cSrcweir pDim->SetCurrentPage( &rStr ); 555*cdf0e10cSrcweir else 556*cdf0e10cSrcweir pDim->SetCurrentPage( NULL ); 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir ScDPObject aNewObj( *pDPObj ); 559*cdf0e10cSrcweir aNewObj.SetSaveData( aSaveData ); 560*cdf0e10cSrcweir ScDBDocFunc aFunc( *pViewData->GetDocShell() ); 561*cdf0e10cSrcweir aFunc.DataPilotUpdate( pDPObj, &aNewObj, sal_True, sal_False ); 562*cdf0e10cSrcweir pViewData->GetView()->CursorPosChanged(); // shells may be switched 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir } 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir void ScGridWindow::LaunchPageFieldMenu( SCCOL nCol, SCROW nRow ) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir //! merge position/size handling with DoAutoFilterMenue 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir delete pFilterBox; 573*cdf0e10cSrcweir delete pFilterFloat; 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir sal_uInt16 i; 576*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 577*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 578*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir long nSizeX = 0; 581*cdf0e10cSrcweir long nSizeY = 0; 582*cdf0e10cSrcweir long nHeight = 0; 583*cdf0e10cSrcweir pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY ); 584*cdf0e10cSrcweir Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich ); 585*cdf0e10cSrcweir if ( bLayoutRTL ) 586*cdf0e10cSrcweir aPos.X() -= nSizeX; 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) ); 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir aPos.X() -= 1; 591*cdf0e10cSrcweir aPos.Y() += nSizeY - 1; 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir pFilterFloat = new ScFilterFloatingWindow( this, WinBits(WB_BORDER) ); // not resizable etc. 594*cdf0e10cSrcweir pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) ); 595*cdf0e10cSrcweir pFilterBox = new ScFilterListBox( pFilterFloat, this, nCol, nRow, SC_FILTERBOX_PAGEFIELD ); 596*cdf0e10cSrcweir if ( bLayoutRTL ) 597*cdf0e10cSrcweir pFilterBox->EnableMirroring(); 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir nSizeX += 1; 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() ); 603*cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL ); 604*cdf0e10cSrcweir 605*cdf0e10cSrcweir nHeight = GetTextHeight(); 606*cdf0e10cSrcweir nHeight *= SC_FILTERLISTBOX_LINES; 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir SetMapMode( aOldMode ); 609*cdf0e10cSrcweir SetFont( aOldFont ); 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir // SetSize comes later 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir TypedScStrCollection aStrings( 128, 128 ); 615*cdf0e10cSrcweir 616*cdf0e10cSrcweir // get list box entries and selection 617*cdf0e10cSrcweir sal_Bool bHasCurrentPage = sal_False; 618*cdf0e10cSrcweir String aCurrentPage; 619*cdf0e10cSrcweir ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab); 620*cdf0e10cSrcweir if ( pDPObj && nCol > 0 ) 621*cdf0e10cSrcweir { 622*cdf0e10cSrcweir // look for the dimension header left of the drop-down arrow 623*cdf0e10cSrcweir sal_uInt16 nOrient = sheet::DataPilotFieldOrientation_HIDDEN; 624*cdf0e10cSrcweir long nField = pDPObj->GetHeaderDim( ScAddress( nCol-1, nRow, nTab ), nOrient ); 625*cdf0e10cSrcweir if ( nField >= 0 && nOrient == sheet::DataPilotFieldOrientation_PAGE ) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir pDPObj->FillPageList( aStrings, nField ); 628*cdf0e10cSrcweir 629*cdf0e10cSrcweir // get current page from SaveData 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir ScDPSaveData* pSaveData = pDPObj->GetSaveData(); 632*cdf0e10cSrcweir sal_Bool bIsDataLayout; 633*cdf0e10cSrcweir String aDimName = pDPObj->GetDimName( nField, bIsDataLayout ); 634*cdf0e10cSrcweir if ( pSaveData && !bIsDataLayout ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(aDimName); 637*cdf0e10cSrcweir if ( pDim && pDim->HasCurrentPage() ) 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir aCurrentPage = pDim->GetCurrentPage(); 640*cdf0e10cSrcweir bHasCurrentPage = sal_True; 641*cdf0e10cSrcweir } 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir } 645*cdf0e10cSrcweir 646*cdf0e10cSrcweir // include all entry widths for the size of the drop-down 647*cdf0e10cSrcweir long nMaxText = 0; 648*cdf0e10cSrcweir sal_uInt16 nCount = aStrings.GetCount(); 649*cdf0e10cSrcweir for (i=0; i<nCount; i++) 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir TypedStrData* pData = aStrings[i]; 652*cdf0e10cSrcweir long nTextWidth = pFilterBox->GetTextWidth( pData->GetString() ); 653*cdf0e10cSrcweir if ( nTextWidth > nMaxText ) 654*cdf0e10cSrcweir nMaxText = nTextWidth; 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir // add scrollbar width if needed (string entries are counted here) 658*cdf0e10cSrcweir // (scrollbar is shown if the box is exactly full?) 659*cdf0e10cSrcweir if ( nCount >= SC_FILTERLISTBOX_LINES ) 660*cdf0e10cSrcweir nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize(); 661*cdf0e10cSrcweir 662*cdf0e10cSrcweir nMaxText += 4; // for borders 663*cdf0e10cSrcweir 664*cdf0e10cSrcweir if ( nMaxText > nSizeX ) 665*cdf0e10cSrcweir nSizeX = nMaxText; // just modify width - starting position is unchanged 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir // adjust position and size to window 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir Size aParentSize = GetParent()->GetOutputSizePixel(); 670*cdf0e10cSrcweir Size aSize( nSizeX, nHeight ); 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir if ( aSize.Height() > aParentSize.Height() ) 673*cdf0e10cSrcweir aSize.Height() = aParentSize.Height(); 674*cdf0e10cSrcweir if ( aPos.Y() + aSize.Height() > aParentSize.Height() ) 675*cdf0e10cSrcweir aPos.Y() = aParentSize.Height() - aSize.Height(); 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir pFilterBox->SetSizePixel( aSize ); 678*cdf0e10cSrcweir pFilterBox->Show(); // Show must be called before SetUpdateMode 679*cdf0e10cSrcweir pFilterBox->SetUpdateMode(sal_False); 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir pFilterFloat->SetOutputSizePixel( aSize ); 682*cdf0e10cSrcweir pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS); 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir // fill the list box 685*cdf0e10cSrcweir sal_Bool bWait = ( nCount > 100 ); 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir if (bWait) 688*cdf0e10cSrcweir EnterWait(); 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir for (i=0; i<nCount; i++) 691*cdf0e10cSrcweir pFilterBox->InsertEntry( aStrings[i]->GetString() ); 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir pFilterBox->SetSeparatorPos( 0 ); 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir if (bWait) 696*cdf0e10cSrcweir LeaveWait(); 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir pFilterBox->SetUpdateMode(sal_True); 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir sal_uInt16 nSelPos = LISTBOX_ENTRY_NOTFOUND; 701*cdf0e10cSrcweir if (bHasCurrentPage) 702*cdf0e10cSrcweir nSelPos = pFilterBox->GetEntryPos( aCurrentPage ); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir if ( nSelPos == LISTBOX_ENTRY_NOTFOUND ) 705*cdf0e10cSrcweir nSelPos = 0; // first entry 706*cdf0e10cSrcweir 707*cdf0e10cSrcweir pFilterBox->GrabFocus(); 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir // call Select after GrabFocus, so the focus rectangle ends up in the right position 710*cdf0e10cSrcweir if ( nSelPos != LISTBOX_ENTRY_NOTFOUND ) 711*cdf0e10cSrcweir pFilterBox->SelectEntryPos( nSelPos ); 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir pFilterBox->EndInit(); 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir nMouseStatus = SC_GM_FILTER; 716*cdf0e10cSrcweir CaptureMouse(); 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir void ScGridWindow::LaunchDPFieldMenu( SCCOL nCol, SCROW nRow ) 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 722*cdf0e10cSrcweir ScDPObject* pDPObj = pViewData->GetDocument()->GetDPAtCursor(nCol, nRow, nTab); 723*cdf0e10cSrcweir if (!pDPObj) 724*cdf0e10cSrcweir return; 725*cdf0e10cSrcweir 726*cdf0e10cSrcweir // Get the geometry of the cell. 727*cdf0e10cSrcweir Point aScrPos = pViewData->GetScrPos(nCol, nRow, eWhich); 728*cdf0e10cSrcweir long nSizeX, nSizeY; 729*cdf0e10cSrcweir pViewData->GetMergeSizePixel(nCol, nRow, nSizeX, nSizeY); 730*cdf0e10cSrcweir Size aScrSize(nSizeX-1, nSizeY-1); 731*cdf0e10cSrcweir 732*cdf0e10cSrcweir DPLaunchFieldPopupMenu(OutputToScreenPixel(aScrPos), aScrSize, ScAddress(nCol, nRow, nTab), pDPObj); 733*cdf0e10cSrcweir } 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir void ScGridWindow::DoScenarioMenue( const ScRange& rScenRange ) 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir delete pFilterBox; 738*cdf0e10cSrcweir delete pFilterFloat; 739*cdf0e10cSrcweir 740*cdf0e10cSrcweir SCCOL nCol = rScenRange.aEnd.Col(); // Zelle unterhalb des Buttons 741*cdf0e10cSrcweir SCROW nRow = rScenRange.aStart.Row(); 742*cdf0e10cSrcweir if (nRow == 0) 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir nRow = rScenRange.aEnd.Row() + 1; // Bereich ganz oben -> Button unterhalb 745*cdf0e10cSrcweir if (nRow>MAXROW) nRow = MAXROW; 746*cdf0e10cSrcweir //! Texthoehe addieren (wenn sie an der View gespeichert ist...) 747*cdf0e10cSrcweir } 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 750*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 751*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir long nSizeX = 0; 754*cdf0e10cSrcweir long nSizeY = 0; 755*cdf0e10cSrcweir long nHeight = 0; 756*cdf0e10cSrcweir pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY ); 757*cdf0e10cSrcweir Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich ); 758*cdf0e10cSrcweir if ( bLayoutRTL ) 759*cdf0e10cSrcweir aPos.X() -= nSizeX; 760*cdf0e10cSrcweir Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) ); 761*cdf0e10cSrcweir aCellRect.Top() -= nSizeY; 762*cdf0e10cSrcweir aCellRect.Bottom() -= nSizeY - 1; 763*cdf0e10cSrcweir // Die ListBox direkt unter der schwarzen Linie auf dem Zellgitter 764*cdf0e10cSrcweir // (wenn die Linie verdeckt wird, sieht es komisch aus...) 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir pFilterFloat = new ScFilterFloatingWindow( this, WinBits(WB_BORDER) ); // nicht resizable etc. 767*cdf0e10cSrcweir pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) ); 768*cdf0e10cSrcweir pFilterBox = new ScFilterListBox( pFilterFloat, this, nCol, nRow, SC_FILTERBOX_SCENARIO ); 769*cdf0e10cSrcweir if ( bLayoutRTL ) 770*cdf0e10cSrcweir pFilterBox->EnableMirroring(); 771*cdf0e10cSrcweir 772*cdf0e10cSrcweir nSizeX += 1; 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() ); 776*cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL ); 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir nHeight = GetTextHeight(); 779*cdf0e10cSrcweir nHeight *= SC_FILTERLISTBOX_LINES; 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir SetMapMode( aOldMode ); 782*cdf0e10cSrcweir SetFont( aOldFont ); 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir // SetSize spaeter 786*cdf0e10cSrcweir /* 787*cdf0e10cSrcweir pFilterBox->SetSelectionMode( SINGLE_SELECTION ); 788*cdf0e10cSrcweir pFilterBox->SetTabs( nFilterBoxTabs, MapUnit( MAP_APPFONT )); 789*cdf0e10cSrcweir pFilterBox->SetTabJustify( 1, bLayoutRTL ? AdjustRight : AdjustLeft ); 790*cdf0e10cSrcweir */ 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir // ParentSize Abfrage fehlt 793*cdf0e10cSrcweir Size aSize( nSizeX, nHeight ); 794*cdf0e10cSrcweir pFilterBox->SetSizePixel( aSize ); 795*cdf0e10cSrcweir pFilterBox->Show(); // Show muss vor SetUpdateMode kommen !!! 796*cdf0e10cSrcweir pFilterBox->SetUpdateMode(sal_False); 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir // SetOutputSizePixel/StartPopupMode erst unten, wenn die Groesse feststeht 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir // Listbox fuellen 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir long nMaxText = 0; 803*cdf0e10cSrcweir String aCurrent; 804*cdf0e10cSrcweir String aTabName; 805*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 806*cdf0e10cSrcweir SCTAB nEntryCount = 0; 807*cdf0e10cSrcweir for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++) 808*cdf0e10cSrcweir { 809*cdf0e10cSrcweir if (pDoc->HasScenarioRange( i, rScenRange )) 810*cdf0e10cSrcweir if (pDoc->GetName( i, aTabName )) 811*cdf0e10cSrcweir { 812*cdf0e10cSrcweir pFilterBox->InsertEntry( aTabName ); 813*cdf0e10cSrcweir if (pDoc->IsActiveScenario(i)) 814*cdf0e10cSrcweir aCurrent = aTabName; 815*cdf0e10cSrcweir long nTextWidth = pFilterBox->GetTextWidth( aTabName ); 816*cdf0e10cSrcweir if ( nTextWidth > nMaxText ) 817*cdf0e10cSrcweir nMaxText = nTextWidth; 818*cdf0e10cSrcweir ++nEntryCount; 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir if (nEntryCount > SC_FILTERLISTBOX_LINES) 822*cdf0e10cSrcweir nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize(); 823*cdf0e10cSrcweir nMaxText += 4; // fuer Rand 824*cdf0e10cSrcweir if ( nMaxText > 300 ) 825*cdf0e10cSrcweir nMaxText = 300; // auch nicht uebertreiben (Pixel) 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir if (nMaxText > nSizeX) // Groesse auf benoetigte Groesse anpassen 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir long nDiff = nMaxText - nSizeX; 830*cdf0e10cSrcweir aSize = Size( nMaxText, nHeight ); 831*cdf0e10cSrcweir pFilterBox->SetSizePixel( aSize ); 832*cdf0e10cSrcweir pFilterFloat->SetOutputSizePixel( aSize ); 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir if ( !bLayoutRTL ) 835*cdf0e10cSrcweir { 836*cdf0e10cSrcweir // also move popup position 837*cdf0e10cSrcweir long nNewX = aCellRect.Left() - nDiff; 838*cdf0e10cSrcweir if ( nNewX < 0 ) 839*cdf0e10cSrcweir nNewX = 0; 840*cdf0e10cSrcweir aCellRect.Left() = nNewX; 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir } 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir pFilterFloat->SetOutputSizePixel( aSize ); 845*cdf0e10cSrcweir pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS ); 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir pFilterBox->SetUpdateMode(sal_True); 848*cdf0e10cSrcweir pFilterBox->GrabFocus(); 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir // Select erst nach GrabFocus, damit das Focus-Rechteck richtig landet 851*cdf0e10cSrcweir //! SvLBoxEntry* pSelect = NULL; 852*cdf0e10cSrcweir sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND; 853*cdf0e10cSrcweir if (aCurrent.Len()) 854*cdf0e10cSrcweir { 855*cdf0e10cSrcweir nPos = pFilterBox->GetEntryPos( aCurrent ); 856*cdf0e10cSrcweir //! pSelect = pFilterBox->GetEntry( nPos ); 857*cdf0e10cSrcweir } 858*cdf0e10cSrcweir if (/*!pSelect*/ LISTBOX_ENTRY_NOTFOUND == nPos && pFilterBox->GetEntryCount() > 0 ) 859*cdf0e10cSrcweir nPos = 0; 860*cdf0e10cSrcweir //! pSelect = pFilterBox->GetEntry(0); // einer sollte immer selektiert sein 861*cdf0e10cSrcweir if (/*pSelect*/ LISTBOX_ENTRY_NOTFOUND != nPos ) 862*cdf0e10cSrcweir pFilterBox->SelectEntryPos(nPos); 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir pFilterBox->EndInit(); 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir // Szenario-Auswahl kommt aus MouseButtonDown: 867*cdf0e10cSrcweir // der naechste MouseMove auf die Filterbox ist wie ein ButtonDown 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir nMouseStatus = SC_GM_FILTER; 870*cdf0e10cSrcweir CaptureMouse(); 871*cdf0e10cSrcweir } 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir void ScGridWindow::DoAutoFilterMenue( SCCOL nCol, SCROW nRow, sal_Bool bDataSelect ) 874*cdf0e10cSrcweir { 875*cdf0e10cSrcweir delete pFilterBox; 876*cdf0e10cSrcweir delete pFilterFloat; 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir sal_uInt16 i; 879*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 880*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 881*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 882*cdf0e10cSrcweir 883*cdf0e10cSrcweir long nSizeX = 0; 884*cdf0e10cSrcweir long nSizeY = 0; 885*cdf0e10cSrcweir long nHeight = 0; 886*cdf0e10cSrcweir pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY ); 887*cdf0e10cSrcweir Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich ); 888*cdf0e10cSrcweir if ( bLayoutRTL ) 889*cdf0e10cSrcweir aPos.X() -= nSizeX; 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) ); 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir aPos.X() -= 1; 894*cdf0e10cSrcweir aPos.Y() += nSizeY - 1; 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir pFilterFloat = new ScFilterFloatingWindow( this, WinBits(WB_BORDER) ); // nicht resizable etc. 897*cdf0e10cSrcweir pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) ); 898*cdf0e10cSrcweir pFilterBox = new ScFilterListBox( 899*cdf0e10cSrcweir pFilterFloat, this, nCol, nRow, bDataSelect ? SC_FILTERBOX_DATASELECT : SC_FILTERBOX_FILTER ); 900*cdf0e10cSrcweir if ( bLayoutRTL ) 901*cdf0e10cSrcweir pFilterBox->EnableMirroring(); 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir nSizeX += 1; 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir { 906*cdf0e10cSrcweir Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() ); 907*cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL ); 908*cdf0e10cSrcweir 909*cdf0e10cSrcweir nHeight = GetTextHeight(); 910*cdf0e10cSrcweir nHeight *= SC_FILTERLISTBOX_LINES; 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir SetMapMode( aOldMode ); 913*cdf0e10cSrcweir SetFont( aOldFont ); 914*cdf0e10cSrcweir } 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir // SetSize spaeter 917*cdf0e10cSrcweir /* 918*cdf0e10cSrcweir pFilterBox->SetSelectionMode( SINGLE_SELECTION ); 919*cdf0e10cSrcweir pFilterBox->SetTabs( nFilterBoxTabs, MapUnit( MAP_APPFONT )); 920*cdf0e10cSrcweir pFilterBox->SetTabJustify( 1, bLayoutRTL ? AdjustRight : AdjustLeft ); 921*cdf0e10cSrcweir */ 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir sal_Bool bEmpty = sal_False; 924*cdf0e10cSrcweir TypedScStrCollection aStrings( 128, 128 ); 925*cdf0e10cSrcweir if ( bDataSelect ) // Auswahl-Liste 926*cdf0e10cSrcweir { 927*cdf0e10cSrcweir // Liste fuellen 928*cdf0e10cSrcweir aStrings.SetCaseSensitive( sal_True ); 929*cdf0e10cSrcweir pDoc->GetDataEntries( nCol, nRow, nTab, aStrings ); 930*cdf0e10cSrcweir if ( aStrings.GetCount() == 0 ) 931*cdf0e10cSrcweir bEmpty = sal_True; 932*cdf0e10cSrcweir } 933*cdf0e10cSrcweir else // AutoFilter 934*cdf0e10cSrcweir { 935*cdf0e10cSrcweir //! wird der Titel ueberhaupt ausgewertet ??? 936*cdf0e10cSrcweir String aString; 937*cdf0e10cSrcweir pDoc->GetString( nCol, nRow, nTab, aString ); 938*cdf0e10cSrcweir pFilterBox->SetText( aString ); 939*cdf0e10cSrcweir 940*cdf0e10cSrcweir long nMaxText = 0; 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir // default entries 943*cdf0e10cSrcweir static const sal_uInt16 nDefIDs[] = { SCSTR_ALLFILTER, SCSTR_TOP10FILTER, SCSTR_STDFILTER }; 944*cdf0e10cSrcweir const sal_uInt16 nDefCount = sizeof(nDefIDs) / sizeof(sal_uInt16); 945*cdf0e10cSrcweir for (i=0; i<nDefCount; i++) 946*cdf0e10cSrcweir { 947*cdf0e10cSrcweir String aEntry( (ScResId) nDefIDs[i] ); 948*cdf0e10cSrcweir pFilterBox->InsertEntry( aEntry ); 949*cdf0e10cSrcweir long nTextWidth = pFilterBox->GetTextWidth( aEntry ); 950*cdf0e10cSrcweir if ( nTextWidth > nMaxText ) 951*cdf0e10cSrcweir nMaxText = nTextWidth; 952*cdf0e10cSrcweir } 953*cdf0e10cSrcweir pFilterBox->SetSeparatorPos( nDefCount - 1 ); 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir // get list entries 956*cdf0e10cSrcweir bool bHasDates = false; 957*cdf0e10cSrcweir pDoc->GetFilterEntries( nCol, nRow, nTab, true, aStrings, bHasDates); 958*cdf0e10cSrcweir pFilterBox->SetListHasDates(bHasDates); 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir // check widths of numerical entries (string entries are not included) 961*cdf0e10cSrcweir // so all numbers are completely visible 962*cdf0e10cSrcweir sal_uInt16 nCount = aStrings.GetCount(); 963*cdf0e10cSrcweir for (i=0; i<nCount; i++) 964*cdf0e10cSrcweir { 965*cdf0e10cSrcweir TypedStrData* pData = aStrings[i]; 966*cdf0e10cSrcweir if ( !pData->IsStrData() ) // only numerical entries 967*cdf0e10cSrcweir { 968*cdf0e10cSrcweir long nTextWidth = pFilterBox->GetTextWidth( pData->GetString() ); 969*cdf0e10cSrcweir if ( nTextWidth > nMaxText ) 970*cdf0e10cSrcweir nMaxText = nTextWidth; 971*cdf0e10cSrcweir } 972*cdf0e10cSrcweir } 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir // add scrollbar width if needed (string entries are counted here) 975*cdf0e10cSrcweir // (scrollbar is shown if the box is exactly full?) 976*cdf0e10cSrcweir if ( nCount + nDefCount >= SC_FILTERLISTBOX_LINES ) 977*cdf0e10cSrcweir nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize(); 978*cdf0e10cSrcweir 979*cdf0e10cSrcweir nMaxText += 4; // for borders 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir if ( nMaxText > nSizeX ) 982*cdf0e10cSrcweir nSizeX = nMaxText; // just modify width - starting position is unchanged 983*cdf0e10cSrcweir } 984*cdf0e10cSrcweir 985*cdf0e10cSrcweir if (!bEmpty) 986*cdf0e10cSrcweir { 987*cdf0e10cSrcweir // Position und Groesse an Fenster anpassen 988*cdf0e10cSrcweir //! vorher Abfrage, ob die Eintraege hineinpassen (Breite) 989*cdf0e10cSrcweir 990*cdf0e10cSrcweir Size aParentSize = GetParent()->GetOutputSizePixel(); 991*cdf0e10cSrcweir Size aSize( nSizeX, nHeight ); 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir if ( aSize.Height() > aParentSize.Height() ) 994*cdf0e10cSrcweir aSize.Height() = aParentSize.Height(); 995*cdf0e10cSrcweir if ( aPos.Y() + aSize.Height() > aParentSize.Height() ) 996*cdf0e10cSrcweir aPos.Y() = aParentSize.Height() - aSize.Height(); 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir pFilterBox->SetSizePixel( aSize ); 999*cdf0e10cSrcweir pFilterBox->Show(); // Show muss vor SetUpdateMode kommen !!! 1000*cdf0e10cSrcweir pFilterBox->SetUpdateMode(sal_False); 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir pFilterFloat->SetOutputSizePixel( aSize ); 1003*cdf0e10cSrcweir pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS); 1004*cdf0e10cSrcweir 1005*cdf0e10cSrcweir // Listbox fuellen 1006*cdf0e10cSrcweir sal_uInt16 nCount = aStrings.GetCount(); 1007*cdf0e10cSrcweir sal_Bool bWait = ( nCount > 100 ); 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir if (bWait) 1010*cdf0e10cSrcweir EnterWait(); 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir for (i=0; i<nCount; i++) 1013*cdf0e10cSrcweir pFilterBox->InsertEntry( aStrings[i]->GetString() ); 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir if (bWait) 1016*cdf0e10cSrcweir LeaveWait(); 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir pFilterBox->SetUpdateMode(sal_True); 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir //! SvLBoxEntry* pSelect = NULL; 1022*cdf0e10cSrcweir sal_uInt16 nSelPos = LISTBOX_ENTRY_NOTFOUND; 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir if (!bDataSelect) // AutoFilter: aktiven Eintrag selektieren 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab ); 1027*cdf0e10cSrcweir if (pDBData) 1028*cdf0e10cSrcweir { 1029*cdf0e10cSrcweir ScQueryParam aParam; 1030*cdf0e10cSrcweir pDBData->GetQueryParam( aParam ); // kann nur MAXQUERY Eintraege ergeben 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir sal_Bool bValid = sal_True; 1033*cdf0e10cSrcweir for (SCSIZE j=0; j<MAXQUERY && bValid; j++) // bisherige Filter-Einstellungen 1034*cdf0e10cSrcweir if (aParam.GetEntry(j).bDoQuery) 1035*cdf0e10cSrcweir { 1036*cdf0e10cSrcweir //! Abfrage mit DrawButtons zusammenfassen! 1037*cdf0e10cSrcweir 1038*cdf0e10cSrcweir ScQueryEntry& rEntry = aParam.GetEntry(j); 1039*cdf0e10cSrcweir if (j>0) 1040*cdf0e10cSrcweir if (rEntry.eConnect != SC_AND) 1041*cdf0e10cSrcweir bValid = sal_False; 1042*cdf0e10cSrcweir if (rEntry.nField == nCol) 1043*cdf0e10cSrcweir { 1044*cdf0e10cSrcweir if (rEntry.eOp == SC_EQUAL) 1045*cdf0e10cSrcweir { 1046*cdf0e10cSrcweir String* pStr = rEntry.pStr; 1047*cdf0e10cSrcweir if (pStr) 1048*cdf0e10cSrcweir { 1049*cdf0e10cSrcweir nSelPos = pFilterBox->GetEntryPos( *pStr ); 1050*cdf0e10cSrcweir //! pSelect = pFilterBox->GetEntry( nPos ); 1051*cdf0e10cSrcweir } 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir else if (rEntry.eOp == SC_TOPVAL && rEntry.pStr && 1054*cdf0e10cSrcweir rEntry.pStr->EqualsAscii("10")) 1055*cdf0e10cSrcweir nSelPos = SC_AUTOFILTER_TOP10; 1056*cdf0e10cSrcweir else 1057*cdf0e10cSrcweir nSelPos = SC_AUTOFILTER_CUSTOM; 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir } 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir if (!bValid) 1062*cdf0e10cSrcweir nSelPos = SC_AUTOFILTER_CUSTOM; 1063*cdf0e10cSrcweir } 1064*cdf0e10cSrcweir } 1065*cdf0e10cSrcweir else 1066*cdf0e10cSrcweir { 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir sal_uLong nIndex = ((SfxUInt32Item*)pDoc->GetAttr( 1069*cdf0e10cSrcweir nCol, nRow, nTab, ATTR_VALIDDATA ))->GetValue(); 1070*cdf0e10cSrcweir if ( nIndex ) 1071*cdf0e10cSrcweir { 1072*cdf0e10cSrcweir const ScValidationData* pData = pDoc->GetValidationEntry( nIndex ); 1073*cdf0e10cSrcweir if (pData) 1074*cdf0e10cSrcweir { 1075*cdf0e10cSrcweir TypedStrData* pNew = NULL; 1076*cdf0e10cSrcweir String aDocStr; 1077*cdf0e10cSrcweir pDoc->GetString( nCol, nRow, nTab, aDocStr ); 1078*cdf0e10cSrcweir if ( pDoc->HasValueData( nCol, nRow, nTab ) ) 1079*cdf0e10cSrcweir { 1080*cdf0e10cSrcweir double fVal = pDoc->GetValue(ScAddress(nCol, nRow, nTab)); 1081*cdf0e10cSrcweir pNew = new TypedStrData( aDocStr, fVal, SC_STRTYPE_VALUE ); 1082*cdf0e10cSrcweir } 1083*cdf0e10cSrcweir else 1084*cdf0e10cSrcweir pNew = new TypedStrData( aDocStr, 0.0, SC_STRTYPE_STANDARD ); 1085*cdf0e10cSrcweir 1086*cdf0e10cSrcweir bool bSortList = ( pData->GetListType() == ValidListType::SORTEDASCENDING); 1087*cdf0e10cSrcweir if ( bSortList ) 1088*cdf0e10cSrcweir { 1089*cdf0e10cSrcweir sal_uInt16 nStrIndex; 1090*cdf0e10cSrcweir if (aStrings.Search(pNew,nStrIndex)) 1091*cdf0e10cSrcweir nSelPos = nStrIndex; 1092*cdf0e10cSrcweir } 1093*cdf0e10cSrcweir else 1094*cdf0e10cSrcweir { 1095*cdf0e10cSrcweir sal_uInt16 nCount = aStrings.GetCount(); 1096*cdf0e10cSrcweir for (i = 0; ((i < nCount) && ( LISTBOX_ENTRY_NOTFOUND == nSelPos)); i++) 1097*cdf0e10cSrcweir { 1098*cdf0e10cSrcweir if ( aStrings.Compare(aStrings[i], pNew)==0 ) 1099*cdf0e10cSrcweir nSelPos = i; 1100*cdf0e10cSrcweir } 1101*cdf0e10cSrcweir } 1102*cdf0e10cSrcweir delete pNew; 1103*cdf0e10cSrcweir } 1104*cdf0e10cSrcweir } 1105*cdf0e10cSrcweir } 1106*cdf0e10cSrcweir 1107*cdf0e10cSrcweir // neu (309): irgendwas muss immer selektiert sein: 1108*cdf0e10cSrcweir if ( LISTBOX_ENTRY_NOTFOUND == nSelPos && pFilterBox->GetEntryCount() > 0 && !bDataSelect) 1109*cdf0e10cSrcweir nSelPos = 0; 1110*cdf0e10cSrcweir 1111*cdf0e10cSrcweir // keine leere Auswahl-Liste anzeigen: 1112*cdf0e10cSrcweir 1113*cdf0e10cSrcweir if ( bEmpty ) 1114*cdf0e10cSrcweir { 1115*cdf0e10cSrcweir DELETEZ(pFilterBox); // war nix 1116*cdf0e10cSrcweir DELETEZ(pFilterFloat); 1117*cdf0e10cSrcweir Sound::Beep(); // bemerkbar machen 1118*cdf0e10cSrcweir } 1119*cdf0e10cSrcweir else 1120*cdf0e10cSrcweir { 1121*cdf0e10cSrcweir // pFilterBox->Show(); // schon vorne 1122*cdf0e10cSrcweir pFilterBox->GrabFocus(); 1123*cdf0e10cSrcweir 1124*cdf0e10cSrcweir // Select erst nach GrabFocus, damit das Focus-Rechteck richtig landet 1125*cdf0e10cSrcweir if ( LISTBOX_ENTRY_NOTFOUND != nSelPos ) 1126*cdf0e10cSrcweir pFilterBox->SelectEntryPos( nSelPos ); 1127*cdf0e10cSrcweir else 1128*cdf0e10cSrcweir { 1129*cdf0e10cSrcweir if (bDataSelect) 1130*cdf0e10cSrcweir pFilterBox->SetNoSelection(); 1131*cdf0e10cSrcweir } 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir pFilterBox->EndInit(); 1134*cdf0e10cSrcweir 1135*cdf0e10cSrcweir if (!bDataSelect) 1136*cdf0e10cSrcweir { 1137*cdf0e10cSrcweir // AutoFilter (aus MouseButtonDown): 1138*cdf0e10cSrcweir // der naechste MouseMove auf die Filterbox ist wie ein ButtonDown 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir nMouseStatus = SC_GM_FILTER; 1141*cdf0e10cSrcweir CaptureMouse(); 1142*cdf0e10cSrcweir } 1143*cdf0e10cSrcweir } 1144*cdf0e10cSrcweir } 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir void ScGridWindow::FilterSelect( sal_uLong nSel ) 1147*cdf0e10cSrcweir { 1148*cdf0e10cSrcweir String aString; 1149*cdf0e10cSrcweir /* 1150*cdf0e10cSrcweir SvLBoxEntry* pEntry = pFilterBox->GetEntry( nSel ); 1151*cdf0e10cSrcweir if (pEntry) 1152*cdf0e10cSrcweir { 1153*cdf0e10cSrcweir SvLBoxString* pStringEntry = (SvLBoxString*) pEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING ); 1154*cdf0e10cSrcweir if ( pStringEntry ) 1155*cdf0e10cSrcweir aString = pStringEntry->GetText(); 1156*cdf0e10cSrcweir } 1157*cdf0e10cSrcweir */ 1158*cdf0e10cSrcweir aString = pFilterBox->GetEntry( static_cast< sal_uInt16 >( nSel ) ); 1159*cdf0e10cSrcweir 1160*cdf0e10cSrcweir SCCOL nCol = pFilterBox->GetCol(); 1161*cdf0e10cSrcweir SCROW nRow = pFilterBox->GetRow(); 1162*cdf0e10cSrcweir switch ( pFilterBox->GetMode() ) 1163*cdf0e10cSrcweir { 1164*cdf0e10cSrcweir case SC_FILTERBOX_DATASELECT: 1165*cdf0e10cSrcweir ExecDataSelect( nCol, nRow, aString ); 1166*cdf0e10cSrcweir break; 1167*cdf0e10cSrcweir case SC_FILTERBOX_FILTER: 1168*cdf0e10cSrcweir ExecFilter( nSel, nCol, nRow, aString, pFilterBox->HasDates() ); 1169*cdf0e10cSrcweir break; 1170*cdf0e10cSrcweir case SC_FILTERBOX_SCENARIO: 1171*cdf0e10cSrcweir pViewData->GetView()->UseScenario( aString ); 1172*cdf0e10cSrcweir break; 1173*cdf0e10cSrcweir case SC_FILTERBOX_PAGEFIELD: 1174*cdf0e10cSrcweir // first entry is "all" 1175*cdf0e10cSrcweir ExecPageFieldSelect( nCol, nRow, (nSel != 0), aString ); 1176*cdf0e10cSrcweir break; 1177*cdf0e10cSrcweir } 1178*cdf0e10cSrcweir 1179*cdf0e10cSrcweir if (pFilterFloat) 1180*cdf0e10cSrcweir pFilterFloat->EndPopupMode(); 1181*cdf0e10cSrcweir 1182*cdf0e10cSrcweir GrabFocus(); // unter OS/2 stimmt der Focus sonst nicht 1183*cdf0e10cSrcweir } 1184*cdf0e10cSrcweir 1185*cdf0e10cSrcweir void ScGridWindow::ExecDataSelect( SCCOL nCol, SCROW nRow, const String& rStr ) 1186*cdf0e10cSrcweir { 1187*cdf0e10cSrcweir if ( rStr.Len() ) 1188*cdf0e10cSrcweir { 1189*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 1190*cdf0e10cSrcweir ScViewFunc* pView = pViewData->GetView(); 1191*cdf0e10cSrcweir pView->EnterData( nCol, nRow, nTab, rStr ); 1192*cdf0e10cSrcweir 1193*cdf0e10cSrcweir // #i52307# CellContentChanged is not in EnterData so it isn't called twice 1194*cdf0e10cSrcweir // if the cursor is moved afterwards. 1195*cdf0e10cSrcweir pView->CellContentChanged(); 1196*cdf0e10cSrcweir } 1197*cdf0e10cSrcweir } 1198*cdf0e10cSrcweir 1199*cdf0e10cSrcweir void ScGridWindow::ExecFilter( sal_uLong nSel, 1200*cdf0e10cSrcweir SCCOL nCol, SCROW nRow, 1201*cdf0e10cSrcweir const String& aValue, bool bCheckForDates ) 1202*cdf0e10cSrcweir { 1203*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 1204*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 1205*cdf0e10cSrcweir 1206*cdf0e10cSrcweir ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab ); 1207*cdf0e10cSrcweir if (pDBData) 1208*cdf0e10cSrcweir { 1209*cdf0e10cSrcweir ScQueryParam aParam; 1210*cdf0e10cSrcweir pDBData->GetQueryParam( aParam ); // kann nur MAXQUERY Eintraege ergeben 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir if (SC_AUTOFILTER_CUSTOM == nSel) 1213*cdf0e10cSrcweir { 1214*cdf0e10cSrcweir SCTAB nAreaTab; 1215*cdf0e10cSrcweir SCCOL nStartCol; 1216*cdf0e10cSrcweir SCROW nStartRow; 1217*cdf0e10cSrcweir SCCOL nEndCol; 1218*cdf0e10cSrcweir SCROW nEndRow; 1219*cdf0e10cSrcweir pDBData->GetArea( nAreaTab, nStartCol,nStartRow,nEndCol,nEndRow ); 1220*cdf0e10cSrcweir pViewData->GetView()->MarkRange( ScRange( nStartCol,nStartRow,nAreaTab,nEndCol,nEndRow,nAreaTab)); 1221*cdf0e10cSrcweir pViewData->GetView()->SetCursor(nCol,nRow); //! auch ueber Slot ?? 1222*cdf0e10cSrcweir pViewData->GetDispatcher().Execute( SID_FILTER, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir else 1225*cdf0e10cSrcweir { 1226*cdf0e10cSrcweir sal_Bool bDeleteOld = sal_False; 1227*cdf0e10cSrcweir SCSIZE nQueryPos = 0; 1228*cdf0e10cSrcweir sal_Bool bFound = sal_False; 1229*cdf0e10cSrcweir if (!aParam.bInplace) 1230*cdf0e10cSrcweir bDeleteOld = sal_True; 1231*cdf0e10cSrcweir if (aParam.bRegExp) 1232*cdf0e10cSrcweir bDeleteOld = sal_True; 1233*cdf0e10cSrcweir for (SCSIZE i=0; i<MAXQUERY && !bDeleteOld; i++) // bisherige Filter-Einstellungen 1234*cdf0e10cSrcweir if (aParam.GetEntry(i).bDoQuery) 1235*cdf0e10cSrcweir { 1236*cdf0e10cSrcweir //! Abfrage mit DrawButtons zusammenfassen! 1237*cdf0e10cSrcweir 1238*cdf0e10cSrcweir ScQueryEntry& rEntry = aParam.GetEntry(i); 1239*cdf0e10cSrcweir if (i>0) 1240*cdf0e10cSrcweir if (rEntry.eConnect != SC_AND) 1241*cdf0e10cSrcweir bDeleteOld = sal_True; 1242*cdf0e10cSrcweir 1243*cdf0e10cSrcweir if (rEntry.nField == nCol) 1244*cdf0e10cSrcweir { 1245*cdf0e10cSrcweir if (bFound) // diese Spalte zweimal? 1246*cdf0e10cSrcweir bDeleteOld = sal_True; 1247*cdf0e10cSrcweir nQueryPos = i; 1248*cdf0e10cSrcweir bFound = sal_True; 1249*cdf0e10cSrcweir } 1250*cdf0e10cSrcweir if (!bFound) 1251*cdf0e10cSrcweir nQueryPos = i + 1; 1252*cdf0e10cSrcweir } 1253*cdf0e10cSrcweir 1254*cdf0e10cSrcweir if (bDeleteOld) 1255*cdf0e10cSrcweir { 1256*cdf0e10cSrcweir SCSIZE nEC = aParam.GetEntryCount(); 1257*cdf0e10cSrcweir for (SCSIZE i=0; i<nEC; i++) 1258*cdf0e10cSrcweir aParam.GetEntry(i).Clear(); 1259*cdf0e10cSrcweir nQueryPos = 0; 1260*cdf0e10cSrcweir aParam.bInplace = sal_True; 1261*cdf0e10cSrcweir aParam.bRegExp = sal_False; 1262*cdf0e10cSrcweir } 1263*cdf0e10cSrcweir 1264*cdf0e10cSrcweir if ( nQueryPos < MAXQUERY || SC_AUTOFILTER_ALL == nSel ) // loeschen geht immer 1265*cdf0e10cSrcweir { 1266*cdf0e10cSrcweir if (nSel) 1267*cdf0e10cSrcweir { 1268*cdf0e10cSrcweir ScQueryEntry& rNewEntry = aParam.GetEntry(nQueryPos); 1269*cdf0e10cSrcweir 1270*cdf0e10cSrcweir rNewEntry.bDoQuery = sal_True; 1271*cdf0e10cSrcweir rNewEntry.bQueryByString = sal_True; 1272*cdf0e10cSrcweir rNewEntry.nField = nCol; 1273*cdf0e10cSrcweir rNewEntry.bQueryByDate = bCheckForDates; 1274*cdf0e10cSrcweir if ( nSel == SC_AUTOFILTER_TOP10 ) 1275*cdf0e10cSrcweir { 1276*cdf0e10cSrcweir rNewEntry.eOp = SC_TOPVAL; 1277*cdf0e10cSrcweir *rNewEntry.pStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("10")); 1278*cdf0e10cSrcweir } 1279*cdf0e10cSrcweir else 1280*cdf0e10cSrcweir { 1281*cdf0e10cSrcweir rNewEntry.eOp = SC_EQUAL; 1282*cdf0e10cSrcweir *rNewEntry.pStr = aValue; 1283*cdf0e10cSrcweir } 1284*cdf0e10cSrcweir if (nQueryPos > 0) 1285*cdf0e10cSrcweir rNewEntry.eConnect = SC_AND; 1286*cdf0e10cSrcweir } 1287*cdf0e10cSrcweir else 1288*cdf0e10cSrcweir { 1289*cdf0e10cSrcweir if (bFound) 1290*cdf0e10cSrcweir aParam.DeleteQuery(nQueryPos); 1291*cdf0e10cSrcweir } 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir // #100597# end edit mode - like in ScCellShell::ExecuteDB 1294*cdf0e10cSrcweir if ( pViewData->HasEditView( pViewData->GetActivePart() ) ) 1295*cdf0e10cSrcweir { 1296*cdf0e10cSrcweir SC_MOD()->InputEnterHandler(); 1297*cdf0e10cSrcweir pViewData->GetViewShell()->UpdateInputHandler(); 1298*cdf0e10cSrcweir } 1299*cdf0e10cSrcweir 1300*cdf0e10cSrcweir pViewData->GetView()->Query( aParam, NULL, sal_True ); 1301*cdf0e10cSrcweir pDBData->SetQueryParam( aParam ); // speichern 1302*cdf0e10cSrcweir } 1303*cdf0e10cSrcweir else // "Zuviele Bedingungen" 1304*cdf0e10cSrcweir pViewData->GetView()->ErrorMessage( STR_FILTER_TOOMANY ); 1305*cdf0e10cSrcweir } 1306*cdf0e10cSrcweir } 1307*cdf0e10cSrcweir else 1308*cdf0e10cSrcweir { 1309*cdf0e10cSrcweir DBG_ERROR("Wo ist der Datenbankbereich?"); 1310*cdf0e10cSrcweir } 1311*cdf0e10cSrcweir } 1312*cdf0e10cSrcweir 1313*cdf0e10cSrcweir void ScGridWindow::SetPointer( const Pointer& rPointer ) 1314*cdf0e10cSrcweir { 1315*cdf0e10cSrcweir nCurrentPointer = 0; 1316*cdf0e10cSrcweir Window::SetPointer( rPointer ); 1317*cdf0e10cSrcweir } 1318*cdf0e10cSrcweir 1319*cdf0e10cSrcweir void ScGridWindow::MoveMouseStatus( ScGridWindow& rDestWin ) 1320*cdf0e10cSrcweir { 1321*cdf0e10cSrcweir if (nButtonDown) 1322*cdf0e10cSrcweir { 1323*cdf0e10cSrcweir rDestWin.nButtonDown = nButtonDown; 1324*cdf0e10cSrcweir rDestWin.nMouseStatus = nMouseStatus; 1325*cdf0e10cSrcweir } 1326*cdf0e10cSrcweir 1327*cdf0e10cSrcweir if (bRFMouse) 1328*cdf0e10cSrcweir { 1329*cdf0e10cSrcweir rDestWin.bRFMouse = bRFMouse; 1330*cdf0e10cSrcweir rDestWin.bRFSize = bRFSize; 1331*cdf0e10cSrcweir rDestWin.nRFIndex = nRFIndex; 1332*cdf0e10cSrcweir rDestWin.nRFAddX = nRFAddX; 1333*cdf0e10cSrcweir rDestWin.nRFAddY = nRFAddY; 1334*cdf0e10cSrcweir bRFMouse = sal_False; 1335*cdf0e10cSrcweir } 1336*cdf0e10cSrcweir 1337*cdf0e10cSrcweir if (nPagebreakMouse) 1338*cdf0e10cSrcweir { 1339*cdf0e10cSrcweir rDestWin.nPagebreakMouse = nPagebreakMouse; 1340*cdf0e10cSrcweir rDestWin.nPagebreakBreak = nPagebreakBreak; 1341*cdf0e10cSrcweir rDestWin.nPagebreakPrev = nPagebreakPrev; 1342*cdf0e10cSrcweir rDestWin.aPagebreakSource = aPagebreakSource; 1343*cdf0e10cSrcweir rDestWin.aPagebreakDrag = aPagebreakDrag; 1344*cdf0e10cSrcweir nPagebreakMouse = SC_PD_NONE; 1345*cdf0e10cSrcweir } 1346*cdf0e10cSrcweir } 1347*cdf0e10cSrcweir 1348*cdf0e10cSrcweir sal_Bool ScGridWindow::TestMouse( const MouseEvent& rMEvt, sal_Bool bAction ) 1349*cdf0e10cSrcweir { 1350*cdf0e10cSrcweir // MouseEvent buttons must only be checked if bAction==TRUE 1351*cdf0e10cSrcweir // to allow changing the mouse pointer in MouseMove, 1352*cdf0e10cSrcweir // but not start AutoFill with right button (#74229#). 1353*cdf0e10cSrcweir // with bAction==sal_True, SetFillMode / SetDragMode is called 1354*cdf0e10cSrcweir 1355*cdf0e10cSrcweir if ( bAction && !rMEvt.IsLeft() ) 1356*cdf0e10cSrcweir return sal_False; 1357*cdf0e10cSrcweir 1358*cdf0e10cSrcweir sal_Bool bNewPointer = sal_False; 1359*cdf0e10cSrcweir 1360*cdf0e10cSrcweir SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient(); 1361*cdf0e10cSrcweir sal_Bool bOleActive = ( pClient && pClient->IsObjectInPlaceActive() ); 1362*cdf0e10cSrcweir 1363*cdf0e10cSrcweir if ( pViewData->IsActive() && !bOleActive ) 1364*cdf0e10cSrcweir { 1365*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 1366*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 1367*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 1368*cdf0e10cSrcweir 1369*cdf0e10cSrcweir // Auto-Fill 1370*cdf0e10cSrcweir 1371*cdf0e10cSrcweir ScRange aMarkRange; 1372*cdf0e10cSrcweir if (pViewData->GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE) 1373*cdf0e10cSrcweir { 1374*cdf0e10cSrcweir if (aMarkRange.aStart.Tab() == pViewData->GetTabNo() && mpAutoFillRect) 1375*cdf0e10cSrcweir { 1376*cdf0e10cSrcweir Point aMousePos = rMEvt.GetPosPixel(); 1377*cdf0e10cSrcweir if (mpAutoFillRect->IsInside(aMousePos)) 1378*cdf0e10cSrcweir { 1379*cdf0e10cSrcweir SetPointer( Pointer( POINTER_CROSS ) ); //! dickeres Kreuz ? 1380*cdf0e10cSrcweir if (bAction) 1381*cdf0e10cSrcweir { 1382*cdf0e10cSrcweir SCCOL nX = aMarkRange.aEnd.Col(); 1383*cdf0e10cSrcweir SCROW nY = aMarkRange.aEnd.Row(); 1384*cdf0e10cSrcweir 1385*cdf0e10cSrcweir if ( lcl_IsEditableMatrix( pViewData->GetDocument(), aMarkRange ) ) 1386*cdf0e10cSrcweir pViewData->SetDragMode( 1387*cdf0e10cSrcweir aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY, SC_FILL_MATRIX ); 1388*cdf0e10cSrcweir else 1389*cdf0e10cSrcweir pViewData->SetFillMode( 1390*cdf0e10cSrcweir aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY ); 1391*cdf0e10cSrcweir 1392*cdf0e10cSrcweir // #108266# The simple selection must also be recognized when dragging, 1393*cdf0e10cSrcweir // where the Marking flag is set and MarkToSimple won't work anymore. 1394*cdf0e10cSrcweir pViewData->GetMarkData().MarkToSimple(); 1395*cdf0e10cSrcweir } 1396*cdf0e10cSrcweir bNewPointer = sal_True; 1397*cdf0e10cSrcweir } 1398*cdf0e10cSrcweir } 1399*cdf0e10cSrcweir } 1400*cdf0e10cSrcweir 1401*cdf0e10cSrcweir // Embedded-Rechteck 1402*cdf0e10cSrcweir 1403*cdf0e10cSrcweir if (pDoc->IsEmbedded()) 1404*cdf0e10cSrcweir { 1405*cdf0e10cSrcweir ScRange aRange; 1406*cdf0e10cSrcweir pDoc->GetEmbedded( aRange ); 1407*cdf0e10cSrcweir if ( pViewData->GetTabNo() == aRange.aStart.Tab() ) 1408*cdf0e10cSrcweir { 1409*cdf0e10cSrcweir Point aStartPos = pViewData->GetScrPos( aRange.aStart.Col(), aRange.aStart.Row(), eWhich ); 1410*cdf0e10cSrcweir Point aEndPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich ); 1411*cdf0e10cSrcweir Point aMousePos = rMEvt.GetPosPixel(); 1412*cdf0e10cSrcweir if ( bLayoutRTL ) 1413*cdf0e10cSrcweir { 1414*cdf0e10cSrcweir aStartPos.X() += 2; 1415*cdf0e10cSrcweir aEndPos.X() += 2; 1416*cdf0e10cSrcweir } 1417*cdf0e10cSrcweir sal_Bool bTop = ( aMousePos.X() >= aStartPos.X()-3 && aMousePos.X() <= aStartPos.X()+1 && 1418*cdf0e10cSrcweir aMousePos.Y() >= aStartPos.Y()-3 && aMousePos.Y() <= aStartPos.Y()+1 ); 1419*cdf0e10cSrcweir sal_Bool bBottom = ( aMousePos.X() >= aEndPos.X()-3 && aMousePos.X() <= aEndPos.X()+1 && 1420*cdf0e10cSrcweir aMousePos.Y() >= aEndPos.Y()-3 && aMousePos.Y() <= aEndPos.Y()+1 ); 1421*cdf0e10cSrcweir if ( bTop || bBottom ) 1422*cdf0e10cSrcweir { 1423*cdf0e10cSrcweir SetPointer( Pointer( POINTER_CROSS ) ); 1424*cdf0e10cSrcweir if (bAction) 1425*cdf0e10cSrcweir { 1426*cdf0e10cSrcweir sal_uInt8 nMode = bTop ? SC_FILL_EMBED_LT : SC_FILL_EMBED_RB; 1427*cdf0e10cSrcweir pViewData->SetDragMode( 1428*cdf0e10cSrcweir aRange.aStart.Col(), aRange.aStart.Row(), 1429*cdf0e10cSrcweir aRange.aEnd.Col(), aRange.aEnd.Row(), nMode ); 1430*cdf0e10cSrcweir } 1431*cdf0e10cSrcweir bNewPointer = sal_True; 1432*cdf0e10cSrcweir } 1433*cdf0e10cSrcweir } 1434*cdf0e10cSrcweir } 1435*cdf0e10cSrcweir } 1436*cdf0e10cSrcweir 1437*cdf0e10cSrcweir if (!bNewPointer && bAction) 1438*cdf0e10cSrcweir { 1439*cdf0e10cSrcweir // SetPointer( POINTER_ARROW ); // in Fu... 1440*cdf0e10cSrcweir pViewData->ResetFillMode(); 1441*cdf0e10cSrcweir } 1442*cdf0e10cSrcweir 1443*cdf0e10cSrcweir return bNewPointer; 1444*cdf0e10cSrcweir } 1445*cdf0e10cSrcweir 1446*cdf0e10cSrcweir void __EXPORT ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt ) 1447*cdf0e10cSrcweir { 1448*cdf0e10cSrcweir nNestedButtonState = SC_NESTEDBUTTON_DOWN; 1449*cdf0e10cSrcweir 1450*cdf0e10cSrcweir HandleMouseButtonDown( rMEvt ); 1451*cdf0e10cSrcweir 1452*cdf0e10cSrcweir if ( nNestedButtonState == SC_NESTEDBUTTON_UP ) 1453*cdf0e10cSrcweir { 1454*cdf0e10cSrcweir // #i41690# If an object is deactivated from MouseButtonDown, it might reschedule, 1455*cdf0e10cSrcweir // so MouseButtonUp comes before the MouseButtonDown call is finished. In this case, 1456*cdf0e10cSrcweir // simulate another MouseButtonUp call, so the selection state is consistent. 1457*cdf0e10cSrcweir 1458*cdf0e10cSrcweir nButtonDown = rMEvt.GetButtons(); 1459*cdf0e10cSrcweir FakeButtonUp(); 1460*cdf0e10cSrcweir 1461*cdf0e10cSrcweir if ( IsTracking() ) 1462*cdf0e10cSrcweir EndTracking(); // normally done in VCL as part of MouseButtonUp handling 1463*cdf0e10cSrcweir } 1464*cdf0e10cSrcweir nNestedButtonState = SC_NESTEDBUTTON_NONE; 1465*cdf0e10cSrcweir } 1466*cdf0e10cSrcweir 1467*cdf0e10cSrcweir void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt ) 1468*cdf0e10cSrcweir { 1469*cdf0e10cSrcweir // We have to check if a context menu is shown and we have an UI 1470*cdf0e10cSrcweir // active inplace client. In that case we have to ignore the event. 1471*cdf0e10cSrcweir // Otherwise we would crash (context menu has been 1472*cdf0e10cSrcweir // opened by inplace client and we would deactivate the inplace client, 1473*cdf0e10cSrcweir // the contex menu is closed by VCL asynchronously which in the end 1474*cdf0e10cSrcweir // would work on deleted objects or the context menu has no parent anymore) 1475*cdf0e10cSrcweir // See #126086# and #128122# 1476*cdf0e10cSrcweir SfxViewShell* pViewSh = pViewData->GetViewShell(); 1477*cdf0e10cSrcweir SfxInPlaceClient* pClient = pViewSh->GetIPClient(); 1478*cdf0e10cSrcweir if ( pClient && 1479*cdf0e10cSrcweir pClient->IsObjectInPlaceActive() && 1480*cdf0e10cSrcweir PopupMenu::IsInExecute() ) 1481*cdf0e10cSrcweir return; 1482*cdf0e10cSrcweir 1483*cdf0e10cSrcweir aCurMousePos = rMEvt.GetPosPixel(); 1484*cdf0e10cSrcweir 1485*cdf0e10cSrcweir // Filter-Popup beendet sich mit eigenem Mausklick, nicht erst beim Klick 1486*cdf0e10cSrcweir // in das GridWindow, darum ist die folgende Abfrage nicht mehr noetig: 1487*cdf0e10cSrcweir #if 0 1488*cdf0e10cSrcweir // merken, dass FilterBox geloescht wird, damit sichergestellt 1489*cdf0e10cSrcweir // ist, dass in diesem Handler nicht an gleicher Stelle wieder 1490*cdf0e10cSrcweir // eine neue geoeffnet wird. 1491*cdf0e10cSrcweir sal_Bool bWasFilterBox = ( pFilterBox != NULL && 1492*cdf0e10cSrcweir ((Window*)pFilterBox)->IsVisible() && 1493*cdf0e10cSrcweir !pFilterBox->IsDataSelect() ); 1494*cdf0e10cSrcweir SCCOL nOldColFBox = bWasFilterBox ? pFilterBox->GetCol() : 0; 1495*cdf0e10cSrcweir SCROW nOldRowFBox = bWasFilterBox ? pFilterBox->GetRow() : 0; 1496*cdf0e10cSrcweir #endif 1497*cdf0e10cSrcweir 1498*cdf0e10cSrcweir ClickExtern(); // loescht FilterBox, wenn vorhanden 1499*cdf0e10cSrcweir 1500*cdf0e10cSrcweir HideNoteMarker(); // Notiz-Anzeige 1501*cdf0e10cSrcweir 1502*cdf0e10cSrcweir bEEMouse = sal_False; 1503*cdf0e10cSrcweir 1504*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 1505*cdf0e10cSrcweir if (pScMod->IsModalMode(pViewData->GetSfxDocShell())) 1506*cdf0e10cSrcweir { 1507*cdf0e10cSrcweir Sound::Beep(); 1508*cdf0e10cSrcweir return; 1509*cdf0e10cSrcweir } 1510*cdf0e10cSrcweir 1511*cdf0e10cSrcweir pScActiveViewShell = pViewData->GetViewShell(); // falls auf Link geklickt wird 1512*cdf0e10cSrcweir nScClickMouseModifier = rMEvt.GetModifier(); // um Control-Klick immer zu erkennen 1513*cdf0e10cSrcweir 1514*cdf0e10cSrcweir sal_Bool bDetective = pViewData->GetViewShell()->IsAuditShell(); 1515*cdf0e10cSrcweir sal_Bool bRefMode = pViewData->IsRefMode(); // Referenz angefangen 1516*cdf0e10cSrcweir sal_Bool bFormulaMode = pScMod->IsFormulaMode(); // naechster Klick -> Referenz 1517*cdf0e10cSrcweir sal_Bool bEditMode = pViewData->HasEditView(eWhich); // auch bei Mode==SC_INPUT_TYPE 1518*cdf0e10cSrcweir sal_Bool bDouble = (rMEvt.GetClicks() == 2); 1519*cdf0e10cSrcweir 1520*cdf0e10cSrcweir // DeactivateIP passiert nur noch bei MarkListHasChanged 1521*cdf0e10cSrcweir 1522*cdf0e10cSrcweir // im GrabFocus Aufruf kann eine Fehlermeldung hochkommen 1523*cdf0e10cSrcweir // (z.B. beim Umbenennen von Tabellen per Tab-Reiter) 1524*cdf0e10cSrcweir 1525*cdf0e10cSrcweir if ( !nButtonDown || !bDouble ) // single (first) click is always valid 1526*cdf0e10cSrcweir nButtonDown = rMEvt.GetButtons(); // set nButtonDown first, so StopMarking works 1527*cdf0e10cSrcweir 1528*cdf0e10cSrcweir // pViewData->GetViewShell()->GetViewFrame()->GetWindow().GrabFocus(); 1529*cdf0e10cSrcweir if ( ( bEditMode && pViewData->GetActivePart() == eWhich ) || !bFormulaMode ) 1530*cdf0e10cSrcweir GrabFocus(); 1531*cdf0e10cSrcweir 1532*cdf0e10cSrcweir // #i31846# need to cancel a double click if the first click has set the "ignore" state, 1533*cdf0e10cSrcweir // but a single (first) click is always valid 1534*cdf0e10cSrcweir if ( nMouseStatus == SC_GM_IGNORE && bDouble ) 1535*cdf0e10cSrcweir { 1536*cdf0e10cSrcweir nButtonDown = 0; 1537*cdf0e10cSrcweir nMouseStatus = SC_GM_NONE; 1538*cdf0e10cSrcweir return; 1539*cdf0e10cSrcweir } 1540*cdf0e10cSrcweir 1541*cdf0e10cSrcweir if ( bDetective ) // Detektiv-Fuell-Modus 1542*cdf0e10cSrcweir { 1543*cdf0e10cSrcweir if ( rMEvt.IsLeft() && !rMEvt.GetModifier() ) 1544*cdf0e10cSrcweir { 1545*cdf0e10cSrcweir Point aPos = rMEvt.GetPosPixel(); 1546*cdf0e10cSrcweir SCsCOL nPosX; 1547*cdf0e10cSrcweir SCsROW nPosY; 1548*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 1549*cdf0e10cSrcweir 1550*cdf0e10cSrcweir SfxInt16Item aPosXItem( SID_RANGE_COL, nPosX ); 1551*cdf0e10cSrcweir SfxInt32Item aPosYItem( SID_RANGE_ROW, nPosY ); 1552*cdf0e10cSrcweir pViewData->GetDispatcher().Execute( SID_FILL_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, 1553*cdf0e10cSrcweir &aPosXItem, &aPosYItem, (void*)0L ); 1554*cdf0e10cSrcweir 1555*cdf0e10cSrcweir } 1556*cdf0e10cSrcweir nButtonDown = 0; 1557*cdf0e10cSrcweir nMouseStatus = SC_GM_NONE; 1558*cdf0e10cSrcweir return; 1559*cdf0e10cSrcweir } 1560*cdf0e10cSrcweir 1561*cdf0e10cSrcweir if (!bDouble) 1562*cdf0e10cSrcweir nMouseStatus = SC_GM_NONE; 1563*cdf0e10cSrcweir 1564*cdf0e10cSrcweir if (!bFormulaMode) 1565*cdf0e10cSrcweir { 1566*cdf0e10cSrcweir if ( pViewData->GetActivePart() != eWhich ) 1567*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( eWhich ); 1568*cdf0e10cSrcweir } 1569*cdf0e10cSrcweir else 1570*cdf0e10cSrcweir { 1571*cdf0e10cSrcweir ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine(); 1572*cdf0e10cSrcweir pSelEng->SetWindow(this); 1573*cdf0e10cSrcweir pSelEng->SetWhich(eWhich); 1574*cdf0e10cSrcweir pSelEng->SetVisibleArea( Rectangle(Point(), GetOutputSizePixel()) ); 1575*cdf0e10cSrcweir } 1576*cdf0e10cSrcweir 1577*cdf0e10cSrcweir if (bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo())) 1578*cdf0e10cSrcweir { 1579*cdf0e10cSrcweir Point aPos = rMEvt.GetPosPixel(); 1580*cdf0e10cSrcweir SCsCOL nPosX; 1581*cdf0e10cSrcweir SCsROW nPosY; 1582*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 1583*cdf0e10cSrcweir 1584*cdf0e10cSrcweir EditView* pEditView; 1585*cdf0e10cSrcweir SCCOL nEditCol; 1586*cdf0e10cSrcweir SCROW nEditRow; 1587*cdf0e10cSrcweir pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); 1588*cdf0e10cSrcweir SCCOL nEndCol = pViewData->GetEditEndCol(); 1589*cdf0e10cSrcweir SCROW nEndRow = pViewData->GetEditEndRow(); 1590*cdf0e10cSrcweir 1591*cdf0e10cSrcweir if ( nPosX >= (SCsCOL) nEditCol && nPosX <= (SCsCOL) nEndCol && 1592*cdf0e10cSrcweir nPosY >= (SCsROW) nEditRow && nPosY <= (SCsROW) nEndRow ) 1593*cdf0e10cSrcweir { 1594*cdf0e10cSrcweir // #53966# beim Klick in die Tabellen-EditView immer den Focus umsetzen 1595*cdf0e10cSrcweir if (bFormulaMode) // sonst ist es oben schon passiert 1596*cdf0e10cSrcweir GrabFocus(); 1597*cdf0e10cSrcweir 1598*cdf0e10cSrcweir pScMod->SetInputMode( SC_INPUT_TABLE ); 1599*cdf0e10cSrcweir bEEMouse = sal_True; 1600*cdf0e10cSrcweir bEditMode = pEditView->MouseButtonDown( rMEvt ); 1601*cdf0e10cSrcweir return; 1602*cdf0e10cSrcweir } 1603*cdf0e10cSrcweir } 1604*cdf0e10cSrcweir 1605*cdf0e10cSrcweir if (pScMod->GetIsWaterCan()) 1606*cdf0e10cSrcweir { 1607*cdf0e10cSrcweir //! was is mit'm Mac ??? 1608*cdf0e10cSrcweir if ( rMEvt.GetModifier() + rMEvt.GetButtons() == MOUSE_RIGHT ) 1609*cdf0e10cSrcweir { 1610*cdf0e10cSrcweir nMouseStatus = SC_GM_WATERUNDO; 1611*cdf0e10cSrcweir return; 1612*cdf0e10cSrcweir } 1613*cdf0e10cSrcweir } 1614*cdf0e10cSrcweir 1615*cdf0e10cSrcweir // Reihenfolge passend zum angezeigten Cursor: 1616*cdf0e10cSrcweir // RangeFinder, AutoFill, PageBreak, Drawing 1617*cdf0e10cSrcweir 1618*cdf0e10cSrcweir if ( HitRangeFinder( rMEvt.GetPosPixel(), bRFSize, &nRFIndex, &nRFAddX, &nRFAddY ) ) 1619*cdf0e10cSrcweir { 1620*cdf0e10cSrcweir bRFMouse = sal_True; // die anderen Variablen sind oben initialisiert 1621*cdf0e10cSrcweir 1622*cdf0e10cSrcweir if ( pViewData->GetActivePart() != eWhich ) 1623*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( eWhich ); //! schon oben immer ??? 1624*cdf0e10cSrcweir 1625*cdf0e10cSrcweir // CaptureMouse(); 1626*cdf0e10cSrcweir StartTracking(); 1627*cdf0e10cSrcweir return; 1628*cdf0e10cSrcweir } 1629*cdf0e10cSrcweir 1630*cdf0e10cSrcweir sal_Bool bCrossPointer = TestMouse( rMEvt, sal_True ); 1631*cdf0e10cSrcweir if ( bCrossPointer ) 1632*cdf0e10cSrcweir { 1633*cdf0e10cSrcweir if ( bDouble ) 1634*cdf0e10cSrcweir pViewData->GetView()->FillCrossDblClick(); 1635*cdf0e10cSrcweir else 1636*cdf0e10cSrcweir pScMod->InputEnterHandler(); // Autofill etc. 1637*cdf0e10cSrcweir } 1638*cdf0e10cSrcweir 1639*cdf0e10cSrcweir if ( !bCrossPointer ) 1640*cdf0e10cSrcweir { 1641*cdf0e10cSrcweir nPagebreakMouse = HitPageBreak( rMEvt.GetPosPixel(), &aPagebreakSource, 1642*cdf0e10cSrcweir &nPagebreakBreak, &nPagebreakPrev ); 1643*cdf0e10cSrcweir if (nPagebreakMouse) 1644*cdf0e10cSrcweir { 1645*cdf0e10cSrcweir bPagebreakDrawn = sal_False; 1646*cdf0e10cSrcweir // CaptureMouse(); 1647*cdf0e10cSrcweir StartTracking(); 1648*cdf0e10cSrcweir PagebreakMove( rMEvt, sal_False ); 1649*cdf0e10cSrcweir return; 1650*cdf0e10cSrcweir } 1651*cdf0e10cSrcweir } 1652*cdf0e10cSrcweir 1653*cdf0e10cSrcweir if (!bFormulaMode && !bEditMode && rMEvt.IsLeft()) 1654*cdf0e10cSrcweir { 1655*cdf0e10cSrcweir if ( !bCrossPointer && DrawMouseButtonDown(rMEvt) ) 1656*cdf0e10cSrcweir { 1657*cdf0e10cSrcweir //if (DrawHasMarkedObj()) 1658*cdf0e10cSrcweir // pViewData->GetViewShell()->SetDrawShellOrSub(); // Draw-Objekt selektiert 1659*cdf0e10cSrcweir return; 1660*cdf0e10cSrcweir } 1661*cdf0e10cSrcweir 1662*cdf0e10cSrcweir pViewData->GetViewShell()->SetDrawShell( sal_False ); // kein Draw-Objekt selektiert 1663*cdf0e10cSrcweir 1664*cdf0e10cSrcweir // TestMouse schon oben passiert 1665*cdf0e10cSrcweir } 1666*cdf0e10cSrcweir 1667*cdf0e10cSrcweir Point aPos = rMEvt.GetPosPixel(); 1668*cdf0e10cSrcweir SCsCOL nPosX; 1669*cdf0e10cSrcweir SCsROW nPosY; 1670*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 1671*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 1672*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 1673*cdf0e10cSrcweir 1674*cdf0e10cSrcweir 1675*cdf0e10cSrcweir // 1676*cdf0e10cSrcweir // AutoFilter buttons 1677*cdf0e10cSrcweir // 1678*cdf0e10cSrcweir 1679*cdf0e10cSrcweir if ( !bDouble && !bFormulaMode && rMEvt.IsLeft() ) 1680*cdf0e10cSrcweir { 1681*cdf0e10cSrcweir ScMergeFlagAttr* pAttr = (ScMergeFlagAttr*) 1682*cdf0e10cSrcweir pDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG ); 1683*cdf0e10cSrcweir if (pAttr->HasAutoFilter()) 1684*cdf0e10cSrcweir { 1685*cdf0e10cSrcweir SC_MOD()->InputEnterHandler(); //Add for i85305 1686*cdf0e10cSrcweir if (DoAutoFilterButton(nPosX, nPosY, rMEvt)) 1687*cdf0e10cSrcweir return; 1688*cdf0e10cSrcweir } 1689*cdf0e10cSrcweir if (pAttr->HasButton()) 1690*cdf0e10cSrcweir { 1691*cdf0e10cSrcweir DoPushButton( nPosX, nPosY, rMEvt ); // setzt evtl. bPivotMouse / bDPMouse 1692*cdf0e10cSrcweir return; 1693*cdf0e10cSrcweir } 1694*cdf0e10cSrcweir 1695*cdf0e10cSrcweir // List Validity drop-down button 1696*cdf0e10cSrcweir 1697*cdf0e10cSrcweir if ( bListValButton ) 1698*cdf0e10cSrcweir { 1699*cdf0e10cSrcweir Rectangle aButtonRect = GetListValButtonRect( aListValPos ); 1700*cdf0e10cSrcweir if ( aButtonRect.IsInside( aPos ) ) 1701*cdf0e10cSrcweir { 1702*cdf0e10cSrcweir DoAutoFilterMenue( aListValPos.Col(), aListValPos.Row(), sal_True ); 1703*cdf0e10cSrcweir 1704*cdf0e10cSrcweir nMouseStatus = SC_GM_FILTER; // not set in DoAutoFilterMenue for bDataSelect 1705*cdf0e10cSrcweir CaptureMouse(); 1706*cdf0e10cSrcweir return; 1707*cdf0e10cSrcweir } 1708*cdf0e10cSrcweir } 1709*cdf0e10cSrcweir } 1710*cdf0e10cSrcweir 1711*cdf0e10cSrcweir // 1712*cdf0e10cSrcweir // scenario selection 1713*cdf0e10cSrcweir // 1714*cdf0e10cSrcweir 1715*cdf0e10cSrcweir ScRange aScenRange; 1716*cdf0e10cSrcweir if ( rMEvt.IsLeft() && HasScenarioButton( aPos, aScenRange ) ) 1717*cdf0e10cSrcweir { 1718*cdf0e10cSrcweir DoScenarioMenue( aScenRange ); 1719*cdf0e10cSrcweir return; 1720*cdf0e10cSrcweir } 1721*cdf0e10cSrcweir 1722*cdf0e10cSrcweir // 1723*cdf0e10cSrcweir // Doppelklick angefangen ? 1724*cdf0e10cSrcweir // 1725*cdf0e10cSrcweir 1726*cdf0e10cSrcweir // StopMarking kann aus DrawMouseButtonDown gerufen werden 1727*cdf0e10cSrcweir 1728*cdf0e10cSrcweir if ( nMouseStatus != SC_GM_IGNORE && !bRefMode ) 1729*cdf0e10cSrcweir { 1730*cdf0e10cSrcweir if ( bDouble && !bCrossPointer ) 1731*cdf0e10cSrcweir { 1732*cdf0e10cSrcweir if (nMouseStatus == SC_GM_TABDOWN) 1733*cdf0e10cSrcweir nMouseStatus = SC_GM_DBLDOWN; 1734*cdf0e10cSrcweir } 1735*cdf0e10cSrcweir else 1736*cdf0e10cSrcweir nMouseStatus = SC_GM_TABDOWN; 1737*cdf0e10cSrcweir } 1738*cdf0e10cSrcweir 1739*cdf0e10cSrcweir // 1740*cdf0e10cSrcweir // Links in Edit-Zellen 1741*cdf0e10cSrcweir // 1742*cdf0e10cSrcweir 1743*cdf0e10cSrcweir sal_Bool bAlt = rMEvt.IsMod2(); 1744*cdf0e10cSrcweir if ( !bAlt && rMEvt.IsLeft() && 1745*cdf0e10cSrcweir GetEditUrl(rMEvt.GetPosPixel()) ) // Klick auf Link: Cursor nicht bewegen 1746*cdf0e10cSrcweir { 1747*cdf0e10cSrcweir SetPointer( Pointer( POINTER_REFHAND ) ); 1748*cdf0e10cSrcweir nMouseStatus = SC_GM_URLDOWN; // auch nur dann beim ButtonUp ausfuehren 1749*cdf0e10cSrcweir return; 1750*cdf0e10cSrcweir } 1751*cdf0e10cSrcweir 1752*cdf0e10cSrcweir // 1753*cdf0e10cSrcweir // Gridwin - SelectionEngine 1754*cdf0e10cSrcweir // 1755*cdf0e10cSrcweir 1756*cdf0e10cSrcweir if ( rMEvt.IsLeft() ) 1757*cdf0e10cSrcweir { 1758*cdf0e10cSrcweir ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine(); 1759*cdf0e10cSrcweir pSelEng->SetWindow(this); 1760*cdf0e10cSrcweir pSelEng->SetWhich(eWhich); 1761*cdf0e10cSrcweir pSelEng->SetVisibleArea( Rectangle(Point(), GetOutputSizePixel()) ); 1762*cdf0e10cSrcweir 1763*cdf0e10cSrcweir // SelMouseButtonDown an der View setzt noch das bMoveIsShift Flag 1764*cdf0e10cSrcweir if ( pViewData->GetView()->SelMouseButtonDown( rMEvt ) ) 1765*cdf0e10cSrcweir { 1766*cdf0e10cSrcweir if (IsMouseCaptured()) 1767*cdf0e10cSrcweir { 1768*cdf0e10cSrcweir // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann 1769*cdf0e10cSrcweir //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?! 1770*cdf0e10cSrcweir ReleaseMouse(); 1771*cdf0e10cSrcweir StartTracking(); 1772*cdf0e10cSrcweir } 1773*cdf0e10cSrcweir pViewData->GetMarkData().SetMarking(sal_True); 1774*cdf0e10cSrcweir return; 1775*cdf0e10cSrcweir } 1776*cdf0e10cSrcweir } 1777*cdf0e10cSrcweir } 1778*cdf0e10cSrcweir 1779*cdf0e10cSrcweir void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) 1780*cdf0e10cSrcweir { 1781*cdf0e10cSrcweir aCurMousePos = rMEvt.GetPosPixel(); 1782*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 1783*cdf0e10cSrcweir ScMarkData& rMark = pViewData->GetMarkData(); 1784*cdf0e10cSrcweir 1785*cdf0e10cSrcweir // #i41690# detect a MouseButtonUp call from within MouseButtonDown 1786*cdf0e10cSrcweir // (possible through Reschedule from storing an OLE object that is deselected) 1787*cdf0e10cSrcweir 1788*cdf0e10cSrcweir if ( nNestedButtonState == SC_NESTEDBUTTON_DOWN ) 1789*cdf0e10cSrcweir nNestedButtonState = SC_NESTEDBUTTON_UP; 1790*cdf0e10cSrcweir 1791*cdf0e10cSrcweir if (nButtonDown != rMEvt.GetButtons()) 1792*cdf0e10cSrcweir nMouseStatus = SC_GM_IGNORE; // reset und return 1793*cdf0e10cSrcweir 1794*cdf0e10cSrcweir nButtonDown = 0; 1795*cdf0e10cSrcweir 1796*cdf0e10cSrcweir if (nMouseStatus == SC_GM_IGNORE) 1797*cdf0e10cSrcweir { 1798*cdf0e10cSrcweir nMouseStatus = SC_GM_NONE; 1799*cdf0e10cSrcweir // Selection-Engine: Markieren abbrechen 1800*cdf0e10cSrcweir pViewData->GetView()->GetSelEngine()->Reset(); 1801*cdf0e10cSrcweir rMark.SetMarking(sal_False); 1802*cdf0e10cSrcweir if (pViewData->IsAnyFillMode()) 1803*cdf0e10cSrcweir { 1804*cdf0e10cSrcweir pViewData->GetView()->StopRefMode(); 1805*cdf0e10cSrcweir pViewData->ResetFillMode(); 1806*cdf0e10cSrcweir } 1807*cdf0e10cSrcweir StopMarking(); 1808*cdf0e10cSrcweir DrawEndAction(); // Markieren/Verschieben auf Drawing-Layer abbrechen 1809*cdf0e10cSrcweir ReleaseMouse(); 1810*cdf0e10cSrcweir return; 1811*cdf0e10cSrcweir } 1812*cdf0e10cSrcweir 1813*cdf0e10cSrcweir if (nMouseStatus == SC_GM_FILTER) 1814*cdf0e10cSrcweir { 1815*cdf0e10cSrcweir if ( pFilterBox && pFilterBox->GetMode() == SC_FILTERBOX_FILTER ) 1816*cdf0e10cSrcweir { 1817*cdf0e10cSrcweir if (mpFilterButton.get()) 1818*cdf0e10cSrcweir { 1819*cdf0e10cSrcweir bool bFilterActive = IsAutoFilterActive( 1820*cdf0e10cSrcweir pFilterBox->GetCol(), pFilterBox->GetRow(), pViewData->GetTabNo() ); 1821*cdf0e10cSrcweir 1822*cdf0e10cSrcweir mpFilterButton->setHasHiddenMember(bFilterActive); 1823*cdf0e10cSrcweir mpFilterButton->setPopupPressed(false); 1824*cdf0e10cSrcweir HideCursor(); 1825*cdf0e10cSrcweir mpFilterButton->draw(); 1826*cdf0e10cSrcweir ShowCursor(); 1827*cdf0e10cSrcweir } 1828*cdf0e10cSrcweir } 1829*cdf0e10cSrcweir nMouseStatus = SC_GM_NONE; 1830*cdf0e10cSrcweir ReleaseMouse(); 1831*cdf0e10cSrcweir return; // da muss nix mehr passieren 1832*cdf0e10cSrcweir } 1833*cdf0e10cSrcweir 1834*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 1835*cdf0e10cSrcweir if (pScMod->IsModalMode(pViewData->GetSfxDocShell())) 1836*cdf0e10cSrcweir return; 1837*cdf0e10cSrcweir 1838*cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 1839*cdf0e10cSrcweir if (bEEMouse && pViewData->HasEditView( eWhich )) 1840*cdf0e10cSrcweir { 1841*cdf0e10cSrcweir EditView* pEditView; 1842*cdf0e10cSrcweir SCCOL nEditCol; 1843*cdf0e10cSrcweir SCROW nEditRow; 1844*cdf0e10cSrcweir pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); 1845*cdf0e10cSrcweir pEditView->MouseButtonUp( rMEvt ); 1846*cdf0e10cSrcweir 1847*cdf0e10cSrcweir if ( rMEvt.IsMiddle() && 1848*cdf0e10cSrcweir GetSettings().GetMouseSettings().GetMiddleButtonAction() == MOUSE_MIDDLE_PASTESELECTION ) 1849*cdf0e10cSrcweir { 1850*cdf0e10cSrcweir // EditView may have pasted from selection 1851*cdf0e10cSrcweir pScMod->InputChanged( pEditView ); 1852*cdf0e10cSrcweir } 1853*cdf0e10cSrcweir else 1854*cdf0e10cSrcweir pScMod->InputSelection( pEditView ); // parentheses etc. 1855*cdf0e10cSrcweir 1856*cdf0e10cSrcweir pViewData->GetView()->InvalidateAttribs(); 1857*cdf0e10cSrcweir rBindings.Invalidate( SID_HYPERLINK_GETLINK ); 1858*cdf0e10cSrcweir bEEMouse = sal_False; 1859*cdf0e10cSrcweir return; 1860*cdf0e10cSrcweir } 1861*cdf0e10cSrcweir 1862*cdf0e10cSrcweir if (bDPMouse) 1863*cdf0e10cSrcweir { 1864*cdf0e10cSrcweir DPMouseButtonUp( rMEvt ); // resets bDPMouse 1865*cdf0e10cSrcweir return; 1866*cdf0e10cSrcweir } 1867*cdf0e10cSrcweir 1868*cdf0e10cSrcweir if (bRFMouse) 1869*cdf0e10cSrcweir { 1870*cdf0e10cSrcweir RFMouseMove( rMEvt, sal_True ); // Range wieder richtigherum 1871*cdf0e10cSrcweir bRFMouse = sal_False; 1872*cdf0e10cSrcweir SetPointer( Pointer( POINTER_ARROW ) ); 1873*cdf0e10cSrcweir ReleaseMouse(); 1874*cdf0e10cSrcweir return; 1875*cdf0e10cSrcweir } 1876*cdf0e10cSrcweir 1877*cdf0e10cSrcweir if (nPagebreakMouse) 1878*cdf0e10cSrcweir { 1879*cdf0e10cSrcweir PagebreakMove( rMEvt, sal_True ); 1880*cdf0e10cSrcweir nPagebreakMouse = SC_PD_NONE; 1881*cdf0e10cSrcweir SetPointer( Pointer( POINTER_ARROW ) ); 1882*cdf0e10cSrcweir ReleaseMouse(); 1883*cdf0e10cSrcweir return; 1884*cdf0e10cSrcweir } 1885*cdf0e10cSrcweir 1886*cdf0e10cSrcweir if (nMouseStatus == SC_GM_WATERUNDO) // Undo im Giesskannenmodus 1887*cdf0e10cSrcweir { 1888*cdf0e10cSrcweir ::svl::IUndoManager* pMgr = pViewData->GetDocShell()->GetUndoManager(); 1889*cdf0e10cSrcweir if ( pMgr->GetUndoActionCount() && pMgr->GetUndoActionId() == STR_UNDO_APPLYCELLSTYLE ) 1890*cdf0e10cSrcweir pMgr->Undo(); 1891*cdf0e10cSrcweir else 1892*cdf0e10cSrcweir Sound::Beep(); 1893*cdf0e10cSrcweir return; 1894*cdf0e10cSrcweir } 1895*cdf0e10cSrcweir 1896*cdf0e10cSrcweir if (DrawMouseButtonUp(rMEvt)) // includes format paint brush handling for drawing objects 1897*cdf0e10cSrcweir return; 1898*cdf0e10cSrcweir 1899*cdf0e10cSrcweir rMark.SetMarking(sal_False); 1900*cdf0e10cSrcweir 1901*cdf0e10cSrcweir SetPointer( Pointer( POINTER_ARROW ) ); 1902*cdf0e10cSrcweir 1903*cdf0e10cSrcweir if (pViewData->IsFillMode() || 1904*cdf0e10cSrcweir ( pViewData->GetFillMode() == SC_FILL_MATRIX && rMEvt.IsMod1() )) 1905*cdf0e10cSrcweir { 1906*cdf0e10cSrcweir nScFillModeMouseModifier = rMEvt.GetModifier(); 1907*cdf0e10cSrcweir SCCOL nStartCol; 1908*cdf0e10cSrcweir SCROW nStartRow; 1909*cdf0e10cSrcweir SCCOL nEndCol; 1910*cdf0e10cSrcweir SCROW nEndRow; 1911*cdf0e10cSrcweir pViewData->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow ); 1912*cdf0e10cSrcweir // DBG_ASSERT( nStartCol==pViewData->GetRefStartX() && nStartRow==pViewData->GetRefStartY(), 1913*cdf0e10cSrcweir // "Block falsch fuer AutoFill" ); 1914*cdf0e10cSrcweir ScRange aDelRange; 1915*cdf0e10cSrcweir sal_Bool bIsDel = pViewData->GetDelMark( aDelRange ); 1916*cdf0e10cSrcweir 1917*cdf0e10cSrcweir ScViewFunc* pView = pViewData->GetView(); 1918*cdf0e10cSrcweir pView->StopRefMode(); 1919*cdf0e10cSrcweir pViewData->ResetFillMode(); 1920*cdf0e10cSrcweir pView->GetFunctionSet()->SetAnchorFlag( sal_False ); // #i5819# don't use AutoFill anchor flag for selection 1921*cdf0e10cSrcweir 1922*cdf0e10cSrcweir if ( bIsDel ) 1923*cdf0e10cSrcweir { 1924*cdf0e10cSrcweir pView->MarkRange( aDelRange, sal_False ); 1925*cdf0e10cSrcweir pView->DeleteContents( IDF_CONTENTS ); 1926*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 1927*cdf0e10cSrcweir ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ); 1928*cdf0e10cSrcweir if ( aBlockRange != aDelRange ) 1929*cdf0e10cSrcweir { 1930*cdf0e10cSrcweir if ( aDelRange.aStart.Row() == nStartRow ) 1931*cdf0e10cSrcweir aBlockRange.aEnd.SetCol( aDelRange.aStart.Col() - 1 ); 1932*cdf0e10cSrcweir else 1933*cdf0e10cSrcweir aBlockRange.aEnd.SetRow( aDelRange.aStart.Row() - 1 ); 1934*cdf0e10cSrcweir pView->MarkRange( aBlockRange, sal_False ); 1935*cdf0e10cSrcweir } 1936*cdf0e10cSrcweir } 1937*cdf0e10cSrcweir else 1938*cdf0e10cSrcweir pViewData->GetDispatcher().Execute( FID_FILL_AUTO, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); 1939*cdf0e10cSrcweir } 1940*cdf0e10cSrcweir else if (pViewData->GetFillMode() == SC_FILL_MATRIX) 1941*cdf0e10cSrcweir { 1942*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 1943*cdf0e10cSrcweir SCCOL nStartCol; 1944*cdf0e10cSrcweir SCROW nStartRow; 1945*cdf0e10cSrcweir SCCOL nEndCol; 1946*cdf0e10cSrcweir SCROW nEndRow; 1947*cdf0e10cSrcweir pViewData->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow ); 1948*cdf0e10cSrcweir ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ); 1949*cdf0e10cSrcweir SCCOL nFillCol = pViewData->GetRefEndX(); 1950*cdf0e10cSrcweir SCROW nFillRow = pViewData->GetRefEndY(); 1951*cdf0e10cSrcweir ScAddress aEndPos( nFillCol, nFillRow, nTab ); 1952*cdf0e10cSrcweir 1953*cdf0e10cSrcweir ScTabView* pView = pViewData->GetView(); 1954*cdf0e10cSrcweir pView->StopRefMode(); 1955*cdf0e10cSrcweir pViewData->ResetFillMode(); 1956*cdf0e10cSrcweir pView->GetFunctionSet()->SetAnchorFlag( sal_False ); 1957*cdf0e10cSrcweir 1958*cdf0e10cSrcweir if ( aEndPos != aBlockRange.aEnd ) 1959*cdf0e10cSrcweir { 1960*cdf0e10cSrcweir pViewData->GetDocShell()->GetDocFunc().ResizeMatrix( aBlockRange, aEndPos, sal_False ); 1961*cdf0e10cSrcweir pViewData->GetView()->MarkRange( ScRange( aBlockRange.aStart, aEndPos ) ); 1962*cdf0e10cSrcweir } 1963*cdf0e10cSrcweir } 1964*cdf0e10cSrcweir else if (pViewData->IsAnyFillMode()) 1965*cdf0e10cSrcweir { 1966*cdf0e10cSrcweir // Embedded-Area has been changed 1967*cdf0e10cSrcweir ScTabView* pView = pViewData->GetView(); 1968*cdf0e10cSrcweir pView->StopRefMode(); 1969*cdf0e10cSrcweir pViewData->ResetFillMode(); 1970*cdf0e10cSrcweir pView->GetFunctionSet()->SetAnchorFlag( sal_False ); 1971*cdf0e10cSrcweir pViewData->GetDocShell()->UpdateOle(pViewData); 1972*cdf0e10cSrcweir } 1973*cdf0e10cSrcweir 1974*cdf0e10cSrcweir sal_Bool bRefMode = pViewData->IsRefMode(); 1975*cdf0e10cSrcweir if (bRefMode) 1976*cdf0e10cSrcweir pScMod->EndReference(); 1977*cdf0e10cSrcweir 1978*cdf0e10cSrcweir // 1979*cdf0e10cSrcweir // Giesskannen-Modus (Gestalter) 1980*cdf0e10cSrcweir // 1981*cdf0e10cSrcweir 1982*cdf0e10cSrcweir if (pScMod->GetIsWaterCan()) 1983*cdf0e10cSrcweir { 1984*cdf0e10cSrcweir // Abfrage auf Undo schon oben 1985*cdf0e10cSrcweir 1986*cdf0e10cSrcweir ScStyleSheetPool* pStylePool = (ScStyleSheetPool*) 1987*cdf0e10cSrcweir (pViewData->GetDocument()-> 1988*cdf0e10cSrcweir GetStyleSheetPool()); 1989*cdf0e10cSrcweir if ( pStylePool ) 1990*cdf0e10cSrcweir { 1991*cdf0e10cSrcweir SfxStyleSheet* pStyleSheet = (SfxStyleSheet*) 1992*cdf0e10cSrcweir pStylePool->GetActualStyleSheet(); 1993*cdf0e10cSrcweir 1994*cdf0e10cSrcweir if ( pStyleSheet ) 1995*cdf0e10cSrcweir { 1996*cdf0e10cSrcweir SfxStyleFamily eFamily = pStyleSheet->GetFamily(); 1997*cdf0e10cSrcweir 1998*cdf0e10cSrcweir switch ( eFamily ) 1999*cdf0e10cSrcweir { 2000*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PARA: 2001*cdf0e10cSrcweir pViewData->GetView()->SetStyleSheetToMarked( pStyleSheet ); 2002*cdf0e10cSrcweir pViewData->GetView()->DoneBlockMode(); 2003*cdf0e10cSrcweir break; 2004*cdf0e10cSrcweir 2005*cdf0e10cSrcweir case SFX_STYLE_FAMILY_PAGE: 2006*cdf0e10cSrcweir pViewData->GetDocument()->SetPageStyle( pViewData->GetTabNo(), 2007*cdf0e10cSrcweir pStyleSheet->GetName() ); 2008*cdf0e10cSrcweir 2009*cdf0e10cSrcweir ScPrintFunc( pViewData->GetDocShell(), 2010*cdf0e10cSrcweir pViewData->GetViewShell()->GetPrinter(sal_True), 2011*cdf0e10cSrcweir pViewData->GetTabNo() ).UpdatePages(); 2012*cdf0e10cSrcweir 2013*cdf0e10cSrcweir rBindings.Invalidate( SID_STATUS_PAGESTYLE ); 2014*cdf0e10cSrcweir break; 2015*cdf0e10cSrcweir 2016*cdf0e10cSrcweir default: 2017*cdf0e10cSrcweir break; 2018*cdf0e10cSrcweir } 2019*cdf0e10cSrcweir } 2020*cdf0e10cSrcweir } 2021*cdf0e10cSrcweir } 2022*cdf0e10cSrcweir 2023*cdf0e10cSrcweir ScDBFunc* pView = pViewData->GetView(); 2024*cdf0e10cSrcweir ScDocument* pBrushDoc = pView->GetBrushDocument(); 2025*cdf0e10cSrcweir if ( pBrushDoc ) 2026*cdf0e10cSrcweir { 2027*cdf0e10cSrcweir pView->PasteFromClip( IDF_ATTRIB, pBrushDoc ); 2028*cdf0e10cSrcweir if ( !pView->IsPaintBrushLocked() ) 2029*cdf0e10cSrcweir pView->ResetBrushDocument(); // invalidates pBrushDoc pointer 2030*cdf0e10cSrcweir } 2031*cdf0e10cSrcweir 2032*cdf0e10cSrcweir // 2033*cdf0e10cSrcweir // double click (only left button) 2034*cdf0e10cSrcweir // 2035*cdf0e10cSrcweir 2036*cdf0e10cSrcweir sal_Bool bDouble = ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() ); 2037*cdf0e10cSrcweir if ( bDouble && !bRefMode && nMouseStatus == SC_GM_DBLDOWN && !pScMod->IsRefDialogOpen() ) 2038*cdf0e10cSrcweir { 2039*cdf0e10cSrcweir // data pilot table 2040*cdf0e10cSrcweir Point aPos = rMEvt.GetPosPixel(); 2041*cdf0e10cSrcweir SCsCOL nPosX; 2042*cdf0e10cSrcweir SCsROW nPosY; 2043*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 2044*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 2045*cdf0e10cSrcweir ScDPObject* pDPObj = pDoc->GetDPAtCursor( nPosX, nPosY, nTab ); 2046*cdf0e10cSrcweir if ( pDPObj && pDPObj->GetSaveData()->GetDrillDown() ) 2047*cdf0e10cSrcweir { 2048*cdf0e10cSrcweir ScAddress aCellPos( nPosX, nPosY, pViewData->GetTabNo() ); 2049*cdf0e10cSrcweir 2050*cdf0e10cSrcweir // Check for header drill-down first. 2051*cdf0e10cSrcweir sheet::DataPilotTableHeaderData aData; 2052*cdf0e10cSrcweir pDPObj->GetHeaderPositionData(aCellPos, aData); 2053*cdf0e10cSrcweir 2054*cdf0e10cSrcweir if ( ( aData.Flags & sheet::MemberResultFlags::HASMEMBER ) && 2055*cdf0e10cSrcweir ! ( aData.Flags & sheet::MemberResultFlags::SUBTOTAL ) ) 2056*cdf0e10cSrcweir { 2057*cdf0e10cSrcweir sal_uInt16 nDummy; 2058*cdf0e10cSrcweir if ( pView->HasSelectionForDrillDown( nDummy ) ) 2059*cdf0e10cSrcweir { 2060*cdf0e10cSrcweir // execute slot to show dialog 2061*cdf0e10cSrcweir pViewData->GetDispatcher().Execute( SID_OUTLINE_SHOW, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); 2062*cdf0e10cSrcweir } 2063*cdf0e10cSrcweir else 2064*cdf0e10cSrcweir { 2065*cdf0e10cSrcweir // toggle single entry 2066*cdf0e10cSrcweir ScDPObject aNewObj( *pDPObj ); 2067*cdf0e10cSrcweir pDPObj->ToggleDetails( aData, &aNewObj ); 2068*cdf0e10cSrcweir ScDBDocFunc aFunc( *pViewData->GetDocShell() ); 2069*cdf0e10cSrcweir aFunc.DataPilotUpdate( pDPObj, &aNewObj, sal_True, sal_False ); 2070*cdf0e10cSrcweir pViewData->GetView()->CursorPosChanged(); // shells may be switched 2071*cdf0e10cSrcweir } 2072*cdf0e10cSrcweir } 2073*cdf0e10cSrcweir else 2074*cdf0e10cSrcweir { 2075*cdf0e10cSrcweir // Check if the data area is double-clicked. 2076*cdf0e10cSrcweir 2077*cdf0e10cSrcweir Sequence<sheet::DataPilotFieldFilter> aFilters; 2078*cdf0e10cSrcweir if ( pDPObj->GetDataFieldPositionData(aCellPos, aFilters) ) 2079*cdf0e10cSrcweir pViewData->GetView()->ShowDataPilotSourceData( *pDPObj, aFilters ); 2080*cdf0e10cSrcweir else 2081*cdf0e10cSrcweir Sound::Beep(); // nothing to expand/collapse/show 2082*cdf0e10cSrcweir } 2083*cdf0e10cSrcweir 2084*cdf0e10cSrcweir return; 2085*cdf0e10cSrcweir } 2086*cdf0e10cSrcweir 2087*cdf0e10cSrcweir // Check for cell protection attribute. 2088*cdf0e10cSrcweir ScTableProtection* pProtect = pDoc->GetTabProtection( nTab ); 2089*cdf0e10cSrcweir bool bEditAllowed = true; 2090*cdf0e10cSrcweir if ( pProtect && pProtect->isProtected() ) 2091*cdf0e10cSrcweir { 2092*cdf0e10cSrcweir bool bCellProtected = pDoc->HasAttrib(nPosX, nPosY, nTab, nPosX, nPosY, nTab, HASATTR_PROTECTED); 2093*cdf0e10cSrcweir bool bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); 2094*cdf0e10cSrcweir bool bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); 2095*cdf0e10cSrcweir 2096*cdf0e10cSrcweir if ( bSkipProtected && bSkipUnprotected ) 2097*cdf0e10cSrcweir bEditAllowed = false; 2098*cdf0e10cSrcweir else if ( (bCellProtected && bSkipProtected) || (!bCellProtected && bSkipUnprotected) ) 2099*cdf0e10cSrcweir bEditAllowed = false; 2100*cdf0e10cSrcweir } 2101*cdf0e10cSrcweir 2102*cdf0e10cSrcweir if ( bEditAllowed ) 2103*cdf0e10cSrcweir { 2104*cdf0e10cSrcweir // edit cell contents 2105*cdf0e10cSrcweir pViewData->GetViewShell()->UpdateInputHandler(); 2106*cdf0e10cSrcweir pScMod->SetInputMode( SC_INPUT_TABLE ); 2107*cdf0e10cSrcweir if (pViewData->HasEditView(eWhich)) 2108*cdf0e10cSrcweir { 2109*cdf0e10cSrcweir // Text-Cursor gleich an die geklickte Stelle setzen 2110*cdf0e10cSrcweir EditView* pEditView = pViewData->GetEditView( eWhich ); 2111*cdf0e10cSrcweir MouseEvent aEditEvt( rMEvt.GetPosPixel(), 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 ); 2112*cdf0e10cSrcweir pEditView->MouseButtonDown( aEditEvt ); 2113*cdf0e10cSrcweir pEditView->MouseButtonUp( aEditEvt ); 2114*cdf0e10cSrcweir } 2115*cdf0e10cSrcweir } 2116*cdf0e10cSrcweir return; 2117*cdf0e10cSrcweir } 2118*cdf0e10cSrcweir 2119*cdf0e10cSrcweir // 2120*cdf0e10cSrcweir // Links in edit cells 2121*cdf0e10cSrcweir // 2122*cdf0e10cSrcweir 2123*cdf0e10cSrcweir sal_Bool bAlt = rMEvt.IsMod2(); 2124*cdf0e10cSrcweir if ( !bAlt && !bRefMode && !bDouble && nMouseStatus == SC_GM_URLDOWN ) 2125*cdf0e10cSrcweir { 2126*cdf0e10cSrcweir // beim ButtonUp nur ausfuehren, wenn ButtonDown auch ueber einer URL war 2127*cdf0e10cSrcweir 2128*cdf0e10cSrcweir String aName, aUrl, aTarget; 2129*cdf0e10cSrcweir if ( GetEditUrl( rMEvt.GetPosPixel(), &aName, &aUrl, &aTarget ) ) 2130*cdf0e10cSrcweir { 2131*cdf0e10cSrcweir nMouseStatus = SC_GM_NONE; // keinen Doppelklick anfangen 2132*cdf0e10cSrcweir ScGlobal::OpenURL( aUrl, aTarget ); 2133*cdf0e10cSrcweir 2134*cdf0e10cSrcweir // fire worksheet_followhyperlink event 2135*cdf0e10cSrcweir uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); 2136*cdf0e10cSrcweir if( xVbaEvents.is() ) try 2137*cdf0e10cSrcweir { 2138*cdf0e10cSrcweir Point aPos = rMEvt.GetPosPixel(); 2139*cdf0e10cSrcweir SCsCOL nPosX; 2140*cdf0e10cSrcweir SCsROW nPosY; 2141*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 2142*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 2143*cdf0e10cSrcweir ScBaseCell* pCell = NULL; 2144*cdf0e10cSrcweir if( lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell ) ) 2145*cdf0e10cSrcweir { 2146*cdf0e10cSrcweir ScAddress aCellPos( nPosX, nPosY, nTab ); 2147*cdf0e10cSrcweir uno::Reference< table::XCell > xCell( new ScCellObj( pViewData->GetDocShell(), aCellPos ) ); 2148*cdf0e10cSrcweir uno::Sequence< uno::Any > aArgs(1); 2149*cdf0e10cSrcweir aArgs[0] <<= xCell; 2150*cdf0e10cSrcweir xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_FOLLOWHYPERLINK, aArgs ); 2151*cdf0e10cSrcweir } 2152*cdf0e10cSrcweir } 2153*cdf0e10cSrcweir catch( uno::Exception& ) 2154*cdf0e10cSrcweir { 2155*cdf0e10cSrcweir } 2156*cdf0e10cSrcweir 2157*cdf0e10cSrcweir return; 2158*cdf0e10cSrcweir } 2159*cdf0e10cSrcweir } 2160*cdf0e10cSrcweir 2161*cdf0e10cSrcweir // 2162*cdf0e10cSrcweir // Gridwin - SelectionEngine 2163*cdf0e10cSrcweir // 2164*cdf0e10cSrcweir 2165*cdf0e10cSrcweir // SelMouseButtonDown is called only for left button, but SelMouseButtonUp would return 2166*cdf0e10cSrcweir // sal_True for any call, so IsLeft must be checked here, too. 2167*cdf0e10cSrcweir 2168*cdf0e10cSrcweir if ( rMEvt.IsLeft() && pViewData->GetView()->GetSelEngine()->SelMouseButtonUp( rMEvt ) ) 2169*cdf0e10cSrcweir { 2170*cdf0e10cSrcweir // rMark.MarkToSimple(); 2171*cdf0e10cSrcweir pViewData->GetView()->UpdateAutoFillMark(); 2172*cdf0e10cSrcweir 2173*cdf0e10cSrcweir SfxDispatcher* pDisp = pViewData->GetViewShell()->GetDispatcher(); 2174*cdf0e10cSrcweir sal_Bool bFormulaMode = pScMod->IsFormulaMode(); 2175*cdf0e10cSrcweir DBG_ASSERT( pDisp || bFormulaMode, "Cursor auf nicht aktiver View bewegen ?" ); 2176*cdf0e10cSrcweir 2177*cdf0e10cSrcweir // #i14927# execute SID_CURRENTCELL (for macro recording) only if there is no 2178*cdf0e10cSrcweir // multiple selection, so the argument string completely describes the selection, 2179*cdf0e10cSrcweir // and executing the slot won't change the existing selection (executing the slot 2180*cdf0e10cSrcweir // here and from a recorded macro is treated equally) 2181*cdf0e10cSrcweir 2182*cdf0e10cSrcweir if ( pDisp && !bFormulaMode && !rMark.IsMultiMarked() ) 2183*cdf0e10cSrcweir { 2184*cdf0e10cSrcweir String aAddr; // CurrentCell 2185*cdf0e10cSrcweir if( rMark.IsMarked() ) 2186*cdf0e10cSrcweir { 2187*cdf0e10cSrcweir // sal_Bool bKeep = rMark.IsMultiMarked(); //! wohin damit ??? 2188*cdf0e10cSrcweir 2189*cdf0e10cSrcweir ScRange aScRange; 2190*cdf0e10cSrcweir rMark.GetMarkArea( aScRange ); 2191*cdf0e10cSrcweir aScRange.Format( aAddr, SCR_ABS ); 2192*cdf0e10cSrcweir if ( aScRange.aStart == aScRange.aEnd ) 2193*cdf0e10cSrcweir { 2194*cdf0e10cSrcweir // make sure there is a range selection string even for a single cell 2195*cdf0e10cSrcweir String aSingle = aAddr; 2196*cdf0e10cSrcweir aAddr.Append( (sal_Char) ':' ); 2197*cdf0e10cSrcweir aAddr.Append( aSingle ); 2198*cdf0e10cSrcweir } 2199*cdf0e10cSrcweir 2200*cdf0e10cSrcweir //! SID_MARKAREA gibts nicht mehr ??? 2201*cdf0e10cSrcweir //! was passiert beim Markieren mit dem Cursor ??? 2202*cdf0e10cSrcweir } 2203*cdf0e10cSrcweir else // nur Cursor bewegen 2204*cdf0e10cSrcweir { 2205*cdf0e10cSrcweir ScAddress aScAddress( pViewData->GetCurX(), pViewData->GetCurY(), 0 ); 2206*cdf0e10cSrcweir aScAddress.Format( aAddr, SCA_ABS ); 2207*cdf0e10cSrcweir } 2208*cdf0e10cSrcweir 2209*cdf0e10cSrcweir SfxStringItem aPosItem( SID_CURRENTCELL, aAddr ); 2210*cdf0e10cSrcweir pDisp->Execute( SID_CURRENTCELL, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, 2211*cdf0e10cSrcweir &aPosItem, (void*)0L ); 2212*cdf0e10cSrcweir 2213*cdf0e10cSrcweir pViewData->GetView()->InvalidateAttribs(); 2214*cdf0e10cSrcweir } 2215*cdf0e10cSrcweir return; 2216*cdf0e10cSrcweir } 2217*cdf0e10cSrcweir } 2218*cdf0e10cSrcweir 2219*cdf0e10cSrcweir void ScGridWindow::FakeButtonUp() 2220*cdf0e10cSrcweir { 2221*cdf0e10cSrcweir if ( nButtonDown ) 2222*cdf0e10cSrcweir { 2223*cdf0e10cSrcweir MouseEvent aEvent( aCurMousePos ); // nButtons = 0 -> ignore 2224*cdf0e10cSrcweir MouseButtonUp( aEvent ); 2225*cdf0e10cSrcweir } 2226*cdf0e10cSrcweir } 2227*cdf0e10cSrcweir 2228*cdf0e10cSrcweir void __EXPORT ScGridWindow::MouseMove( const MouseEvent& rMEvt ) 2229*cdf0e10cSrcweir { 2230*cdf0e10cSrcweir aCurMousePos = rMEvt.GetPosPixel(); 2231*cdf0e10cSrcweir 2232*cdf0e10cSrcweir if ( rMEvt.IsLeaveWindow() && pNoteMarker && !pNoteMarker->IsByKeyboard() ) 2233*cdf0e10cSrcweir HideNoteMarker(); 2234*cdf0e10cSrcweir 2235*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 2236*cdf0e10cSrcweir if (pScMod->IsModalMode(pViewData->GetSfxDocShell())) 2237*cdf0e10cSrcweir return; 2238*cdf0e10cSrcweir 2239*cdf0e10cSrcweir // Ob aus dem Edit-Modus Drag&Drop gestartet wurde, bekommt man leider 2240*cdf0e10cSrcweir // nicht anders mit: 2241*cdf0e10cSrcweir 2242*cdf0e10cSrcweir if (bEEMouse && nButtonDown && !rMEvt.GetButtons()) 2243*cdf0e10cSrcweir { 2244*cdf0e10cSrcweir bEEMouse = sal_False; 2245*cdf0e10cSrcweir nButtonDown = 0; 2246*cdf0e10cSrcweir nMouseStatus = SC_GM_NONE; 2247*cdf0e10cSrcweir return; 2248*cdf0e10cSrcweir } 2249*cdf0e10cSrcweir 2250*cdf0e10cSrcweir if (nMouseStatus == SC_GM_IGNORE) 2251*cdf0e10cSrcweir return; 2252*cdf0e10cSrcweir 2253*cdf0e10cSrcweir if (nMouseStatus == SC_GM_WATERUNDO) // Undo im Giesskannenmodus -> nur auf Up warten 2254*cdf0e10cSrcweir return; 2255*cdf0e10cSrcweir 2256*cdf0e10cSrcweir if ( pViewData->GetViewShell()->IsAuditShell() ) // Detektiv-Fuell-Modus 2257*cdf0e10cSrcweir { 2258*cdf0e10cSrcweir SetPointer( Pointer( POINTER_FILL ) ); 2259*cdf0e10cSrcweir return; 2260*cdf0e10cSrcweir } 2261*cdf0e10cSrcweir 2262*cdf0e10cSrcweir if (nMouseStatus == SC_GM_FILTER && pFilterBox) 2263*cdf0e10cSrcweir { 2264*cdf0e10cSrcweir Point aRelPos = pFilterBox->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) ); 2265*cdf0e10cSrcweir if ( Rectangle(Point(),pFilterBox->GetOutputSizePixel()).IsInside(aRelPos) ) 2266*cdf0e10cSrcweir { 2267*cdf0e10cSrcweir nButtonDown = 0; 2268*cdf0e10cSrcweir nMouseStatus = SC_GM_NONE; 2269*cdf0e10cSrcweir if ( pFilterBox->GetMode() == SC_FILTERBOX_FILTER ) 2270*cdf0e10cSrcweir { 2271*cdf0e10cSrcweir if (mpFilterButton.get()) 2272*cdf0e10cSrcweir { 2273*cdf0e10cSrcweir mpFilterButton->setHasHiddenMember(false); 2274*cdf0e10cSrcweir mpFilterButton->setPopupPressed(false); 2275*cdf0e10cSrcweir HideCursor(); 2276*cdf0e10cSrcweir mpFilterButton->draw(); 2277*cdf0e10cSrcweir ShowCursor(); 2278*cdf0e10cSrcweir } 2279*cdf0e10cSrcweir } 2280*cdf0e10cSrcweir ReleaseMouse(); 2281*cdf0e10cSrcweir pFilterBox->MouseButtonDown( MouseEvent( aRelPos, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT ) ); 2282*cdf0e10cSrcweir return; 2283*cdf0e10cSrcweir } 2284*cdf0e10cSrcweir } 2285*cdf0e10cSrcweir 2286*cdf0e10cSrcweir sal_Bool bFormulaMode = pScMod->IsFormulaMode(); // naechster Klick -> Referenz 2287*cdf0e10cSrcweir 2288*cdf0e10cSrcweir if (bEEMouse && pViewData->HasEditView( eWhich )) 2289*cdf0e10cSrcweir { 2290*cdf0e10cSrcweir EditView* pEditView; 2291*cdf0e10cSrcweir SCCOL nEditCol; 2292*cdf0e10cSrcweir SCROW nEditRow; 2293*cdf0e10cSrcweir pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); 2294*cdf0e10cSrcweir pEditView->MouseMove( rMEvt ); 2295*cdf0e10cSrcweir return; 2296*cdf0e10cSrcweir } 2297*cdf0e10cSrcweir 2298*cdf0e10cSrcweir if (bDPMouse) 2299*cdf0e10cSrcweir { 2300*cdf0e10cSrcweir DPMouseMove( rMEvt ); 2301*cdf0e10cSrcweir return; 2302*cdf0e10cSrcweir } 2303*cdf0e10cSrcweir 2304*cdf0e10cSrcweir if (bRFMouse) 2305*cdf0e10cSrcweir { 2306*cdf0e10cSrcweir RFMouseMove( rMEvt, sal_False ); 2307*cdf0e10cSrcweir return; 2308*cdf0e10cSrcweir } 2309*cdf0e10cSrcweir 2310*cdf0e10cSrcweir if (nPagebreakMouse) 2311*cdf0e10cSrcweir { 2312*cdf0e10cSrcweir PagebreakMove( rMEvt, sal_False ); 2313*cdf0e10cSrcweir return; 2314*cdf0e10cSrcweir } 2315*cdf0e10cSrcweir 2316*cdf0e10cSrcweir // anderen Mauszeiger anzeigen? 2317*cdf0e10cSrcweir 2318*cdf0e10cSrcweir sal_Bool bEditMode = pViewData->HasEditView(eWhich); 2319*cdf0e10cSrcweir 2320*cdf0e10cSrcweir //! Testen ob RefMode-Dragging !!! 2321*cdf0e10cSrcweir if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) ) 2322*cdf0e10cSrcweir { 2323*cdf0e10cSrcweir Point aPos = rMEvt.GetPosPixel(); 2324*cdf0e10cSrcweir SCsCOL nPosX; 2325*cdf0e10cSrcweir SCsROW nPosY; 2326*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 2327*cdf0e10cSrcweir 2328*cdf0e10cSrcweir EditView* pEditView; 2329*cdf0e10cSrcweir SCCOL nEditCol; 2330*cdf0e10cSrcweir SCROW nEditRow; 2331*cdf0e10cSrcweir pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); 2332*cdf0e10cSrcweir SCCOL nEndCol = pViewData->GetEditEndCol(); 2333*cdf0e10cSrcweir SCROW nEndRow = pViewData->GetEditEndRow(); 2334*cdf0e10cSrcweir 2335*cdf0e10cSrcweir if ( nPosX >= (SCsCOL) nEditCol && nPosX <= (SCsCOL) nEndCol && 2336*cdf0e10cSrcweir nPosY >= (SCsROW) nEditRow && nPosY <= (SCsROW) nEndRow ) 2337*cdf0e10cSrcweir { 2338*cdf0e10cSrcweir // Field can only be URL field 2339*cdf0e10cSrcweir sal_Bool bAlt = rMEvt.IsMod2(); 2340*cdf0e10cSrcweir if ( !bAlt && !nButtonDown && pEditView && pEditView->GetFieldUnderMousePointer() ) 2341*cdf0e10cSrcweir SetPointer( Pointer( POINTER_REFHAND ) ); 2342*cdf0e10cSrcweir else if ( pEditView && pEditView->GetEditEngine()->IsVertical() ) 2343*cdf0e10cSrcweir SetPointer( Pointer( POINTER_TEXT_VERTICAL ) ); 2344*cdf0e10cSrcweir else 2345*cdf0e10cSrcweir SetPointer( Pointer( POINTER_TEXT ) ); 2346*cdf0e10cSrcweir return; 2347*cdf0e10cSrcweir } 2348*cdf0e10cSrcweir } 2349*cdf0e10cSrcweir 2350*cdf0e10cSrcweir sal_Bool bWater = SC_MOD()->GetIsWaterCan() || pViewData->GetView()->HasPaintBrush(); 2351*cdf0e10cSrcweir if (bWater) 2352*cdf0e10cSrcweir SetPointer( Pointer(POINTER_FILL) ); 2353*cdf0e10cSrcweir 2354*cdf0e10cSrcweir if (!bWater) 2355*cdf0e10cSrcweir { 2356*cdf0e10cSrcweir sal_Bool bCross = sal_False; 2357*cdf0e10cSrcweir 2358*cdf0e10cSrcweir // Range-Finder 2359*cdf0e10cSrcweir 2360*cdf0e10cSrcweir sal_Bool bCorner; 2361*cdf0e10cSrcweir if ( HitRangeFinder( rMEvt.GetPosPixel(), bCorner ) ) 2362*cdf0e10cSrcweir { 2363*cdf0e10cSrcweir if (bCorner) 2364*cdf0e10cSrcweir SetPointer( Pointer( POINTER_CROSS ) ); 2365*cdf0e10cSrcweir else 2366*cdf0e10cSrcweir SetPointer( Pointer( POINTER_HAND ) ); 2367*cdf0e10cSrcweir bCross = sal_True; 2368*cdf0e10cSrcweir } 2369*cdf0e10cSrcweir 2370*cdf0e10cSrcweir // Page-Break-Modus 2371*cdf0e10cSrcweir 2372*cdf0e10cSrcweir sal_uInt16 nBreakType; 2373*cdf0e10cSrcweir if ( !nButtonDown && pViewData->IsPagebreakMode() && 2374*cdf0e10cSrcweir ( nBreakType = HitPageBreak( rMEvt.GetPosPixel() ) ) != 0 ) 2375*cdf0e10cSrcweir { 2376*cdf0e10cSrcweir PointerStyle eNew = POINTER_ARROW; 2377*cdf0e10cSrcweir switch ( nBreakType ) 2378*cdf0e10cSrcweir { 2379*cdf0e10cSrcweir case SC_PD_RANGE_L: 2380*cdf0e10cSrcweir case SC_PD_RANGE_R: 2381*cdf0e10cSrcweir case SC_PD_BREAK_H: 2382*cdf0e10cSrcweir eNew = POINTER_ESIZE; 2383*cdf0e10cSrcweir break; 2384*cdf0e10cSrcweir case SC_PD_RANGE_T: 2385*cdf0e10cSrcweir case SC_PD_RANGE_B: 2386*cdf0e10cSrcweir case SC_PD_BREAK_V: 2387*cdf0e10cSrcweir eNew = POINTER_SSIZE; 2388*cdf0e10cSrcweir break; 2389*cdf0e10cSrcweir case SC_PD_RANGE_TL: 2390*cdf0e10cSrcweir case SC_PD_RANGE_BR: 2391*cdf0e10cSrcweir eNew = POINTER_SESIZE; 2392*cdf0e10cSrcweir break; 2393*cdf0e10cSrcweir case SC_PD_RANGE_TR: 2394*cdf0e10cSrcweir case SC_PD_RANGE_BL: 2395*cdf0e10cSrcweir eNew = POINTER_NESIZE; 2396*cdf0e10cSrcweir break; 2397*cdf0e10cSrcweir } 2398*cdf0e10cSrcweir SetPointer( Pointer( eNew ) ); 2399*cdf0e10cSrcweir bCross = sal_True; 2400*cdf0e10cSrcweir } 2401*cdf0e10cSrcweir 2402*cdf0e10cSrcweir // Fill-Cursor anzeigen ? 2403*cdf0e10cSrcweir 2404*cdf0e10cSrcweir if ( !bFormulaMode && !nButtonDown ) 2405*cdf0e10cSrcweir if (TestMouse( rMEvt, sal_False )) 2406*cdf0e10cSrcweir bCross = sal_True; 2407*cdf0e10cSrcweir 2408*cdf0e10cSrcweir if ( nButtonDown && pViewData->IsAnyFillMode() ) 2409*cdf0e10cSrcweir { 2410*cdf0e10cSrcweir SetPointer( Pointer( POINTER_CROSS ) ); 2411*cdf0e10cSrcweir bCross = sal_True; 2412*cdf0e10cSrcweir nScFillModeMouseModifier = rMEvt.GetModifier(); // ausgewertet bei AutoFill und Matrix 2413*cdf0e10cSrcweir } 2414*cdf0e10cSrcweir 2415*cdf0e10cSrcweir if (!bCross) 2416*cdf0e10cSrcweir { 2417*cdf0e10cSrcweir sal_Bool bAlt = rMEvt.IsMod2(); 2418*cdf0e10cSrcweir 2419*cdf0e10cSrcweir if (bEditMode) // Edit-Mode muss zuerst kommen! 2420*cdf0e10cSrcweir SetPointer( Pointer( POINTER_ARROW ) ); 2421*cdf0e10cSrcweir else if ( !bAlt && !nButtonDown && 2422*cdf0e10cSrcweir GetEditUrl(rMEvt.GetPosPixel()) ) 2423*cdf0e10cSrcweir SetPointer( Pointer( POINTER_REFHAND ) ); 2424*cdf0e10cSrcweir else if ( DrawMouseMove(rMEvt) ) // setzt Pointer um 2425*cdf0e10cSrcweir return; 2426*cdf0e10cSrcweir } 2427*cdf0e10cSrcweir } 2428*cdf0e10cSrcweir 2429*cdf0e10cSrcweir if ( pViewData->GetView()->GetSelEngine()->SelMouseMove( rMEvt ) ) 2430*cdf0e10cSrcweir return; 2431*cdf0e10cSrcweir } 2432*cdf0e10cSrcweir 2433*cdf0e10cSrcweir void lcl_InitMouseEvent( ::com::sun::star::awt::MouseEvent& rEvent, const MouseEvent& rEvt ) 2434*cdf0e10cSrcweir { 2435*cdf0e10cSrcweir rEvent.Modifiers = 0; 2436*cdf0e10cSrcweir if ( rEvt.IsShift() ) 2437*cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::SHIFT; 2438*cdf0e10cSrcweir if ( rEvt.IsMod1() ) 2439*cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD1; 2440*cdf0e10cSrcweir if ( rEvt.IsMod2() ) 2441*cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD2; 2442*cdf0e10cSrcweir if ( rEvt.IsMod3() ) 2443*cdf0e10cSrcweir rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD3; 2444*cdf0e10cSrcweir 2445*cdf0e10cSrcweir rEvent.Buttons = 0; 2446*cdf0e10cSrcweir if ( rEvt.IsLeft() ) 2447*cdf0e10cSrcweir rEvent.Buttons |= ::com::sun::star::awt::MouseButton::LEFT; 2448*cdf0e10cSrcweir if ( rEvt.IsRight() ) 2449*cdf0e10cSrcweir rEvent.Buttons |= ::com::sun::star::awt::MouseButton::RIGHT; 2450*cdf0e10cSrcweir if ( rEvt.IsMiddle() ) 2451*cdf0e10cSrcweir rEvent.Buttons |= ::com::sun::star::awt::MouseButton::MIDDLE; 2452*cdf0e10cSrcweir 2453*cdf0e10cSrcweir rEvent.X = rEvt.GetPosPixel().X(); 2454*cdf0e10cSrcweir rEvent.Y = rEvt.GetPosPixel().Y(); 2455*cdf0e10cSrcweir rEvent.ClickCount = rEvt.GetClicks(); 2456*cdf0e10cSrcweir rEvent.PopupTrigger = sal_False; 2457*cdf0e10cSrcweir } 2458*cdf0e10cSrcweir 2459*cdf0e10cSrcweir long ScGridWindow::PreNotify( NotifyEvent& rNEvt ) 2460*cdf0e10cSrcweir { 2461*cdf0e10cSrcweir bool bDone = false; 2462*cdf0e10cSrcweir sal_uInt16 nType = rNEvt.GetType(); 2463*cdf0e10cSrcweir if ( nType == EVENT_MOUSEBUTTONUP || nType == EVENT_MOUSEBUTTONDOWN ) 2464*cdf0e10cSrcweir { 2465*cdf0e10cSrcweir Window* pWindow = rNEvt.GetWindow(); 2466*cdf0e10cSrcweir if (pWindow == this && pViewData) 2467*cdf0e10cSrcweir { 2468*cdf0e10cSrcweir SfxViewFrame* pViewFrame = pViewData->GetViewShell()->GetViewFrame(); 2469*cdf0e10cSrcweir if (pViewFrame) 2470*cdf0e10cSrcweir { 2471*cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::frame::XController> xController = pViewFrame->GetFrame().GetController(); 2472*cdf0e10cSrcweir if (xController.is()) 2473*cdf0e10cSrcweir { 2474*cdf0e10cSrcweir ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController ); 2475*cdf0e10cSrcweir if (pImp && pImp->IsMouseListening()) 2476*cdf0e10cSrcweir { 2477*cdf0e10cSrcweir ::com::sun::star::awt::MouseEvent aEvent; 2478*cdf0e10cSrcweir lcl_InitMouseEvent( aEvent, *rNEvt.GetMouseEvent() ); 2479*cdf0e10cSrcweir if ( rNEvt.GetWindow() ) 2480*cdf0e10cSrcweir aEvent.Source = rNEvt.GetWindow()->GetComponentInterface(); 2481*cdf0e10cSrcweir if ( nType == EVENT_MOUSEBUTTONDOWN) 2482*cdf0e10cSrcweir bDone = pImp->MousePressed( aEvent ); 2483*cdf0e10cSrcweir else 2484*cdf0e10cSrcweir bDone = pImp->MouseReleased( aEvent ); 2485*cdf0e10cSrcweir } 2486*cdf0e10cSrcweir } 2487*cdf0e10cSrcweir } 2488*cdf0e10cSrcweir } 2489*cdf0e10cSrcweir } 2490*cdf0e10cSrcweir if (bDone) // event consumed by a listener 2491*cdf0e10cSrcweir { 2492*cdf0e10cSrcweir if ( nType == EVENT_MOUSEBUTTONDOWN ) 2493*cdf0e10cSrcweir { 2494*cdf0e10cSrcweir const MouseEvent* pMouseEvent = rNEvt.GetMouseEvent(); 2495*cdf0e10cSrcweir if ( pMouseEvent->IsRight() && pMouseEvent->GetClicks() == 1 ) 2496*cdf0e10cSrcweir { 2497*cdf0e10cSrcweir // If a listener returned true for a right-click call, also prevent opening the context menu 2498*cdf0e10cSrcweir // (this works only if the context menu is opened on mouse-down) 2499*cdf0e10cSrcweir nMouseStatus = SC_GM_IGNORE; 2500*cdf0e10cSrcweir } 2501*cdf0e10cSrcweir } 2502*cdf0e10cSrcweir 2503*cdf0e10cSrcweir return 1; 2504*cdf0e10cSrcweir } 2505*cdf0e10cSrcweir else 2506*cdf0e10cSrcweir return Window::PreNotify( rNEvt ); 2507*cdf0e10cSrcweir } 2508*cdf0e10cSrcweir 2509*cdf0e10cSrcweir void ScGridWindow::Tracking( const TrackingEvent& rTEvt ) 2510*cdf0e10cSrcweir { 2511*cdf0e10cSrcweir // Weil die SelectionEngine kein Tracking kennt, die Events nur auf 2512*cdf0e10cSrcweir // die verschiedenen MouseHandler verteilen... 2513*cdf0e10cSrcweir 2514*cdf0e10cSrcweir const MouseEvent& rMEvt = rTEvt.GetMouseEvent(); 2515*cdf0e10cSrcweir 2516*cdf0e10cSrcweir if ( rTEvt.IsTrackingCanceled() ) // alles abbrechen... 2517*cdf0e10cSrcweir { 2518*cdf0e10cSrcweir if (!pViewData->GetView()->IsInActivatePart()) 2519*cdf0e10cSrcweir { 2520*cdf0e10cSrcweir if (bDPMouse) 2521*cdf0e10cSrcweir bDPMouse = sal_False; // gezeichnet wird per bDragRect 2522*cdf0e10cSrcweir if (bDragRect) 2523*cdf0e10cSrcweir { 2524*cdf0e10cSrcweir // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); 2525*cdf0e10cSrcweir bDragRect = sal_False; 2526*cdf0e10cSrcweir UpdateDragRectOverlay(); 2527*cdf0e10cSrcweir } 2528*cdf0e10cSrcweir if (bRFMouse) 2529*cdf0e10cSrcweir { 2530*cdf0e10cSrcweir RFMouseMove( rMEvt, sal_True ); // richtig abbrechen geht dabei nicht... 2531*cdf0e10cSrcweir bRFMouse = sal_False; 2532*cdf0e10cSrcweir } 2533*cdf0e10cSrcweir if (nPagebreakMouse) 2534*cdf0e10cSrcweir { 2535*cdf0e10cSrcweir // if (bPagebreakDrawn) 2536*cdf0e10cSrcweir // DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(), 2537*cdf0e10cSrcweir // aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), sal_False ); 2538*cdf0e10cSrcweir bPagebreakDrawn = sal_False; 2539*cdf0e10cSrcweir UpdateDragRectOverlay(); 2540*cdf0e10cSrcweir nPagebreakMouse = SC_PD_NONE; 2541*cdf0e10cSrcweir } 2542*cdf0e10cSrcweir 2543*cdf0e10cSrcweir SetPointer( Pointer( POINTER_ARROW ) ); 2544*cdf0e10cSrcweir StopMarking(); 2545*cdf0e10cSrcweir MouseButtonUp( rMEvt ); // mit Status SC_GM_IGNORE aus StopMarking 2546*cdf0e10cSrcweir 2547*cdf0e10cSrcweir sal_Bool bRefMode = pViewData->IsRefMode(); 2548*cdf0e10cSrcweir if (bRefMode) 2549*cdf0e10cSrcweir SC_MOD()->EndReference(); // #63148# Dialog nicht verkleinert lassen 2550*cdf0e10cSrcweir } 2551*cdf0e10cSrcweir } 2552*cdf0e10cSrcweir else if ( rTEvt.IsTrackingEnded() ) 2553*cdf0e10cSrcweir { 2554*cdf0e10cSrcweir // MouseButtonUp immer mit passenden Buttons (z.B. wegen Testtool, #63148#) 2555*cdf0e10cSrcweir // Schliesslich behauptet der Tracking-Event ja, dass normal beendet und nicht 2556*cdf0e10cSrcweir // abgebrochen wurde. 2557*cdf0e10cSrcweir 2558*cdf0e10cSrcweir MouseEvent aUpEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(), 2559*cdf0e10cSrcweir rMEvt.GetMode(), nButtonDown, rMEvt.GetModifier() ); 2560*cdf0e10cSrcweir MouseButtonUp( aUpEvt ); 2561*cdf0e10cSrcweir } 2562*cdf0e10cSrcweir else 2563*cdf0e10cSrcweir MouseMove( rMEvt ); 2564*cdf0e10cSrcweir } 2565*cdf0e10cSrcweir 2566*cdf0e10cSrcweir void ScGridWindow::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel ) 2567*cdf0e10cSrcweir { 2568*cdf0e10cSrcweir if ( pFilterBox || nPagebreakMouse ) 2569*cdf0e10cSrcweir return; 2570*cdf0e10cSrcweir 2571*cdf0e10cSrcweir HideNoteMarker(); 2572*cdf0e10cSrcweir 2573*cdf0e10cSrcweir CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, sal_True ); 2574*cdf0e10cSrcweir 2575*cdf0e10cSrcweir if (bEEMouse && pViewData->HasEditView( eWhich )) 2576*cdf0e10cSrcweir { 2577*cdf0e10cSrcweir EditView* pEditView; 2578*cdf0e10cSrcweir SCCOL nEditCol; 2579*cdf0e10cSrcweir SCROW nEditRow; 2580*cdf0e10cSrcweir pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow ); 2581*cdf0e10cSrcweir 2582*cdf0e10cSrcweir // #63263# don't remove the edit view while switching views 2583*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 2584*cdf0e10cSrcweir pScMod->SetInEditCommand( sal_True ); 2585*cdf0e10cSrcweir 2586*cdf0e10cSrcweir pEditView->Command( aDragEvent ); 2587*cdf0e10cSrcweir 2588*cdf0e10cSrcweir ScInputHandler* pHdl = pScMod->GetInputHdl(); 2589*cdf0e10cSrcweir if (pHdl) 2590*cdf0e10cSrcweir pHdl->DataChanged(); 2591*cdf0e10cSrcweir 2592*cdf0e10cSrcweir pScMod->SetInEditCommand( sal_False ); 2593*cdf0e10cSrcweir if (!pViewData->IsActive()) // dropped to different view? 2594*cdf0e10cSrcweir { 2595*cdf0e10cSrcweir ScInputHandler* pViewHdl = pScMod->GetInputHdl( pViewData->GetViewShell() ); 2596*cdf0e10cSrcweir if ( pViewHdl && pViewData->HasEditView( eWhich ) ) 2597*cdf0e10cSrcweir { 2598*cdf0e10cSrcweir pViewHdl->CancelHandler(); 2599*cdf0e10cSrcweir ShowCursor(); // missing from KillEditView 2600*cdf0e10cSrcweir } 2601*cdf0e10cSrcweir } 2602*cdf0e10cSrcweir } 2603*cdf0e10cSrcweir else 2604*cdf0e10cSrcweir if ( !DrawCommand(aDragEvent) ) 2605*cdf0e10cSrcweir pViewData->GetView()->GetSelEngine()->Command( aDragEvent ); 2606*cdf0e10cSrcweir } 2607*cdf0e10cSrcweir 2608*cdf0e10cSrcweir void lcl_SetTextCursorPos( ScViewData* pViewData, ScSplitPos eWhich, Window* pWin ) 2609*cdf0e10cSrcweir { 2610*cdf0e10cSrcweir SCCOL nCol = pViewData->GetCurX(); 2611*cdf0e10cSrcweir SCROW nRow = pViewData->GetCurY(); 2612*cdf0e10cSrcweir Rectangle aEditArea = pViewData->GetEditArea( eWhich, nCol, nRow, pWin, NULL, sal_True ); 2613*cdf0e10cSrcweir aEditArea.Right() = aEditArea.Left(); 2614*cdf0e10cSrcweir aEditArea = pWin->PixelToLogic( aEditArea ); 2615*cdf0e10cSrcweir pWin->SetCursorRect( &aEditArea ); 2616*cdf0e10cSrcweir } 2617*cdf0e10cSrcweir 2618*cdf0e10cSrcweir void __EXPORT ScGridWindow::Command( const CommandEvent& rCEvt ) 2619*cdf0e10cSrcweir { 2620*cdf0e10cSrcweir // The command event is send to the window after a possible context 2621*cdf0e10cSrcweir // menu from an inplace client is closed. Now we have the chance to 2622*cdf0e10cSrcweir // deactivate the inplace client without any problem regarding parent 2623*cdf0e10cSrcweir // windows and code on the stack. 2624*cdf0e10cSrcweir // For more information, see #126086# and #128122# 2625*cdf0e10cSrcweir sal_uInt16 nCmd = rCEvt.GetCommand(); 2626*cdf0e10cSrcweir ScTabViewShell* pTabViewSh = pViewData->GetViewShell(); 2627*cdf0e10cSrcweir SfxInPlaceClient* pClient = pTabViewSh->GetIPClient(); 2628*cdf0e10cSrcweir if ( pClient && 2629*cdf0e10cSrcweir pClient->IsObjectInPlaceActive() && 2630*cdf0e10cSrcweir nCmd == COMMAND_CONTEXTMENU ) 2631*cdf0e10cSrcweir { 2632*cdf0e10cSrcweir pTabViewSh->DeactivateOle(); 2633*cdf0e10cSrcweir return; 2634*cdf0e10cSrcweir } 2635*cdf0e10cSrcweir 2636*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 2637*cdf0e10cSrcweir DBG_ASSERT( nCmd != COMMAND_STARTDRAG, "ScGridWindow::Command called with COMMAND_STARTDRAG" ); 2638*cdf0e10cSrcweir 2639*cdf0e10cSrcweir if ( nCmd == COMMAND_STARTEXTTEXTINPUT || 2640*cdf0e10cSrcweir nCmd == COMMAND_ENDEXTTEXTINPUT || 2641*cdf0e10cSrcweir nCmd == COMMAND_EXTTEXTINPUT || 2642*cdf0e10cSrcweir nCmd == COMMAND_CURSORPOS ) 2643*cdf0e10cSrcweir { 2644*cdf0e10cSrcweir sal_Bool bEditView = pViewData->HasEditView( eWhich ); 2645*cdf0e10cSrcweir if (!bEditView) 2646*cdf0e10cSrcweir { 2647*cdf0e10cSrcweir // only if no cell editview is active, look at drawview 2648*cdf0e10cSrcweir SdrView* pSdrView = pViewData->GetView()->GetSdrView(); 2649*cdf0e10cSrcweir if ( pSdrView ) 2650*cdf0e10cSrcweir { 2651*cdf0e10cSrcweir OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView(); 2652*cdf0e10cSrcweir if ( pOlView && pOlView->GetWindow() == this ) 2653*cdf0e10cSrcweir { 2654*cdf0e10cSrcweir pOlView->Command( rCEvt ); 2655*cdf0e10cSrcweir return; // done 2656*cdf0e10cSrcweir } 2657*cdf0e10cSrcweir } 2658*cdf0e10cSrcweir } 2659*cdf0e10cSrcweir 2660*cdf0e10cSrcweir if ( nCmd == COMMAND_CURSORPOS && !bEditView ) 2661*cdf0e10cSrcweir { 2662*cdf0e10cSrcweir // #88458# CURSORPOS may be called without following text input, 2663*cdf0e10cSrcweir // to set the input method window position 2664*cdf0e10cSrcweir // -> input mode must not be started, 2665*cdf0e10cSrcweir // manually calculate text insert position if not in input mode 2666*cdf0e10cSrcweir 2667*cdf0e10cSrcweir lcl_SetTextCursorPos( pViewData, eWhich, this ); 2668*cdf0e10cSrcweir return; 2669*cdf0e10cSrcweir } 2670*cdf0e10cSrcweir 2671*cdf0e10cSrcweir ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() ); 2672*cdf0e10cSrcweir if ( pHdl ) 2673*cdf0e10cSrcweir { 2674*cdf0e10cSrcweir pHdl->InputCommand( rCEvt, sal_True ); 2675*cdf0e10cSrcweir return; // done 2676*cdf0e10cSrcweir } 2677*cdf0e10cSrcweir 2678*cdf0e10cSrcweir Window::Command( rCEvt ); 2679*cdf0e10cSrcweir return; 2680*cdf0e10cSrcweir } 2681*cdf0e10cSrcweir 2682*cdf0e10cSrcweir if ( nCmd == COMMAND_VOICE ) 2683*cdf0e10cSrcweir { 2684*cdf0e10cSrcweir // Der Handler wird nur gerufen, wenn ein Text-Cursor aktiv ist, 2685*cdf0e10cSrcweir // also muss es eine EditView oder ein editiertes Zeichenobjekt geben 2686*cdf0e10cSrcweir 2687*cdf0e10cSrcweir ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() ); 2688*cdf0e10cSrcweir if ( pHdl && pViewData->HasEditView( eWhich ) ) 2689*cdf0e10cSrcweir { 2690*cdf0e10cSrcweir EditView* pEditView = pViewData->GetEditView( eWhich ); // ist dann nicht 0 2691*cdf0e10cSrcweir pHdl->DataChanging(); 2692*cdf0e10cSrcweir pEditView->Command( rCEvt ); 2693*cdf0e10cSrcweir pHdl->DataChanged(); 2694*cdf0e10cSrcweir return; // erledigt 2695*cdf0e10cSrcweir } 2696*cdf0e10cSrcweir SdrView* pSdrView = pViewData->GetView()->GetSdrView(); 2697*cdf0e10cSrcweir if ( pSdrView ) 2698*cdf0e10cSrcweir { 2699*cdf0e10cSrcweir OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView(); 2700*cdf0e10cSrcweir if ( pOlView && pOlView->GetWindow() == this ) 2701*cdf0e10cSrcweir { 2702*cdf0e10cSrcweir pOlView->Command( rCEvt ); 2703*cdf0e10cSrcweir return; // erledigt 2704*cdf0e10cSrcweir } 2705*cdf0e10cSrcweir } 2706*cdf0e10cSrcweir Window::Command(rCEvt); // sonst soll sich die Basisklasse drum kuemmern... 2707*cdf0e10cSrcweir return; 2708*cdf0e10cSrcweir } 2709*cdf0e10cSrcweir 2710*cdf0e10cSrcweir if ( nCmd == COMMAND_PASTESELECTION ) 2711*cdf0e10cSrcweir { 2712*cdf0e10cSrcweir if ( bEEMouse ) 2713*cdf0e10cSrcweir { 2714*cdf0e10cSrcweir // EditEngine handles selection in MouseButtonUp - no action 2715*cdf0e10cSrcweir // needed in command handler 2716*cdf0e10cSrcweir } 2717*cdf0e10cSrcweir else 2718*cdf0e10cSrcweir { 2719*cdf0e10cSrcweir PasteSelection( rCEvt.GetMousePosPixel() ); 2720*cdf0e10cSrcweir } 2721*cdf0e10cSrcweir return; 2722*cdf0e10cSrcweir } 2723*cdf0e10cSrcweir 2724*cdf0e10cSrcweir if ( nCmd == COMMAND_INPUTLANGUAGECHANGE ) 2725*cdf0e10cSrcweir { 2726*cdf0e10cSrcweir // #i55929# Font and font size state depends on input language if nothing is selected, 2727*cdf0e10cSrcweir // so the slots have to be invalidated when the input language is changed. 2728*cdf0e10cSrcweir 2729*cdf0e10cSrcweir SfxBindings& rBindings = pViewData->GetBindings(); 2730*cdf0e10cSrcweir rBindings.Invalidate( SID_ATTR_CHAR_FONT ); 2731*cdf0e10cSrcweir rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); 2732*cdf0e10cSrcweir return; 2733*cdf0e10cSrcweir } 2734*cdf0e10cSrcweir 2735*cdf0e10cSrcweir if ( nCmd == COMMAND_WHEEL || nCmd == COMMAND_STARTAUTOSCROLL || nCmd == COMMAND_AUTOSCROLL ) 2736*cdf0e10cSrcweir { 2737*cdf0e10cSrcweir sal_Bool bDone = pViewData->GetView()->ScrollCommand( rCEvt, eWhich ); 2738*cdf0e10cSrcweir if (!bDone) 2739*cdf0e10cSrcweir Window::Command(rCEvt); 2740*cdf0e10cSrcweir return; 2741*cdf0e10cSrcweir } 2742*cdf0e10cSrcweir // #i7560# FormulaMode check is below scrolling - scrolling is allowed during formula input 2743*cdf0e10cSrcweir sal_Bool bDisable = pScMod->IsFormulaMode() || 2744*cdf0e10cSrcweir pScMod->IsModalMode(pViewData->GetSfxDocShell()); 2745*cdf0e10cSrcweir if (bDisable) 2746*cdf0e10cSrcweir return; 2747*cdf0e10cSrcweir 2748*cdf0e10cSrcweir if ( nCmd == COMMAND_CONTEXTMENU && !SC_MOD()->GetIsWaterCan() ) 2749*cdf0e10cSrcweir { 2750*cdf0e10cSrcweir sal_Bool bMouse = rCEvt.IsMouseEvent(); 2751*cdf0e10cSrcweir if ( bMouse && nMouseStatus == SC_GM_IGNORE ) 2752*cdf0e10cSrcweir return; 2753*cdf0e10cSrcweir 2754*cdf0e10cSrcweir if (pViewData->IsAnyFillMode()) 2755*cdf0e10cSrcweir { 2756*cdf0e10cSrcweir pViewData->GetView()->StopRefMode(); 2757*cdf0e10cSrcweir pViewData->ResetFillMode(); 2758*cdf0e10cSrcweir } 2759*cdf0e10cSrcweir ReleaseMouse(); 2760*cdf0e10cSrcweir StopMarking(); 2761*cdf0e10cSrcweir 2762*cdf0e10cSrcweir Point aPosPixel = rCEvt.GetMousePosPixel(); 2763*cdf0e10cSrcweir Point aMenuPos = aPosPixel; 2764*cdf0e10cSrcweir 2765*cdf0e10cSrcweir if ( bMouse ) 2766*cdf0e10cSrcweir { 2767*cdf0e10cSrcweir SCsCOL nCellX = -1; 2768*cdf0e10cSrcweir SCsROW nCellY = -1; 2769*cdf0e10cSrcweir pViewData->GetPosFromPixel(aPosPixel.X(), aPosPixel.Y(), eWhich, nCellX, nCellY); 2770*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 2771*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 2772*cdf0e10cSrcweir const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab); 2773*cdf0e10cSrcweir bool bSelectAllowed = true; 2774*cdf0e10cSrcweir if ( pProtect && pProtect->isProtected() ) 2775*cdf0e10cSrcweir { 2776*cdf0e10cSrcweir // This sheet is protected. Check if a context menu is allowed on this cell. 2777*cdf0e10cSrcweir bool bCellProtected = pDoc->HasAttrib(nCellX, nCellY, nTab, nCellX, nCellY, nTab, HASATTR_PROTECTED); 2778*cdf0e10cSrcweir bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS); 2779*cdf0e10cSrcweir bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS); 2780*cdf0e10cSrcweir 2781*cdf0e10cSrcweir if (bCellProtected) 2782*cdf0e10cSrcweir bSelectAllowed = bSelProtected; 2783*cdf0e10cSrcweir else 2784*cdf0e10cSrcweir bSelectAllowed = bSelUnprotected; 2785*cdf0e10cSrcweir } 2786*cdf0e10cSrcweir if (!bSelectAllowed) 2787*cdf0e10cSrcweir // Selecting this cell is not allowed, neither is context menu. 2788*cdf0e10cSrcweir return; 2789*cdf0e10cSrcweir 2790*cdf0e10cSrcweir // #i18735# First select the item under the mouse pointer. 2791*cdf0e10cSrcweir // This can change the selection, and the view state (edit mode, etc). 2792*cdf0e10cSrcweir SelectForContextMenu( aPosPixel, nCellX, nCellY ); 2793*cdf0e10cSrcweir } 2794*cdf0e10cSrcweir 2795*cdf0e10cSrcweir sal_Bool bDone = sal_False; 2796*cdf0e10cSrcweir sal_Bool bEdit = pViewData->HasEditView(eWhich); 2797*cdf0e10cSrcweir if ( !bEdit ) 2798*cdf0e10cSrcweir { 2799*cdf0e10cSrcweir // Edit-Zelle mit Spelling-Errors ? 2800*cdf0e10cSrcweir if ( bMouse && GetEditUrlOrError( sal_True, aPosPixel ) ) 2801*cdf0e10cSrcweir { 2802*cdf0e10cSrcweir // GetEditUrlOrError hat den Cursor schon bewegt 2803*cdf0e10cSrcweir 2804*cdf0e10cSrcweir pScMod->SetInputMode( SC_INPUT_TABLE ); 2805*cdf0e10cSrcweir bEdit = pViewData->HasEditView(eWhich); // hat's geklappt ? 2806*cdf0e10cSrcweir 2807*cdf0e10cSrcweir DBG_ASSERT( bEdit, "kann nicht in Edit-Modus schalten" ); 2808*cdf0e10cSrcweir } 2809*cdf0e10cSrcweir } 2810*cdf0e10cSrcweir if ( bEdit ) 2811*cdf0e10cSrcweir { 2812*cdf0e10cSrcweir EditView* pEditView = pViewData->GetEditView( eWhich ); // ist dann nicht 0 2813*cdf0e10cSrcweir 2814*cdf0e10cSrcweir if ( !bMouse ) 2815*cdf0e10cSrcweir { 2816*cdf0e10cSrcweir Cursor* pCur = pEditView->GetCursor(); 2817*cdf0e10cSrcweir if ( pCur ) 2818*cdf0e10cSrcweir { 2819*cdf0e10cSrcweir Point aLogicPos = pCur->GetPos(); 2820*cdf0e10cSrcweir // use the position right of the cursor (spell popup is opened if 2821*cdf0e10cSrcweir // the cursor is before the word, but not if behind it) 2822*cdf0e10cSrcweir aLogicPos.X() += pCur->GetWidth(); 2823*cdf0e10cSrcweir aLogicPos.Y() += pCur->GetHeight() / 2; // center vertically 2824*cdf0e10cSrcweir aMenuPos = LogicToPixel( aLogicPos ); 2825*cdf0e10cSrcweir } 2826*cdf0e10cSrcweir } 2827*cdf0e10cSrcweir 2828*cdf0e10cSrcweir // if edit mode was just started above, online spelling may be incomplete 2829*cdf0e10cSrcweir pEditView->GetEditEngine()->CompleteOnlineSpelling(); 2830*cdf0e10cSrcweir 2831*cdf0e10cSrcweir // IsCursorAtWrongSpelledWord could be used for !bMouse 2832*cdf0e10cSrcweir // if there was a corresponding ExecuteSpellPopup call 2833*cdf0e10cSrcweir 2834*cdf0e10cSrcweir if( pEditView->IsWrongSpelledWordAtPos( aMenuPos ) ) 2835*cdf0e10cSrcweir { 2836*cdf0e10cSrcweir // Wenn man unter OS/2 neben das Popupmenue klickt, kommt MouseButtonDown 2837*cdf0e10cSrcweir // vor dem Ende des Menue-Execute, darum muss SetModified vorher kommen 2838*cdf0e10cSrcweir // (Bug #40968#) 2839*cdf0e10cSrcweir ScInputHandler* pHdl = pScMod->GetInputHdl(); 2840*cdf0e10cSrcweir if (pHdl) 2841*cdf0e10cSrcweir pHdl->SetModified(); 2842*cdf0e10cSrcweir 2843*cdf0e10cSrcweir Link aLink = LINK( this, ScGridWindow, PopupSpellingHdl ); 2844*cdf0e10cSrcweir pEditView->ExecuteSpellPopup( aMenuPos, &aLink ); 2845*cdf0e10cSrcweir 2846*cdf0e10cSrcweir bDone = sal_True; 2847*cdf0e10cSrcweir } 2848*cdf0e10cSrcweir } 2849*cdf0e10cSrcweir else if ( !bMouse ) 2850*cdf0e10cSrcweir { 2851*cdf0e10cSrcweir // non-edit menu by keyboard -> use lower right of cell cursor position 2852*cdf0e10cSrcweir 2853*cdf0e10cSrcweir SCCOL nCurX = pViewData->GetCurX(); 2854*cdf0e10cSrcweir SCROW nCurY = pViewData->GetCurY(); 2855*cdf0e10cSrcweir aMenuPos = pViewData->GetScrPos( nCurX, nCurY, eWhich, sal_True ); 2856*cdf0e10cSrcweir long nSizeXPix; 2857*cdf0e10cSrcweir long nSizeYPix; 2858*cdf0e10cSrcweir pViewData->GetMergeSizePixel( nCurX, nCurY, nSizeXPix, nSizeYPix ); 2859*cdf0e10cSrcweir aMenuPos.X() += nSizeXPix; 2860*cdf0e10cSrcweir aMenuPos.Y() += nSizeYPix; 2861*cdf0e10cSrcweir 2862*cdf0e10cSrcweir if (pViewData) 2863*cdf0e10cSrcweir { 2864*cdf0e10cSrcweir ScTabViewShell* pViewSh = pViewData->GetViewShell(); 2865*cdf0e10cSrcweir if (pViewSh) 2866*cdf0e10cSrcweir { 2867*cdf0e10cSrcweir // Is a draw object selected? 2868*cdf0e10cSrcweir 2869*cdf0e10cSrcweir SdrView* pDrawView = pViewSh->GetSdrView(); 2870*cdf0e10cSrcweir if (pDrawView && pDrawView->AreObjectsMarked()) 2871*cdf0e10cSrcweir { 2872*cdf0e10cSrcweir // #100442#; the conext menu should open in the middle of the selected objects 2873*cdf0e10cSrcweir Rectangle aSelectRect(LogicToPixel(pDrawView->GetAllMarkedBoundRect())); 2874*cdf0e10cSrcweir aMenuPos = aSelectRect.Center(); 2875*cdf0e10cSrcweir } 2876*cdf0e10cSrcweir } 2877*cdf0e10cSrcweir } 2878*cdf0e10cSrcweir } 2879*cdf0e10cSrcweir 2880*cdf0e10cSrcweir if (!bDone) 2881*cdf0e10cSrcweir { 2882*cdf0e10cSrcweir SfxDispatcher::ExecutePopup( 0, this, &aMenuPos ); 2883*cdf0e10cSrcweir } 2884*cdf0e10cSrcweir } 2885*cdf0e10cSrcweir } 2886*cdf0e10cSrcweir 2887*cdf0e10cSrcweir void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY ) 2888*cdf0e10cSrcweir { 2889*cdf0e10cSrcweir // #i18735# if the click was outside of the current selection, 2890*cdf0e10cSrcweir // the cursor is moved or an object at the click position selected. 2891*cdf0e10cSrcweir // (see SwEditWin::SelectMenuPosition in Writer) 2892*cdf0e10cSrcweir 2893*cdf0e10cSrcweir ScTabView* pView = pViewData->GetView(); 2894*cdf0e10cSrcweir ScDrawView* pDrawView = pView->GetScDrawView(); 2895*cdf0e10cSrcweir 2896*cdf0e10cSrcweir // check cell edit mode 2897*cdf0e10cSrcweir 2898*cdf0e10cSrcweir if ( pViewData->HasEditView(eWhich) ) 2899*cdf0e10cSrcweir { 2900*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 2901*cdf0e10cSrcweir SCCOL nEditStartCol = pViewData->GetEditViewCol(); //! change to GetEditStartCol after calcrtl is integrated 2902*cdf0e10cSrcweir SCROW nEditStartRow = pViewData->GetEditViewRow(); 2903*cdf0e10cSrcweir SCCOL nEditEndCol = pViewData->GetEditEndCol(); 2904*cdf0e10cSrcweir SCROW nEditEndRow = pViewData->GetEditEndRow(); 2905*cdf0e10cSrcweir 2906*cdf0e10cSrcweir if ( nCellX >= (SCsCOL) nEditStartCol && nCellX <= (SCsCOL) nEditEndCol && 2907*cdf0e10cSrcweir nCellY >= (SCsROW) nEditStartRow && nCellY <= (SCsROW) nEditEndRow ) 2908*cdf0e10cSrcweir { 2909*cdf0e10cSrcweir // handle selection within the EditView 2910*cdf0e10cSrcweir 2911*cdf0e10cSrcweir EditView* pEditView = pViewData->GetEditView( eWhich ); // not NULL (HasEditView) 2912*cdf0e10cSrcweir EditEngine* pEditEngine = pEditView->GetEditEngine(); 2913*cdf0e10cSrcweir Rectangle aOutputArea = pEditView->GetOutputArea(); 2914*cdf0e10cSrcweir Rectangle aVisArea = pEditView->GetVisArea(); 2915*cdf0e10cSrcweir 2916*cdf0e10cSrcweir Point aTextPos = PixelToLogic( rPosPixel ); 2917*cdf0e10cSrcweir if ( pEditEngine->IsVertical() ) // have to manually transform position 2918*cdf0e10cSrcweir { 2919*cdf0e10cSrcweir aTextPos -= aOutputArea.TopRight(); 2920*cdf0e10cSrcweir long nTemp = -aTextPos.X(); 2921*cdf0e10cSrcweir aTextPos.X() = aTextPos.Y(); 2922*cdf0e10cSrcweir aTextPos.Y() = nTemp; 2923*cdf0e10cSrcweir } 2924*cdf0e10cSrcweir else 2925*cdf0e10cSrcweir aTextPos -= aOutputArea.TopLeft(); 2926*cdf0e10cSrcweir aTextPos += aVisArea.TopLeft(); // position in the edit document 2927*cdf0e10cSrcweir 2928*cdf0e10cSrcweir EPosition aDocPosition = pEditEngine->FindDocPosition(aTextPos); 2929*cdf0e10cSrcweir ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex); 2930*cdf0e10cSrcweir ESelection aSelection = pEditView->GetSelection(); 2931*cdf0e10cSrcweir aSelection.Adjust(); // needed for IsLess/IsGreater 2932*cdf0e10cSrcweir if ( aCompare.IsLess(aSelection) || aCompare.IsGreater(aSelection) ) 2933*cdf0e10cSrcweir { 2934*cdf0e10cSrcweir // clicked outside the selected text - deselect and move text cursor 2935*cdf0e10cSrcweir MouseEvent aEvent( rPosPixel ); 2936*cdf0e10cSrcweir pEditView->MouseButtonDown( aEvent ); 2937*cdf0e10cSrcweir pEditView->MouseButtonUp( aEvent ); 2938*cdf0e10cSrcweir pScMod->InputSelection( pEditView ); 2939*cdf0e10cSrcweir } 2940*cdf0e10cSrcweir 2941*cdf0e10cSrcweir return; // clicked within the edit view - keep edit mode 2942*cdf0e10cSrcweir } 2943*cdf0e10cSrcweir else 2944*cdf0e10cSrcweir { 2945*cdf0e10cSrcweir // outside of the edit view - end edit mode, regardless of cell selection, then continue 2946*cdf0e10cSrcweir pScMod->InputEnterHandler(); 2947*cdf0e10cSrcweir } 2948*cdf0e10cSrcweir } 2949*cdf0e10cSrcweir 2950*cdf0e10cSrcweir // check draw text edit mode 2951*cdf0e10cSrcweir 2952*cdf0e10cSrcweir Point aLogicPos = PixelToLogic( rPosPixel ); // after cell edit mode is ended 2953*cdf0e10cSrcweir if ( pDrawView && pDrawView->GetTextEditObject() && pDrawView->GetTextEditOutlinerView() ) 2954*cdf0e10cSrcweir { 2955*cdf0e10cSrcweir OutlinerView* pOlView = pDrawView->GetTextEditOutlinerView(); 2956*cdf0e10cSrcweir Rectangle aOutputArea = pOlView->GetOutputArea(); 2957*cdf0e10cSrcweir if ( aOutputArea.IsInside( aLogicPos ) ) 2958*cdf0e10cSrcweir { 2959*cdf0e10cSrcweir // handle selection within the OutlinerView 2960*cdf0e10cSrcweir 2961*cdf0e10cSrcweir Outliner* pOutliner = pOlView->GetOutliner(); 2962*cdf0e10cSrcweir const EditEngine& rEditEngine = pOutliner->GetEditEngine(); 2963*cdf0e10cSrcweir Rectangle aVisArea = pOlView->GetVisArea(); 2964*cdf0e10cSrcweir 2965*cdf0e10cSrcweir Point aTextPos = aLogicPos; 2966*cdf0e10cSrcweir if ( pOutliner->IsVertical() ) // have to manually transform position 2967*cdf0e10cSrcweir { 2968*cdf0e10cSrcweir aTextPos -= aOutputArea.TopRight(); 2969*cdf0e10cSrcweir long nTemp = -aTextPos.X(); 2970*cdf0e10cSrcweir aTextPos.X() = aTextPos.Y(); 2971*cdf0e10cSrcweir aTextPos.Y() = nTemp; 2972*cdf0e10cSrcweir } 2973*cdf0e10cSrcweir else 2974*cdf0e10cSrcweir aTextPos -= aOutputArea.TopLeft(); 2975*cdf0e10cSrcweir aTextPos += aVisArea.TopLeft(); // position in the edit document 2976*cdf0e10cSrcweir 2977*cdf0e10cSrcweir EPosition aDocPosition = rEditEngine.FindDocPosition(aTextPos); 2978*cdf0e10cSrcweir ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex); 2979*cdf0e10cSrcweir ESelection aSelection = pOlView->GetSelection(); 2980*cdf0e10cSrcweir aSelection.Adjust(); // needed for IsLess/IsGreater 2981*cdf0e10cSrcweir if ( aCompare.IsLess(aSelection) || aCompare.IsGreater(aSelection) ) 2982*cdf0e10cSrcweir { 2983*cdf0e10cSrcweir // clicked outside the selected text - deselect and move text cursor 2984*cdf0e10cSrcweir // use DrawView to allow extra handling there (none currently) 2985*cdf0e10cSrcweir MouseEvent aEvent( rPosPixel ); 2986*cdf0e10cSrcweir pDrawView->MouseButtonDown( aEvent, this ); 2987*cdf0e10cSrcweir pDrawView->MouseButtonUp( aEvent, this ); 2988*cdf0e10cSrcweir } 2989*cdf0e10cSrcweir 2990*cdf0e10cSrcweir return; // clicked within the edit area - keep edit mode 2991*cdf0e10cSrcweir } 2992*cdf0e10cSrcweir else 2993*cdf0e10cSrcweir { 2994*cdf0e10cSrcweir // Outside of the edit area - end text edit mode, then continue. 2995*cdf0e10cSrcweir // DrawDeselectAll also ends text edit mode and updates the shells. 2996*cdf0e10cSrcweir // If the click was on the edited object, it will be selected again below. 2997*cdf0e10cSrcweir pView->DrawDeselectAll(); 2998*cdf0e10cSrcweir } 2999*cdf0e10cSrcweir } 3000*cdf0e10cSrcweir 3001*cdf0e10cSrcweir // look for existing selection 3002*cdf0e10cSrcweir 3003*cdf0e10cSrcweir sal_Bool bHitSelected = sal_False; 3004*cdf0e10cSrcweir if ( pDrawView && pDrawView->IsMarkedObjHit( aLogicPos ) ) 3005*cdf0e10cSrcweir { 3006*cdf0e10cSrcweir // clicked on selected object -> don't change anything 3007*cdf0e10cSrcweir bHitSelected = sal_True; 3008*cdf0e10cSrcweir } 3009*cdf0e10cSrcweir else if ( pViewData->GetMarkData().IsCellMarked(nCellX, nCellY) ) 3010*cdf0e10cSrcweir { 3011*cdf0e10cSrcweir // clicked on selected cell -> don't change anything 3012*cdf0e10cSrcweir bHitSelected = sal_True; 3013*cdf0e10cSrcweir } 3014*cdf0e10cSrcweir 3015*cdf0e10cSrcweir // select drawing object or move cell cursor 3016*cdf0e10cSrcweir 3017*cdf0e10cSrcweir if ( !bHitSelected ) 3018*cdf0e10cSrcweir { 3019*cdf0e10cSrcweir sal_Bool bWasDraw = ( pDrawView && pDrawView->AreObjectsMarked() ); 3020*cdf0e10cSrcweir sal_Bool bHitDraw = sal_False; 3021*cdf0e10cSrcweir if ( pDrawView ) 3022*cdf0e10cSrcweir { 3023*cdf0e10cSrcweir pDrawView->UnmarkAllObj(); 3024*cdf0e10cSrcweir // Unlock the Internal Layer in order to activate the context menu. 3025*cdf0e10cSrcweir // re-lock in ScDrawView::MarkListHasChanged() 3026*cdf0e10cSrcweir lcl_UnLockComment( pDrawView, pDrawView->GetSdrPageView(), pDrawView->GetModel(), aLogicPos ,pViewData); 3027*cdf0e10cSrcweir bHitDraw = pDrawView->MarkObj( aLogicPos ); 3028*cdf0e10cSrcweir // draw shell is activated in MarkListHasChanged 3029*cdf0e10cSrcweir } 3030*cdf0e10cSrcweir if ( !bHitDraw ) 3031*cdf0e10cSrcweir { 3032*cdf0e10cSrcweir pView->Unmark(); 3033*cdf0e10cSrcweir pView->SetCursor(nCellX, nCellY); 3034*cdf0e10cSrcweir if ( bWasDraw ) 3035*cdf0e10cSrcweir pViewData->GetViewShell()->SetDrawShell( sal_False ); // switch shells 3036*cdf0e10cSrcweir } 3037*cdf0e10cSrcweir } 3038*cdf0e10cSrcweir } 3039*cdf0e10cSrcweir 3040*cdf0e10cSrcweir void __EXPORT ScGridWindow::KeyInput(const KeyEvent& rKEvt) 3041*cdf0e10cSrcweir { 3042*cdf0e10cSrcweir // #96965# Cursor control for ref input dialog 3043*cdf0e10cSrcweir if( SC_MOD()->IsRefDialogOpen() ) 3044*cdf0e10cSrcweir { 3045*cdf0e10cSrcweir const KeyCode& rKeyCode = rKEvt.GetKeyCode(); 3046*cdf0e10cSrcweir if( !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) ) 3047*cdf0e10cSrcweir { 3048*cdf0e10cSrcweir SC_MOD()->EndReference(); 3049*cdf0e10cSrcweir return; 3050*cdf0e10cSrcweir } 3051*cdf0e10cSrcweir else if( pViewData->GetViewShell()->MoveCursorKeyInput( rKEvt ) ) 3052*cdf0e10cSrcweir { 3053*cdf0e10cSrcweir ScRange aRef( 3054*cdf0e10cSrcweir pViewData->GetRefStartX(), pViewData->GetRefStartY(), pViewData->GetRefStartZ(), 3055*cdf0e10cSrcweir pViewData->GetRefEndX(), pViewData->GetRefEndY(), pViewData->GetRefEndZ() ); 3056*cdf0e10cSrcweir SC_MOD()->SetReference( aRef, pViewData->GetDocument() ); 3057*cdf0e10cSrcweir return; 3058*cdf0e10cSrcweir } 3059*cdf0e10cSrcweir } 3060*cdf0e10cSrcweir // wenn semi-Modeless-SfxChildWindow-Dialog oben, keine KeyInputs: 3061*cdf0e10cSrcweir else if( !pViewData->IsAnyFillMode() ) 3062*cdf0e10cSrcweir { 3063*cdf0e10cSrcweir // query for existing note marker before calling ViewShell's keyboard handling 3064*cdf0e10cSrcweir // which may remove the marker 3065*cdf0e10cSrcweir sal_Bool bHadKeyMarker = ( pNoteMarker && pNoteMarker->IsByKeyboard() ); 3066*cdf0e10cSrcweir ScTabViewShell* pViewSh = pViewData->GetViewShell(); 3067*cdf0e10cSrcweir 3068*cdf0e10cSrcweir if (pViewData->GetDocShell()->GetProgress()) 3069*cdf0e10cSrcweir return; 3070*cdf0e10cSrcweir 3071*cdf0e10cSrcweir if (DrawKeyInput(rKEvt)) 3072*cdf0e10cSrcweir return; 3073*cdf0e10cSrcweir 3074*cdf0e10cSrcweir if (!pViewData->GetView()->IsDrawSelMode() && !DrawHasMarkedObj()) // keine Eingaben im Zeichenmodus 3075*cdf0e10cSrcweir { //! DrawShell abfragen !!! 3076*cdf0e10cSrcweir if (pViewSh->TabKeyInput(rKEvt)) 3077*cdf0e10cSrcweir return; 3078*cdf0e10cSrcweir } 3079*cdf0e10cSrcweir else 3080*cdf0e10cSrcweir if (pViewSh->SfxViewShell::KeyInput(rKEvt)) // von SfxViewShell 3081*cdf0e10cSrcweir return; 3082*cdf0e10cSrcweir 3083*cdf0e10cSrcweir KeyCode aCode = rKEvt.GetKeyCode(); 3084*cdf0e10cSrcweir if ( aCode.GetCode() == KEY_ESCAPE && aCode.GetModifier() == 0 ) 3085*cdf0e10cSrcweir { 3086*cdf0e10cSrcweir if ( bHadKeyMarker ) 3087*cdf0e10cSrcweir HideNoteMarker(); 3088*cdf0e10cSrcweir else 3089*cdf0e10cSrcweir pViewSh->Escape(); 3090*cdf0e10cSrcweir return; 3091*cdf0e10cSrcweir } 3092*cdf0e10cSrcweir if ( aCode.GetCode() == KEY_F1 && aCode.GetModifier() == KEY_MOD1 ) 3093*cdf0e10cSrcweir { 3094*cdf0e10cSrcweir // ctrl-F1 shows or hides the note or redlining info for the cursor position 3095*cdf0e10cSrcweir // (hard-coded because F1 can't be configured) 3096*cdf0e10cSrcweir 3097*cdf0e10cSrcweir if ( bHadKeyMarker ) 3098*cdf0e10cSrcweir HideNoteMarker(); // hide when previously visible 3099*cdf0e10cSrcweir else 3100*cdf0e10cSrcweir ShowNoteMarker( pViewData->GetCurX(), pViewData->GetCurY(), sal_True ); 3101*cdf0e10cSrcweir return; 3102*cdf0e10cSrcweir } 3103*cdf0e10cSrcweir } 3104*cdf0e10cSrcweir 3105*cdf0e10cSrcweir Window::KeyInput(rKEvt); 3106*cdf0e10cSrcweir } 3107*cdf0e10cSrcweir 3108*cdf0e10cSrcweir void ScGridWindow::StopMarking() 3109*cdf0e10cSrcweir { 3110*cdf0e10cSrcweir DrawEndAction(); // Markieren/Verschieben auf Drawing-Layer abbrechen 3111*cdf0e10cSrcweir 3112*cdf0e10cSrcweir if (nButtonDown) 3113*cdf0e10cSrcweir { 3114*cdf0e10cSrcweir pViewData->GetMarkData().SetMarking(sal_False); 3115*cdf0e10cSrcweir nMouseStatus = SC_GM_IGNORE; 3116*cdf0e10cSrcweir } 3117*cdf0e10cSrcweir } 3118*cdf0e10cSrcweir 3119*cdf0e10cSrcweir void ScGridWindow::UpdateInputContext() 3120*cdf0e10cSrcweir { 3121*cdf0e10cSrcweir sal_Bool bReadOnly = pViewData->GetDocShell()->IsReadOnly(); 3122*cdf0e10cSrcweir sal_uLong nOptions = bReadOnly ? 0 : ( INPUTCONTEXT_TEXT | INPUTCONTEXT_EXTTEXTINPUT ); 3123*cdf0e10cSrcweir 3124*cdf0e10cSrcweir // when font from InputContext is used, 3125*cdf0e10cSrcweir // it must be taken from the cursor position's cell attributes 3126*cdf0e10cSrcweir 3127*cdf0e10cSrcweir InputContext aContext; 3128*cdf0e10cSrcweir aContext.SetOptions( nOptions ); 3129*cdf0e10cSrcweir SetInputContext( aContext ); 3130*cdf0e10cSrcweir } 3131*cdf0e10cSrcweir 3132*cdf0e10cSrcweir //-------------------------------------------------------- 3133*cdf0e10cSrcweir 3134*cdf0e10cSrcweir // sensitiver Bereich (Pixel) 3135*cdf0e10cSrcweir #define SCROLL_SENSITIVE 20 3136*cdf0e10cSrcweir 3137*cdf0e10cSrcweir sal_Bool ScGridWindow::DropScroll( const Point& rMousePos ) 3138*cdf0e10cSrcweir { 3139*cdf0e10cSrcweir /* doch auch auf nicht aktiven Views... 3140*cdf0e10cSrcweir if ( !pViewData->IsActive() ) 3141*cdf0e10cSrcweir return sal_False; 3142*cdf0e10cSrcweir */ 3143*cdf0e10cSrcweir SCsCOL nDx = 0; 3144*cdf0e10cSrcweir SCsROW nDy = 0; 3145*cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 3146*cdf0e10cSrcweir 3147*cdf0e10cSrcweir if (aSize.Width() > SCROLL_SENSITIVE * 3) 3148*cdf0e10cSrcweir { 3149*cdf0e10cSrcweir if ( rMousePos.X() < SCROLL_SENSITIVE && pViewData->GetPosX(WhichH(eWhich)) > 0 ) 3150*cdf0e10cSrcweir nDx = -1; 3151*cdf0e10cSrcweir if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE 3152*cdf0e10cSrcweir && pViewData->GetPosX(WhichH(eWhich)) < MAXCOL ) 3153*cdf0e10cSrcweir nDx = 1; 3154*cdf0e10cSrcweir } 3155*cdf0e10cSrcweir if (aSize.Height() > SCROLL_SENSITIVE * 3) 3156*cdf0e10cSrcweir { 3157*cdf0e10cSrcweir if ( rMousePos.Y() < SCROLL_SENSITIVE && pViewData->GetPosY(WhichV(eWhich)) > 0 ) 3158*cdf0e10cSrcweir nDy = -1; 3159*cdf0e10cSrcweir if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE 3160*cdf0e10cSrcweir && pViewData->GetPosY(WhichV(eWhich)) < MAXROW ) 3161*cdf0e10cSrcweir nDy = 1; 3162*cdf0e10cSrcweir } 3163*cdf0e10cSrcweir 3164*cdf0e10cSrcweir if ( nDx != 0 || nDy != 0 ) 3165*cdf0e10cSrcweir { 3166*cdf0e10cSrcweir // if (bDragRect) 3167*cdf0e10cSrcweir // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); 3168*cdf0e10cSrcweir 3169*cdf0e10cSrcweir if ( nDx != 0 ) 3170*cdf0e10cSrcweir pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) ); 3171*cdf0e10cSrcweir if ( nDy != 0 ) 3172*cdf0e10cSrcweir pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) ); 3173*cdf0e10cSrcweir 3174*cdf0e10cSrcweir // if (bDragRect) 3175*cdf0e10cSrcweir // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); 3176*cdf0e10cSrcweir } 3177*cdf0e10cSrcweir 3178*cdf0e10cSrcweir return sal_False; 3179*cdf0e10cSrcweir } 3180*cdf0e10cSrcweir 3181*cdf0e10cSrcweir sal_Bool lcl_TestScenarioRedliningDrop( ScDocument* pDoc, const ScRange& aDragRange) 3182*cdf0e10cSrcweir { 3183*cdf0e10cSrcweir // Testet, ob bei eingeschalteten RedLining, 3184*cdf0e10cSrcweir // bei einem Drop ein Scenario betroffen ist. 3185*cdf0e10cSrcweir 3186*cdf0e10cSrcweir sal_Bool bReturn = sal_False; 3187*cdf0e10cSrcweir SCTAB nTab = aDragRange.aStart.Tab(); 3188*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 3189*cdf0e10cSrcweir 3190*cdf0e10cSrcweir if(pDoc->GetChangeTrack()!=NULL) 3191*cdf0e10cSrcweir { 3192*cdf0e10cSrcweir if( pDoc->IsScenario(nTab) && pDoc->HasScenarioRange(nTab, aDragRange)) 3193*cdf0e10cSrcweir { 3194*cdf0e10cSrcweir bReturn = sal_True; 3195*cdf0e10cSrcweir } 3196*cdf0e10cSrcweir else 3197*cdf0e10cSrcweir { 3198*cdf0e10cSrcweir for(SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++) 3199*cdf0e10cSrcweir { 3200*cdf0e10cSrcweir if(pDoc->HasScenarioRange(i, aDragRange)) 3201*cdf0e10cSrcweir { 3202*cdf0e10cSrcweir bReturn = sal_True; 3203*cdf0e10cSrcweir break; 3204*cdf0e10cSrcweir } 3205*cdf0e10cSrcweir } 3206*cdf0e10cSrcweir } 3207*cdf0e10cSrcweir } 3208*cdf0e10cSrcweir return bReturn; 3209*cdf0e10cSrcweir } 3210*cdf0e10cSrcweir 3211*cdf0e10cSrcweir ScRange lcl_MakeDropRange( SCCOL nPosX, SCROW nPosY, SCTAB nTab, const ScRange& rSource ) 3212*cdf0e10cSrcweir { 3213*cdf0e10cSrcweir SCCOL nCol1 = nPosX; 3214*cdf0e10cSrcweir SCCOL nCol2 = nCol1 + ( rSource.aEnd.Col() - rSource.aStart.Col() ); 3215*cdf0e10cSrcweir if ( nCol2 > MAXCOL ) 3216*cdf0e10cSrcweir { 3217*cdf0e10cSrcweir nCol1 -= nCol2 - MAXCOL; 3218*cdf0e10cSrcweir nCol2 = MAXCOL; 3219*cdf0e10cSrcweir } 3220*cdf0e10cSrcweir SCROW nRow1 = nPosY; 3221*cdf0e10cSrcweir SCROW nRow2 = nRow1 + ( rSource.aEnd.Row() - rSource.aStart.Row() ); 3222*cdf0e10cSrcweir if ( nRow2 > MAXROW ) 3223*cdf0e10cSrcweir { 3224*cdf0e10cSrcweir nRow1 -= nRow2 - MAXROW; 3225*cdf0e10cSrcweir nRow2 = MAXROW; 3226*cdf0e10cSrcweir } 3227*cdf0e10cSrcweir 3228*cdf0e10cSrcweir return ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab ); 3229*cdf0e10cSrcweir } 3230*cdf0e10cSrcweir 3231*cdf0e10cSrcweir //-------------------------------------------------------- 3232*cdf0e10cSrcweir 3233*cdf0e10cSrcweir extern sal_Bool bPasteIsDrop; // viewfun4 -> move to header 3234*cdf0e10cSrcweir extern sal_Bool bPasteIsMove; // viewfun7 -> move to header 3235*cdf0e10cSrcweir 3236*cdf0e10cSrcweir //-------------------------------------------------------- 3237*cdf0e10cSrcweir 3238*cdf0e10cSrcweir sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt ) 3239*cdf0e10cSrcweir { 3240*cdf0e10cSrcweir if ( rEvt.mbLeaving ) 3241*cdf0e10cSrcweir { 3242*cdf0e10cSrcweir // if (bDragRect) 3243*cdf0e10cSrcweir // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); 3244*cdf0e10cSrcweir bDragRect = sal_False; 3245*cdf0e10cSrcweir UpdateDragRectOverlay(); 3246*cdf0e10cSrcweir return rEvt.mnAction; 3247*cdf0e10cSrcweir } 3248*cdf0e10cSrcweir 3249*cdf0e10cSrcweir const ScDragData& rData = SC_MOD()->GetDragData(); 3250*cdf0e10cSrcweir if ( rData.pCellTransfer ) 3251*cdf0e10cSrcweir { 3252*cdf0e10cSrcweir // Don't move source that would include filtered rows. 3253*cdf0e10cSrcweir if ((rEvt.mnAction & DND_ACTION_MOVE) && rData.pCellTransfer->HasFilteredRows()) 3254*cdf0e10cSrcweir { 3255*cdf0e10cSrcweir if (bDragRect) 3256*cdf0e10cSrcweir { 3257*cdf0e10cSrcweir bDragRect = sal_False; 3258*cdf0e10cSrcweir UpdateDragRectOverlay(); 3259*cdf0e10cSrcweir } 3260*cdf0e10cSrcweir return DND_ACTION_NONE; 3261*cdf0e10cSrcweir } 3262*cdf0e10cSrcweir 3263*cdf0e10cSrcweir Point aPos = rEvt.maPosPixel; 3264*cdf0e10cSrcweir 3265*cdf0e10cSrcweir ScDocument* pSourceDoc = rData.pCellTransfer->GetSourceDocument(); 3266*cdf0e10cSrcweir ScDocument* pThisDoc = pViewData->GetDocument(); 3267*cdf0e10cSrcweir if (pSourceDoc == pThisDoc) 3268*cdf0e10cSrcweir { 3269*cdf0e10cSrcweir if ( pThisDoc->HasChartAtPoint(pViewData->GetTabNo(), PixelToLogic(aPos)) ) 3270*cdf0e10cSrcweir { 3271*cdf0e10cSrcweir if (bDragRect) // Rechteck loeschen 3272*cdf0e10cSrcweir { 3273*cdf0e10cSrcweir // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); 3274*cdf0e10cSrcweir bDragRect = sal_False; 3275*cdf0e10cSrcweir UpdateDragRectOverlay(); 3276*cdf0e10cSrcweir } 3277*cdf0e10cSrcweir 3278*cdf0e10cSrcweir //! highlight chart? (selection border?) 3279*cdf0e10cSrcweir 3280*cdf0e10cSrcweir sal_Int8 nRet = rEvt.mnAction; 3281*cdf0e10cSrcweir //! if ( rEvt.GetAction() == DROP_LINK ) 3282*cdf0e10cSrcweir //! bOk = rEvt.SetAction( DROP_COPY ); // can't link onto chart 3283*cdf0e10cSrcweir return nRet; 3284*cdf0e10cSrcweir } 3285*cdf0e10cSrcweir } 3286*cdf0e10cSrcweir //! else 3287*cdf0e10cSrcweir //! if ( rEvt.GetAction() == DROP_MOVE ) 3288*cdf0e10cSrcweir //! rEvt.SetAction( DROP_COPY ); // different doc: default=COPY 3289*cdf0e10cSrcweir 3290*cdf0e10cSrcweir 3291*cdf0e10cSrcweir if ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE ) // whole sheet? 3292*cdf0e10cSrcweir { 3293*cdf0e10cSrcweir sal_Bool bOk = pThisDoc->IsDocEditable(); 3294*cdf0e10cSrcweir return bOk ? rEvt.mnAction : 0; // don't draw selection frame 3295*cdf0e10cSrcweir } 3296*cdf0e10cSrcweir 3297*cdf0e10cSrcweir SCsCOL nPosX; 3298*cdf0e10cSrcweir SCsROW nPosY; 3299*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 3300*cdf0e10cSrcweir 3301*cdf0e10cSrcweir ScRange aSourceRange = rData.pCellTransfer->GetRange(); 3302*cdf0e10cSrcweir SCCOL nSourceStartX = aSourceRange.aStart.Col(); 3303*cdf0e10cSrcweir SCROW nSourceStartY = aSourceRange.aStart.Row(); 3304*cdf0e10cSrcweir SCCOL nSourceEndX = aSourceRange.aEnd.Col(); 3305*cdf0e10cSrcweir SCROW nSourceEndY = aSourceRange.aEnd.Row(); 3306*cdf0e10cSrcweir SCCOL nSizeX = nSourceEndX - nSourceStartX + 1; 3307*cdf0e10cSrcweir SCROW nSizeY = nSourceEndY - nSourceStartY + 1; 3308*cdf0e10cSrcweir 3309*cdf0e10cSrcweir if ( rEvt.mnAction != DND_ACTION_MOVE ) 3310*cdf0e10cSrcweir nSizeY = rData.pCellTransfer->GetNonFilteredRows(); // copy/link: no filtered rows 3311*cdf0e10cSrcweir 3312*cdf0e10cSrcweir SCsCOL nNewDragX = nPosX - rData.pCellTransfer->GetDragHandleX(); 3313*cdf0e10cSrcweir if (nNewDragX<0) nNewDragX=0; 3314*cdf0e10cSrcweir if (nNewDragX+(nSizeX-1) > MAXCOL) 3315*cdf0e10cSrcweir nNewDragX = MAXCOL-(nSizeX-1); 3316*cdf0e10cSrcweir SCsROW nNewDragY = nPosY - rData.pCellTransfer->GetDragHandleY(); 3317*cdf0e10cSrcweir if (nNewDragY<0) nNewDragY=0; 3318*cdf0e10cSrcweir if (nNewDragY+(nSizeY-1) > MAXROW) 3319*cdf0e10cSrcweir nNewDragY = MAXROW-(nSizeY-1); 3320*cdf0e10cSrcweir 3321*cdf0e10cSrcweir // don't break scenario ranges, don't drop on filtered 3322*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 3323*cdf0e10cSrcweir ScRange aDropRange = lcl_MakeDropRange( nNewDragX, nNewDragY, nTab, aSourceRange ); 3324*cdf0e10cSrcweir if ( lcl_TestScenarioRedliningDrop( pThisDoc, aDropRange ) || 3325*cdf0e10cSrcweir lcl_TestScenarioRedliningDrop( pSourceDoc, aSourceRange ) || 3326*cdf0e10cSrcweir ScViewUtil::HasFiltered( aDropRange, pThisDoc) ) 3327*cdf0e10cSrcweir { 3328*cdf0e10cSrcweir if (bDragRect) 3329*cdf0e10cSrcweir { 3330*cdf0e10cSrcweir // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); 3331*cdf0e10cSrcweir bDragRect = sal_False; 3332*cdf0e10cSrcweir UpdateDragRectOverlay(); 3333*cdf0e10cSrcweir } 3334*cdf0e10cSrcweir return DND_ACTION_NONE; 3335*cdf0e10cSrcweir } 3336*cdf0e10cSrcweir 3337*cdf0e10cSrcweir InsCellCmd eDragInsertMode = INS_NONE; 3338*cdf0e10cSrcweir Window::PointerState aState = GetPointerState(); 3339*cdf0e10cSrcweir 3340*cdf0e10cSrcweir // check for datapilot item sorting 3341*cdf0e10cSrcweir ScDPObject* pDPObj = NULL; 3342*cdf0e10cSrcweir if ( pThisDoc == pSourceDoc && ( pDPObj = pThisDoc->GetDPAtCursor( nNewDragX, nNewDragY, nTab ) ) != NULL ) 3343*cdf0e10cSrcweir { 3344*cdf0e10cSrcweir // drop on DataPilot table: sort or nothing 3345*cdf0e10cSrcweir 3346*cdf0e10cSrcweir bool bDPSort = false; 3347*cdf0e10cSrcweir if ( pThisDoc->GetDPAtCursor( nSourceStartX, nSourceStartY, aSourceRange.aStart.Tab() ) == pDPObj ) 3348*cdf0e10cSrcweir { 3349*cdf0e10cSrcweir sheet::DataPilotTableHeaderData aDestData; 3350*cdf0e10cSrcweir pDPObj->GetHeaderPositionData( ScAddress(nNewDragX, nNewDragY, nTab), aDestData ); 3351*cdf0e10cSrcweir bool bValid = ( aDestData.Dimension >= 0 ); // dropping onto a field 3352*cdf0e10cSrcweir 3353*cdf0e10cSrcweir // look through the source range 3354*cdf0e10cSrcweir for (SCROW nRow = aSourceRange.aStart.Row(); bValid && nRow <= aSourceRange.aEnd.Row(); ++nRow ) 3355*cdf0e10cSrcweir for (SCCOL nCol = aSourceRange.aStart.Col(); bValid && nCol <= aSourceRange.aEnd.Col(); ++nCol ) 3356*cdf0e10cSrcweir { 3357*cdf0e10cSrcweir sheet::DataPilotTableHeaderData aSourceData; 3358*cdf0e10cSrcweir pDPObj->GetHeaderPositionData( ScAddress( nCol, nRow, aSourceRange.aStart.Tab() ), aSourceData ); 3359*cdf0e10cSrcweir if ( aSourceData.Dimension != aDestData.Dimension || !aSourceData.MemberName.getLength() ) 3360*cdf0e10cSrcweir bValid = false; // empty (subtotal) or different field 3361*cdf0e10cSrcweir } 3362*cdf0e10cSrcweir 3363*cdf0e10cSrcweir if ( bValid ) 3364*cdf0e10cSrcweir { 3365*cdf0e10cSrcweir sal_Bool bIsDataLayout; 3366*cdf0e10cSrcweir String aDimName = pDPObj->GetDimName( aDestData.Dimension, bIsDataLayout ); 3367*cdf0e10cSrcweir const ScDPSaveDimension* pDim = pDPObj->GetSaveData()->GetExistingDimensionByName( aDimName ); 3368*cdf0e10cSrcweir if ( pDim ) 3369*cdf0e10cSrcweir { 3370*cdf0e10cSrcweir ScRange aOutRange = pDPObj->GetOutRange(); 3371*cdf0e10cSrcweir 3372*cdf0e10cSrcweir sal_uInt16 nOrient = pDim->GetOrientation(); 3373*cdf0e10cSrcweir if ( nOrient == sheet::DataPilotFieldOrientation_COLUMN ) 3374*cdf0e10cSrcweir { 3375*cdf0e10cSrcweir eDragInsertMode = INS_CELLSRIGHT; 3376*cdf0e10cSrcweir nSizeY = aOutRange.aEnd.Row() - nNewDragY + 1; 3377*cdf0e10cSrcweir bDPSort = true; 3378*cdf0e10cSrcweir } 3379*cdf0e10cSrcweir else if ( nOrient == sheet::DataPilotFieldOrientation_ROW ) 3380*cdf0e10cSrcweir { 3381*cdf0e10cSrcweir eDragInsertMode = INS_CELLSDOWN; 3382*cdf0e10cSrcweir nSizeX = aOutRange.aEnd.Col() - nNewDragX + 1; 3383*cdf0e10cSrcweir bDPSort = true; 3384*cdf0e10cSrcweir } 3385*cdf0e10cSrcweir } 3386*cdf0e10cSrcweir } 3387*cdf0e10cSrcweir } 3388*cdf0e10cSrcweir 3389*cdf0e10cSrcweir if ( !bDPSort ) 3390*cdf0e10cSrcweir { 3391*cdf0e10cSrcweir // no valid sorting in a DataPilot table -> disallow 3392*cdf0e10cSrcweir if ( bDragRect ) 3393*cdf0e10cSrcweir { 3394*cdf0e10cSrcweir bDragRect = sal_False; 3395*cdf0e10cSrcweir UpdateDragRectOverlay(); 3396*cdf0e10cSrcweir } 3397*cdf0e10cSrcweir return DND_ACTION_NONE; 3398*cdf0e10cSrcweir } 3399*cdf0e10cSrcweir } 3400*cdf0e10cSrcweir else if ( aState.mnState & KEY_MOD2 ) 3401*cdf0e10cSrcweir { 3402*cdf0e10cSrcweir if ( pThisDoc == pSourceDoc && nTab == aSourceRange.aStart.Tab() ) 3403*cdf0e10cSrcweir { 3404*cdf0e10cSrcweir long nDeltaX = labs( static_cast< long >( nNewDragX - nSourceStartX ) ); 3405*cdf0e10cSrcweir long nDeltaY = labs( static_cast< long >( nNewDragY - nSourceStartY ) ); 3406*cdf0e10cSrcweir if ( nDeltaX <= nDeltaY ) 3407*cdf0e10cSrcweir { 3408*cdf0e10cSrcweir eDragInsertMode = INS_CELLSDOWN; 3409*cdf0e10cSrcweir } 3410*cdf0e10cSrcweir else 3411*cdf0e10cSrcweir { 3412*cdf0e10cSrcweir eDragInsertMode = INS_CELLSRIGHT; 3413*cdf0e10cSrcweir } 3414*cdf0e10cSrcweir 3415*cdf0e10cSrcweir if ( ( eDragInsertMode == INS_CELLSDOWN && nNewDragY <= nSourceEndY && 3416*cdf0e10cSrcweir ( nNewDragX + nSizeX - 1 ) >= nSourceStartX && nNewDragX <= nSourceEndX && 3417*cdf0e10cSrcweir ( nNewDragX != nSourceStartX || nNewDragY >= nSourceStartY ) ) || 3418*cdf0e10cSrcweir ( eDragInsertMode == INS_CELLSRIGHT && nNewDragX <= nSourceEndX && 3419*cdf0e10cSrcweir ( nNewDragY + nSizeY - 1 ) >= nSourceStartY && nNewDragY <= nSourceEndY && 3420*cdf0e10cSrcweir ( nNewDragY != nSourceStartY || nNewDragX >= nSourceStartX ) ) ) 3421*cdf0e10cSrcweir { 3422*cdf0e10cSrcweir if ( bDragRect ) 3423*cdf0e10cSrcweir { 3424*cdf0e10cSrcweir bDragRect = sal_False; 3425*cdf0e10cSrcweir UpdateDragRectOverlay(); 3426*cdf0e10cSrcweir } 3427*cdf0e10cSrcweir return DND_ACTION_NONE; 3428*cdf0e10cSrcweir } 3429*cdf0e10cSrcweir } 3430*cdf0e10cSrcweir else 3431*cdf0e10cSrcweir { 3432*cdf0e10cSrcweir if ( static_cast< long >( nSizeX ) >= static_cast< long >( nSizeY ) ) 3433*cdf0e10cSrcweir { 3434*cdf0e10cSrcweir eDragInsertMode = INS_CELLSDOWN; 3435*cdf0e10cSrcweir 3436*cdf0e10cSrcweir } 3437*cdf0e10cSrcweir else 3438*cdf0e10cSrcweir { 3439*cdf0e10cSrcweir eDragInsertMode = INS_CELLSRIGHT; 3440*cdf0e10cSrcweir } 3441*cdf0e10cSrcweir } 3442*cdf0e10cSrcweir } 3443*cdf0e10cSrcweir 3444*cdf0e10cSrcweir if ( nNewDragX != (SCsCOL) nDragStartX || nNewDragY != (SCsROW) nDragStartY || 3445*cdf0e10cSrcweir nDragStartX+nSizeX-1 != nDragEndX || nDragStartY+nSizeY-1 != nDragEndY || 3446*cdf0e10cSrcweir !bDragRect || eDragInsertMode != meDragInsertMode ) 3447*cdf0e10cSrcweir { 3448*cdf0e10cSrcweir // if (bDragRect) 3449*cdf0e10cSrcweir // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); 3450*cdf0e10cSrcweir 3451*cdf0e10cSrcweir nDragStartX = nNewDragX; 3452*cdf0e10cSrcweir nDragStartY = nNewDragY; 3453*cdf0e10cSrcweir nDragEndX = nDragStartX+nSizeX-1; 3454*cdf0e10cSrcweir nDragEndY = nDragStartY+nSizeY-1; 3455*cdf0e10cSrcweir bDragRect = sal_True; 3456*cdf0e10cSrcweir meDragInsertMode = eDragInsertMode; 3457*cdf0e10cSrcweir 3458*cdf0e10cSrcweir // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); 3459*cdf0e10cSrcweir 3460*cdf0e10cSrcweir UpdateDragRectOverlay(); 3461*cdf0e10cSrcweir 3462*cdf0e10cSrcweir // show target position as tip help 3463*cdf0e10cSrcweir #if 0 3464*cdf0e10cSrcweir if (Help::IsQuickHelpEnabled()) 3465*cdf0e10cSrcweir { 3466*cdf0e10cSrcweir ScRange aRange( nDragStartX, nDragStartY, nTab, nDragEndX, nDragEndY, nTab ); 3467*cdf0e10cSrcweir String aHelpStr; 3468*cdf0e10cSrcweir aRange.Format( aHelpStr, SCA_VALID ); // non-3D 3469*cdf0e10cSrcweir 3470*cdf0e10cSrcweir Point aPos = Pointer::GetPosPixel(); 3471*cdf0e10cSrcweir sal_uInt16 nAlign = QUICKHELP_BOTTOM|QUICKHELP_RIGHT; 3472*cdf0e10cSrcweir Rectangle aRect( aPos, aPos ); 3473*cdf0e10cSrcweir Help::ShowQuickHelp(aRect, aHelpStr, nAlign); 3474*cdf0e10cSrcweir } 3475*cdf0e10cSrcweir #endif 3476*cdf0e10cSrcweir } 3477*cdf0e10cSrcweir } 3478*cdf0e10cSrcweir 3479*cdf0e10cSrcweir return rEvt.mnAction; 3480*cdf0e10cSrcweir } 3481*cdf0e10cSrcweir 3482*cdf0e10cSrcweir sal_Int8 ScGridWindow::AcceptDrop( const AcceptDropEvent& rEvt ) 3483*cdf0e10cSrcweir { 3484*cdf0e10cSrcweir const ScDragData& rData = SC_MOD()->GetDragData(); 3485*cdf0e10cSrcweir if ( rEvt.mbLeaving ) 3486*cdf0e10cSrcweir { 3487*cdf0e10cSrcweir DrawMarkDropObj( NULL ); 3488*cdf0e10cSrcweir if ( rData.pCellTransfer ) 3489*cdf0e10cSrcweir return AcceptPrivateDrop( rEvt ); // hide drop marker for internal D&D 3490*cdf0e10cSrcweir else 3491*cdf0e10cSrcweir return rEvt.mnAction; 3492*cdf0e10cSrcweir } 3493*cdf0e10cSrcweir 3494*cdf0e10cSrcweir if ( pViewData->GetDocShell()->IsReadOnly() ) 3495*cdf0e10cSrcweir return DND_ACTION_NONE; 3496*cdf0e10cSrcweir 3497*cdf0e10cSrcweir 3498*cdf0e10cSrcweir sal_Int8 nRet = DND_ACTION_NONE; 3499*cdf0e10cSrcweir 3500*cdf0e10cSrcweir if (rData.pCellTransfer) 3501*cdf0e10cSrcweir { 3502*cdf0e10cSrcweir ScRange aSource = rData.pCellTransfer->GetRange(); 3503*cdf0e10cSrcweir if ( aSource.aStart.Col() != 0 || aSource.aEnd.Col() != MAXCOL || 3504*cdf0e10cSrcweir aSource.aStart.Row() != 0 || aSource.aEnd.Row() != MAXROW ) 3505*cdf0e10cSrcweir DropScroll( rEvt.maPosPixel ); 3506*cdf0e10cSrcweir 3507*cdf0e10cSrcweir nRet = AcceptPrivateDrop( rEvt ); 3508*cdf0e10cSrcweir } 3509*cdf0e10cSrcweir else 3510*cdf0e10cSrcweir { 3511*cdf0e10cSrcweir if ( rData.aLinkDoc.Len() ) 3512*cdf0e10cSrcweir { 3513*cdf0e10cSrcweir String aThisName; 3514*cdf0e10cSrcweir ScDocShell* pDocSh = pViewData->GetDocShell(); 3515*cdf0e10cSrcweir if (pDocSh && pDocSh->HasName()) 3516*cdf0e10cSrcweir aThisName = pDocSh->GetMedium()->GetName(); 3517*cdf0e10cSrcweir 3518*cdf0e10cSrcweir if ( rData.aLinkDoc != aThisName ) 3519*cdf0e10cSrcweir nRet = rEvt.mnAction; 3520*cdf0e10cSrcweir } 3521*cdf0e10cSrcweir else if (rData.aJumpTarget.Len()) 3522*cdf0e10cSrcweir { 3523*cdf0e10cSrcweir // internal bookmarks (from Navigator) 3524*cdf0e10cSrcweir // local jumps from an unnamed document are possible only within a document 3525*cdf0e10cSrcweir 3526*cdf0e10cSrcweir if ( !rData.pJumpLocalDoc || rData.pJumpLocalDoc == pViewData->GetDocument() ) 3527*cdf0e10cSrcweir nRet = rEvt.mnAction; 3528*cdf0e10cSrcweir } 3529*cdf0e10cSrcweir else 3530*cdf0e10cSrcweir { 3531*cdf0e10cSrcweir sal_Int8 nMyAction = rEvt.mnAction; 3532*cdf0e10cSrcweir 3533*cdf0e10cSrcweir if ( !rData.pDrawTransfer || 3534*cdf0e10cSrcweir !IsMyModel(rData.pDrawTransfer->GetDragSourceView()) ) // drawing within the document 3535*cdf0e10cSrcweir if ( rEvt.mbDefault && nMyAction == DND_ACTION_MOVE ) 3536*cdf0e10cSrcweir nMyAction = DND_ACTION_COPY; 3537*cdf0e10cSrcweir 3538*cdf0e10cSrcweir ScDocument* pThisDoc = pViewData->GetDocument(); 3539*cdf0e10cSrcweir SdrObject* pHitObj = pThisDoc->GetObjectAtPoint( 3540*cdf0e10cSrcweir pViewData->GetTabNo(), PixelToLogic(rEvt.maPosPixel) ); 3541*cdf0e10cSrcweir if ( pHitObj && nMyAction == DND_ACTION_LINK && !rData.pDrawTransfer ) 3542*cdf0e10cSrcweir { 3543*cdf0e10cSrcweir if ( IsDropFormatSupported(SOT_FORMATSTR_ID_SVXB) 3544*cdf0e10cSrcweir || IsDropFormatSupported(SOT_FORMAT_GDIMETAFILE) 3545*cdf0e10cSrcweir || IsDropFormatSupported(SOT_FORMAT_BITMAP) ) 3546*cdf0e10cSrcweir { 3547*cdf0e10cSrcweir // graphic dragged onto drawing object 3548*cdf0e10cSrcweir DrawMarkDropObj( pHitObj ); 3549*cdf0e10cSrcweir nRet = nMyAction; 3550*cdf0e10cSrcweir } 3551*cdf0e10cSrcweir } 3552*cdf0e10cSrcweir if (!nRet) 3553*cdf0e10cSrcweir DrawMarkDropObj( NULL ); 3554*cdf0e10cSrcweir 3555*cdf0e10cSrcweir if (!nRet) 3556*cdf0e10cSrcweir { 3557*cdf0e10cSrcweir switch ( nMyAction ) 3558*cdf0e10cSrcweir { 3559*cdf0e10cSrcweir case DND_ACTION_COPY: 3560*cdf0e10cSrcweir case DND_ACTION_MOVE: 3561*cdf0e10cSrcweir case DND_ACTION_COPYMOVE: 3562*cdf0e10cSrcweir { 3563*cdf0e10cSrcweir sal_Bool bMove = ( nMyAction == DND_ACTION_MOVE ); 3564*cdf0e10cSrcweir if ( IsDropFormatSupported( SOT_FORMATSTR_ID_EMBED_SOURCE ) || 3565*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE ) || 3566*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) || 3567*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) || 3568*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) || 3569*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMAT_STRING ) || 3570*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_SYLK ) || 3571*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_LINK ) || 3572*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_HTML ) || 3573*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_HTML_SIMPLE ) || 3574*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_DIF ) || 3575*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_DRAWING ) || 3576*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_SVXB ) || 3577*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMAT_RTF ) || 3578*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMAT_GDIMETAFILE ) || 3579*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMAT_BITMAP ) || 3580*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) || 3581*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE ) || 3582*cdf0e10cSrcweir ( !bMove && ( 3583*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMAT_FILE_LIST ) || 3584*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMAT_FILE ) || 3585*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) || 3586*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) || 3587*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) || 3588*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ) ) ) 3589*cdf0e10cSrcweir { 3590*cdf0e10cSrcweir nRet = nMyAction; 3591*cdf0e10cSrcweir } 3592*cdf0e10cSrcweir } 3593*cdf0e10cSrcweir break; 3594*cdf0e10cSrcweir case DND_ACTION_LINK: 3595*cdf0e10cSrcweir if ( IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE ) || 3596*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) || 3597*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_LINK ) || 3598*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMAT_FILE_LIST ) || 3599*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMAT_FILE ) || 3600*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) || 3601*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) || 3602*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) || 3603*cdf0e10cSrcweir IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ) 3604*cdf0e10cSrcweir { 3605*cdf0e10cSrcweir nRet = nMyAction; 3606*cdf0e10cSrcweir } 3607*cdf0e10cSrcweir break; 3608*cdf0e10cSrcweir } 3609*cdf0e10cSrcweir 3610*cdf0e10cSrcweir if ( nRet ) 3611*cdf0e10cSrcweir { 3612*cdf0e10cSrcweir // Simple check for protection: It's not known here if the drop will result 3613*cdf0e10cSrcweir // in cells or drawing objects (some formats can be both) and how many cells 3614*cdf0e10cSrcweir // the result will be. But if IsFormatEditable for the drop cell position 3615*cdf0e10cSrcweir // is sal_False (ignores matrix formulas), nothing can be pasted, so the drop 3616*cdf0e10cSrcweir // can already be rejected here. 3617*cdf0e10cSrcweir 3618*cdf0e10cSrcweir Point aPos = rEvt.maPosPixel; 3619*cdf0e10cSrcweir SCsCOL nPosX; 3620*cdf0e10cSrcweir SCsROW nPosY; 3621*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 3622*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 3623*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 3624*cdf0e10cSrcweir 3625*cdf0e10cSrcweir ScEditableTester aTester( pDoc, nTab, nPosX,nPosY, nPosX,nPosY ); 3626*cdf0e10cSrcweir if ( !aTester.IsFormatEditable() ) 3627*cdf0e10cSrcweir nRet = DND_ACTION_NONE; // forbidden 3628*cdf0e10cSrcweir } 3629*cdf0e10cSrcweir } 3630*cdf0e10cSrcweir } 3631*cdf0e10cSrcweir 3632*cdf0e10cSrcweir // scroll only for accepted formats 3633*cdf0e10cSrcweir if (nRet) 3634*cdf0e10cSrcweir DropScroll( rEvt.maPosPixel ); 3635*cdf0e10cSrcweir } 3636*cdf0e10cSrcweir 3637*cdf0e10cSrcweir return nRet; 3638*cdf0e10cSrcweir } 3639*cdf0e10cSrcweir 3640*cdf0e10cSrcweir sal_uLong lcl_GetDropFormatId( const uno::Reference<datatransfer::XTransferable>& xTransfer, bool bPreferText = false ) 3641*cdf0e10cSrcweir { 3642*cdf0e10cSrcweir TransferableDataHelper aDataHelper( xTransfer ); 3643*cdf0e10cSrcweir 3644*cdf0e10cSrcweir if ( !aDataHelper.HasFormat( SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) ) 3645*cdf0e10cSrcweir { 3646*cdf0e10cSrcweir // use bookmark formats if no sba is present 3647*cdf0e10cSrcweir 3648*cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) ) 3649*cdf0e10cSrcweir return SOT_FORMATSTR_ID_SOLK; 3650*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ) 3651*cdf0e10cSrcweir return SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR; 3652*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) ) 3653*cdf0e10cSrcweir return SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK; 3654*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ) 3655*cdf0e10cSrcweir return SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR; 3656*cdf0e10cSrcweir } 3657*cdf0e10cSrcweir 3658*cdf0e10cSrcweir sal_uLong nFormatId = 0; 3659*cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) ) 3660*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_DRAWING; 3661*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) ) 3662*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_SVXB; 3663*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) ) 3664*cdf0e10cSrcweir { 3665*cdf0e10cSrcweir // If it's a Writer object, insert RTF instead of OLE 3666*cdf0e10cSrcweir 3667*cdf0e10cSrcweir sal_Bool bDoRtf = sal_False; 3668*cdf0e10cSrcweir SotStorageStreamRef xStm; 3669*cdf0e10cSrcweir TransferableObjectDescriptor aObjDesc; 3670*cdf0e10cSrcweir if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) && 3671*cdf0e10cSrcweir aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_EMBED_SOURCE, xStm ) ) 3672*cdf0e10cSrcweir { 3673*cdf0e10cSrcweir SotStorageRef xStore( new SotStorage( *xStm ) ); 3674*cdf0e10cSrcweir bDoRtf = ( ( aObjDesc.maClassName == SvGlobalName( SO3_SW_CLASSID ) || 3675*cdf0e10cSrcweir aObjDesc.maClassName == SvGlobalName( SO3_SWWEB_CLASSID ) ) 3676*cdf0e10cSrcweir && aDataHelper.HasFormat( SOT_FORMAT_RTF ) ); 3677*cdf0e10cSrcweir } 3678*cdf0e10cSrcweir if ( bDoRtf ) 3679*cdf0e10cSrcweir nFormatId = FORMAT_RTF; 3680*cdf0e10cSrcweir else 3681*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE; 3682*cdf0e10cSrcweir } 3683*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) ) 3684*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE; 3685*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) ) 3686*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_SBA_DATAEXCHANGE; 3687*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE ) ) 3688*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE; 3689*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_BIFF_8 ) ) 3690*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_BIFF_8; 3691*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_BIFF_5 ) ) 3692*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_BIFF_5; 3693*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) ) 3694*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE; 3695*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) ) 3696*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE; 3697*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) ) 3698*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE_OLE; 3699*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) ) 3700*cdf0e10cSrcweir nFormatId = SOT_FORMAT_RTF; 3701*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_HTML ) ) 3702*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_HTML; 3703*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_HTML_SIMPLE ) ) 3704*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_HTML_SIMPLE; 3705*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SYLK ) ) 3706*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_SYLK; 3707*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK ) ) 3708*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_LINK; 3709*cdf0e10cSrcweir else if ( bPreferText && aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) // #i86734# the behaviour introduced in #i62773# is wrong when pasting 3710*cdf0e10cSrcweir nFormatId = SOT_FORMAT_STRING; 3711*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) ) 3712*cdf0e10cSrcweir nFormatId = SOT_FORMAT_FILE_LIST; 3713*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE ) ) // #i62773# FILE_LIST/FILE before STRING (Unix file managers) 3714*cdf0e10cSrcweir nFormatId = SOT_FORMAT_FILE; 3715*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) 3716*cdf0e10cSrcweir nFormatId = SOT_FORMAT_STRING; 3717*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMAT_GDIMETAFILE ) ) 3718*cdf0e10cSrcweir nFormatId = SOT_FORMAT_GDIMETAFILE; 3719*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMAT_BITMAP ) ) 3720*cdf0e10cSrcweir nFormatId = SOT_FORMAT_BITMAP; 3721*cdf0e10cSrcweir 3722*cdf0e10cSrcweir return nFormatId; 3723*cdf0e10cSrcweir } 3724*cdf0e10cSrcweir 3725*cdf0e10cSrcweir sal_uLong lcl_GetDropLinkId( const uno::Reference<datatransfer::XTransferable>& xTransfer ) 3726*cdf0e10cSrcweir { 3727*cdf0e10cSrcweir TransferableDataHelper aDataHelper( xTransfer ); 3728*cdf0e10cSrcweir 3729*cdf0e10cSrcweir sal_uLong nFormatId = 0; 3730*cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) ) 3731*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE; 3732*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) ) 3733*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE_OLE; 3734*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK ) ) 3735*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_LINK; 3736*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) ) 3737*cdf0e10cSrcweir nFormatId = SOT_FORMAT_FILE_LIST; 3738*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE ) ) 3739*cdf0e10cSrcweir nFormatId = SOT_FORMAT_FILE; 3740*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) ) 3741*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_SOLK; 3742*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ) 3743*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR; 3744*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) ) 3745*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK; 3746*cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ) 3747*cdf0e10cSrcweir nFormatId = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR; 3748*cdf0e10cSrcweir 3749*cdf0e10cSrcweir return nFormatId; 3750*cdf0e10cSrcweir } 3751*cdf0e10cSrcweir 3752*cdf0e10cSrcweir 3753*cdf0e10cSrcweir sal_Int8 ScGridWindow::ExecutePrivateDrop( const ExecuteDropEvent& rEvt ) 3754*cdf0e10cSrcweir { 3755*cdf0e10cSrcweir // hide drop marker 3756*cdf0e10cSrcweir // if (bDragRect) 3757*cdf0e10cSrcweir // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich ); 3758*cdf0e10cSrcweir bDragRect = sal_False; 3759*cdf0e10cSrcweir UpdateDragRectOverlay(); 3760*cdf0e10cSrcweir 3761*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 3762*cdf0e10cSrcweir const ScDragData& rData = pScMod->GetDragData(); 3763*cdf0e10cSrcweir 3764*cdf0e10cSrcweir return DropTransferObj( rData.pCellTransfer, nDragStartX, nDragStartY, 3765*cdf0e10cSrcweir PixelToLogic(rEvt.maPosPixel), rEvt.mnAction ); 3766*cdf0e10cSrcweir } 3767*cdf0e10cSrcweir 3768*cdf0e10cSrcweir sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY, 3769*cdf0e10cSrcweir const Point& rLogicPos, sal_Int8 nDndAction ) 3770*cdf0e10cSrcweir { 3771*cdf0e10cSrcweir if ( !pTransObj ) 3772*cdf0e10cSrcweir return 0; 3773*cdf0e10cSrcweir 3774*cdf0e10cSrcweir ScDocument* pSourceDoc = pTransObj->GetSourceDocument(); 3775*cdf0e10cSrcweir ScDocShell* pDocSh = pViewData->GetDocShell(); 3776*cdf0e10cSrcweir ScDocument* pThisDoc = pViewData->GetDocument(); 3777*cdf0e10cSrcweir ScViewFunc* pView = pViewData->GetView(); 3778*cdf0e10cSrcweir SCTAB nThisTab = pViewData->GetTabNo(); 3779*cdf0e10cSrcweir sal_uInt16 nFlags = pTransObj->GetDragSourceFlags(); 3780*cdf0e10cSrcweir 3781*cdf0e10cSrcweir sal_Bool bIsNavi = ( nFlags & SC_DROP_NAVIGATOR ) != 0; 3782*cdf0e10cSrcweir sal_Bool bIsMove = ( nDndAction == DND_ACTION_MOVE && !bIsNavi ); 3783*cdf0e10cSrcweir 3784*cdf0e10cSrcweir // workaround for wrong nDndAction on Windows when pressing solely 3785*cdf0e10cSrcweir // the Alt key during drag and drop; 3786*cdf0e10cSrcweir // can be removed after #i79215# has been fixed 3787*cdf0e10cSrcweir if ( meDragInsertMode != INS_NONE ) 3788*cdf0e10cSrcweir { 3789*cdf0e10cSrcweir bIsMove = ( nDndAction & DND_ACTION_MOVE && !bIsNavi ); 3790*cdf0e10cSrcweir } 3791*cdf0e10cSrcweir 3792*cdf0e10cSrcweir sal_Bool bIsLink = ( nDndAction == DND_ACTION_LINK ); 3793*cdf0e10cSrcweir 3794*cdf0e10cSrcweir ScRange aSource = pTransObj->GetRange(); 3795*cdf0e10cSrcweir 3796*cdf0e10cSrcweir // only use visible tab from source range - when dragging within one table, 3797*cdf0e10cSrcweir // all selected tables at the time of dropping are used (handled in MoveBlockTo) 3798*cdf0e10cSrcweir SCTAB nSourceTab = pTransObj->GetVisibleTab(); 3799*cdf0e10cSrcweir aSource.aStart.SetTab( nSourceTab ); 3800*cdf0e10cSrcweir aSource.aEnd.SetTab( nSourceTab ); 3801*cdf0e10cSrcweir 3802*cdf0e10cSrcweir SCCOL nSizeX = aSource.aEnd.Col() - aSource.aStart.Col() + 1; 3803*cdf0e10cSrcweir SCROW nSizeY = (bIsMove ? (aSource.aEnd.Row() - aSource.aStart.Row() + 1) : 3804*cdf0e10cSrcweir pTransObj->GetNonFilteredRows()); // copy/link: no filtered rows 3805*cdf0e10cSrcweir ScRange aDest( nDestPosX, nDestPosY, nThisTab, 3806*cdf0e10cSrcweir nDestPosX + nSizeX - 1, nDestPosY + nSizeY - 1, nThisTab ); 3807*cdf0e10cSrcweir 3808*cdf0e10cSrcweir 3809*cdf0e10cSrcweir /* NOTE: AcceptPrivateDrop() already checked for filtered conditions during 3810*cdf0e10cSrcweir * dragging and adapted drawing of the selection frame. We check here 3811*cdf0e10cSrcweir * (again) because this may actually also be called from PasteSelection(), 3812*cdf0e10cSrcweir * we would have to duplicate determination of flags and destination range 3813*cdf0e10cSrcweir * and would lose the context of the "filtered destination is OK" cases 3814*cdf0e10cSrcweir * below, which is already awkward enough as is. */ 3815*cdf0e10cSrcweir 3816*cdf0e10cSrcweir // Don't move filtered source. 3817*cdf0e10cSrcweir bool bFiltered = (bIsMove && pTransObj->HasFilteredRows()); 3818*cdf0e10cSrcweir if (!bFiltered) 3819*cdf0e10cSrcweir { 3820*cdf0e10cSrcweir if (pSourceDoc != pThisDoc && ((nFlags & SC_DROP_TABLE) || 3821*cdf0e10cSrcweir (!bIsLink && meDragInsertMode == INS_NONE))) 3822*cdf0e10cSrcweir { 3823*cdf0e10cSrcweir // Nothing. Either entire sheet to be dropped, or the one case 3824*cdf0e10cSrcweir // where PasteFromClip() is to be called that handles a filtered 3825*cdf0e10cSrcweir // destination itself. Drag-copy from another document without 3826*cdf0e10cSrcweir // inserting cells. 3827*cdf0e10cSrcweir } 3828*cdf0e10cSrcweir else 3829*cdf0e10cSrcweir // Don't copy or move to filtered destination. 3830*cdf0e10cSrcweir bFiltered = ScViewUtil::HasFiltered( aDest, pThisDoc); 3831*cdf0e10cSrcweir } 3832*cdf0e10cSrcweir 3833*cdf0e10cSrcweir sal_Bool bDone = sal_False; 3834*cdf0e10cSrcweir 3835*cdf0e10cSrcweir if (!bFiltered && pSourceDoc == pThisDoc) 3836*cdf0e10cSrcweir { 3837*cdf0e10cSrcweir if ( nFlags & SC_DROP_TABLE ) // whole sheet? 3838*cdf0e10cSrcweir { 3839*cdf0e10cSrcweir if ( pThisDoc->IsDocEditable() ) 3840*cdf0e10cSrcweir { 3841*cdf0e10cSrcweir SCTAB nSrcTab = aSource.aStart.Tab(); 3842*cdf0e10cSrcweir pViewData->GetDocShell()->MoveTable( nSrcTab, nThisTab, !bIsMove, sal_True ); // with Undo 3843*cdf0e10cSrcweir pView->SetTabNo( nThisTab, sal_True ); 3844*cdf0e10cSrcweir bDone = sal_True; 3845*cdf0e10cSrcweir } 3846*cdf0e10cSrcweir } 3847*cdf0e10cSrcweir else // move/copy block 3848*cdf0e10cSrcweir { 3849*cdf0e10cSrcweir String aChartName; 3850*cdf0e10cSrcweir if (pThisDoc->HasChartAtPoint( nThisTab, rLogicPos, &aChartName )) 3851*cdf0e10cSrcweir { 3852*cdf0e10cSrcweir String aRangeName; 3853*cdf0e10cSrcweir aSource.Format( aRangeName, SCR_ABS_3D, pThisDoc ); 3854*cdf0e10cSrcweir SfxStringItem aNameItem( SID_CHART_NAME, aChartName ); 3855*cdf0e10cSrcweir SfxStringItem aRangeItem( SID_CHART_SOURCE, aRangeName ); 3856*cdf0e10cSrcweir sal_uInt16 nId = bIsMove ? SID_CHART_SOURCE : SID_CHART_ADDSOURCE; 3857*cdf0e10cSrcweir pViewData->GetDispatcher().Execute( nId, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 3858*cdf0e10cSrcweir &aRangeItem, &aNameItem, (void*) NULL ); 3859*cdf0e10cSrcweir bDone = sal_True; 3860*cdf0e10cSrcweir } 3861*cdf0e10cSrcweir else if ( pThisDoc->GetDPAtCursor( nDestPosX, nDestPosY, nThisTab ) ) 3862*cdf0e10cSrcweir { 3863*cdf0e10cSrcweir // drop on DataPilot table: try to sort, fail if that isn't possible 3864*cdf0e10cSrcweir 3865*cdf0e10cSrcweir ScAddress aDestPos( nDestPosX, nDestPosY, nThisTab ); 3866*cdf0e10cSrcweir if ( aDestPos != aSource.aStart ) 3867*cdf0e10cSrcweir bDone = pViewData->GetView()->DataPilotMove( aSource, aDestPos ); 3868*cdf0e10cSrcweir else 3869*cdf0e10cSrcweir bDone = sal_True; // same position: nothing 3870*cdf0e10cSrcweir } 3871*cdf0e10cSrcweir else if ( nDestPosX != aSource.aStart.Col() || nDestPosY != aSource.aStart.Row() || 3872*cdf0e10cSrcweir nSourceTab != nThisTab ) 3873*cdf0e10cSrcweir { 3874*cdf0e10cSrcweir String aUndo = ScGlobal::GetRscString( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY ); 3875*cdf0e10cSrcweir pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); 3876*cdf0e10cSrcweir 3877*cdf0e10cSrcweir bDone = sal_True; 3878*cdf0e10cSrcweir if ( meDragInsertMode != INS_NONE ) 3879*cdf0e10cSrcweir { 3880*cdf0e10cSrcweir // call with bApi = sal_True to avoid error messages in drop handler 3881*cdf0e10cSrcweir bDone = pDocSh->GetDocFunc().InsertCells( aDest, NULL, meDragInsertMode, sal_True /*bRecord*/, sal_True /*bApi*/, sal_True /*bPartOfPaste*/ ); 3882*cdf0e10cSrcweir if ( bDone ) 3883*cdf0e10cSrcweir { 3884*cdf0e10cSrcweir if ( nThisTab == nSourceTab ) 3885*cdf0e10cSrcweir { 3886*cdf0e10cSrcweir if ( meDragInsertMode == INS_CELLSDOWN && 3887*cdf0e10cSrcweir nDestPosX == aSource.aStart.Col() && nDestPosY < aSource.aStart.Row() ) 3888*cdf0e10cSrcweir { 3889*cdf0e10cSrcweir bDone = aSource.Move( 0, nSizeY, 0, pSourceDoc ); 3890*cdf0e10cSrcweir } 3891*cdf0e10cSrcweir else if ( meDragInsertMode == INS_CELLSRIGHT && 3892*cdf0e10cSrcweir nDestPosY == aSource.aStart.Row() && nDestPosX < aSource.aStart.Col() ) 3893*cdf0e10cSrcweir { 3894*cdf0e10cSrcweir bDone = aSource.Move( nSizeX, 0, 0, pSourceDoc ); 3895*cdf0e10cSrcweir } 3896*cdf0e10cSrcweir } 3897*cdf0e10cSrcweir pDocSh->UpdateOle( pViewData ); 3898*cdf0e10cSrcweir pView->CellContentChanged(); 3899*cdf0e10cSrcweir } 3900*cdf0e10cSrcweir } 3901*cdf0e10cSrcweir 3902*cdf0e10cSrcweir if ( bDone ) 3903*cdf0e10cSrcweir { 3904*cdf0e10cSrcweir if ( bIsLink ) 3905*cdf0e10cSrcweir { 3906*cdf0e10cSrcweir // call with bApi = sal_True to avoid error messages in drop handler 3907*cdf0e10cSrcweir bDone = pView->LinkBlock( aSource, aDest.aStart, sal_True /*bApi*/ ); 3908*cdf0e10cSrcweir } 3909*cdf0e10cSrcweir else 3910*cdf0e10cSrcweir { 3911*cdf0e10cSrcweir // call with bApi = sal_True to avoid error messages in drop handler 3912*cdf0e10cSrcweir bDone = pView->MoveBlockTo( aSource, aDest.aStart, bIsMove, sal_True /*bRecord*/, sal_True /*bPaint*/, sal_True /*bApi*/ ); 3913*cdf0e10cSrcweir } 3914*cdf0e10cSrcweir } 3915*cdf0e10cSrcweir 3916*cdf0e10cSrcweir if ( bDone && meDragInsertMode != INS_NONE && bIsMove && nThisTab == nSourceTab ) 3917*cdf0e10cSrcweir { 3918*cdf0e10cSrcweir DelCellCmd eCmd = DEL_NONE; 3919*cdf0e10cSrcweir if ( meDragInsertMode == INS_CELLSDOWN ) 3920*cdf0e10cSrcweir { 3921*cdf0e10cSrcweir eCmd = DEL_CELLSUP; 3922*cdf0e10cSrcweir } 3923*cdf0e10cSrcweir else if ( meDragInsertMode == INS_CELLSRIGHT ) 3924*cdf0e10cSrcweir { 3925*cdf0e10cSrcweir eCmd = DEL_CELLSLEFT; 3926*cdf0e10cSrcweir } 3927*cdf0e10cSrcweir 3928*cdf0e10cSrcweir if ( ( eCmd == DEL_CELLSUP && nDestPosX == aSource.aStart.Col() ) || 3929*cdf0e10cSrcweir ( eCmd == DEL_CELLSLEFT && nDestPosY == aSource.aStart.Row() ) ) 3930*cdf0e10cSrcweir { 3931*cdf0e10cSrcweir // call with bApi = sal_True to avoid error messages in drop handler 3932*cdf0e10cSrcweir bDone = pDocSh->GetDocFunc().DeleteCells( aSource, NULL, eCmd, sal_True /*bRecord*/, sal_True /*bApi*/ ); 3933*cdf0e10cSrcweir if ( bDone ) 3934*cdf0e10cSrcweir { 3935*cdf0e10cSrcweir if ( eCmd == DEL_CELLSUP && nDestPosY > aSource.aEnd.Row() ) 3936*cdf0e10cSrcweir { 3937*cdf0e10cSrcweir bDone = aDest.Move( 0, -nSizeY, 0, pThisDoc ); 3938*cdf0e10cSrcweir } 3939*cdf0e10cSrcweir else if ( eCmd == DEL_CELLSLEFT && nDestPosX > aSource.aEnd.Col() ) 3940*cdf0e10cSrcweir { 3941*cdf0e10cSrcweir bDone = aDest.Move( -nSizeX, 0, 0, pThisDoc ); 3942*cdf0e10cSrcweir } 3943*cdf0e10cSrcweir pDocSh->UpdateOle( pViewData ); 3944*cdf0e10cSrcweir pView->CellContentChanged(); 3945*cdf0e10cSrcweir } 3946*cdf0e10cSrcweir } 3947*cdf0e10cSrcweir } 3948*cdf0e10cSrcweir 3949*cdf0e10cSrcweir if ( bDone ) 3950*cdf0e10cSrcweir { 3951*cdf0e10cSrcweir pView->MarkRange( aDest, sal_False, sal_False ); 3952*cdf0e10cSrcweir pView->SetCursor( aDest.aEnd.Col(), aDest.aEnd.Row() ); 3953*cdf0e10cSrcweir } 3954*cdf0e10cSrcweir 3955*cdf0e10cSrcweir pDocSh->GetUndoManager()->LeaveListAction(); 3956*cdf0e10cSrcweir 3957*cdf0e10cSrcweir if (!bDone) 3958*cdf0e10cSrcweir Sound::Beep(); // instead of error message in drop handler 3959*cdf0e10cSrcweir } 3960*cdf0e10cSrcweir else 3961*cdf0e10cSrcweir bDone = sal_True; // nothing to do 3962*cdf0e10cSrcweir } 3963*cdf0e10cSrcweir 3964*cdf0e10cSrcweir if (bDone) 3965*cdf0e10cSrcweir pTransObj->SetDragWasInternal(); // don't delete source in DragFinished 3966*cdf0e10cSrcweir } 3967*cdf0e10cSrcweir else if ( !bFiltered && pSourceDoc ) // between documents 3968*cdf0e10cSrcweir { 3969*cdf0e10cSrcweir if ( nFlags & SC_DROP_TABLE ) // copy/link sheets between documents 3970*cdf0e10cSrcweir { 3971*cdf0e10cSrcweir if ( pThisDoc->IsDocEditable() ) 3972*cdf0e10cSrcweir { 3973*cdf0e10cSrcweir ScDocShell* pSrcShell = pTransObj->GetSourceDocShell(); 3974*cdf0e10cSrcweir 3975*cdf0e10cSrcweir SCTAB nTabs[MAXTABCOUNT]; 3976*cdf0e10cSrcweir 3977*cdf0e10cSrcweir ScMarkData aMark = pTransObj->GetSourceMarkData(); 3978*cdf0e10cSrcweir SCTAB nTabCount = pSourceDoc->GetTableCount(); 3979*cdf0e10cSrcweir SCTAB nTabSelCount = 0; 3980*cdf0e10cSrcweir 3981*cdf0e10cSrcweir for(SCTAB i=0; i<nTabCount; i++) 3982*cdf0e10cSrcweir { 3983*cdf0e10cSrcweir if(aMark.GetTableSelect(i)) 3984*cdf0e10cSrcweir { 3985*cdf0e10cSrcweir nTabs[nTabSelCount++]=i; 3986*cdf0e10cSrcweir for(SCTAB j=i+1;j<nTabCount;j++) 3987*cdf0e10cSrcweir { 3988*cdf0e10cSrcweir if((!pSourceDoc->IsVisible(j))&&(pSourceDoc->IsScenario(j))) 3989*cdf0e10cSrcweir { 3990*cdf0e10cSrcweir nTabs[nTabSelCount++]=j; 3991*cdf0e10cSrcweir i=j; 3992*cdf0e10cSrcweir } 3993*cdf0e10cSrcweir else break; 3994*cdf0e10cSrcweir } 3995*cdf0e10cSrcweir } 3996*cdf0e10cSrcweir } 3997*cdf0e10cSrcweir 3998*cdf0e10cSrcweir pView->ImportTables( pSrcShell,nTabSelCount, nTabs, bIsLink, nThisTab ); 3999*cdf0e10cSrcweir bDone = sal_True; 4000*cdf0e10cSrcweir } 4001*cdf0e10cSrcweir } 4002*cdf0e10cSrcweir else if ( bIsLink ) 4003*cdf0e10cSrcweir { 4004*cdf0e10cSrcweir // as in PasteDDE 4005*cdf0e10cSrcweir // (external references might be used instead?) 4006*cdf0e10cSrcweir 4007*cdf0e10cSrcweir SfxObjectShell* pSourceSh = pSourceDoc->GetDocumentShell(); 4008*cdf0e10cSrcweir DBG_ASSERT(pSourceSh, "drag document has no shell"); 4009*cdf0e10cSrcweir if (pSourceSh) 4010*cdf0e10cSrcweir { 4011*cdf0e10cSrcweir String aUndo = ScGlobal::GetRscString( STR_UNDO_COPY ); 4012*cdf0e10cSrcweir pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); 4013*cdf0e10cSrcweir 4014*cdf0e10cSrcweir bDone = sal_True; 4015*cdf0e10cSrcweir if ( meDragInsertMode != INS_NONE ) 4016*cdf0e10cSrcweir { 4017*cdf0e10cSrcweir // call with bApi = sal_True to avoid error messages in drop handler 4018*cdf0e10cSrcweir bDone = pDocSh->GetDocFunc().InsertCells( aDest, NULL, meDragInsertMode, sal_True /*bRecord*/, sal_True /*bApi*/, sal_True /*bPartOfPaste*/ ); 4019*cdf0e10cSrcweir if ( bDone ) 4020*cdf0e10cSrcweir { 4021*cdf0e10cSrcweir pDocSh->UpdateOle( pViewData ); 4022*cdf0e10cSrcweir pView->CellContentChanged(); 4023*cdf0e10cSrcweir } 4024*cdf0e10cSrcweir } 4025*cdf0e10cSrcweir 4026*cdf0e10cSrcweir if ( bDone ) 4027*cdf0e10cSrcweir { 4028*cdf0e10cSrcweir String aApp = Application::GetAppName(); 4029*cdf0e10cSrcweir String aTopic = pSourceSh->GetTitle( SFX_TITLE_FULLNAME ); 4030*cdf0e10cSrcweir String aItem; 4031*cdf0e10cSrcweir aSource.Format( aItem, SCA_VALID | SCA_TAB_3D, pSourceDoc ); 4032*cdf0e10cSrcweir 4033*cdf0e10cSrcweir // TODO: we could define ocQuote for " 4034*cdf0e10cSrcweir const String aQuote( '"' ); 4035*cdf0e10cSrcweir const String& sSep = ScCompiler::GetNativeSymbol( ocSep); 4036*cdf0e10cSrcweir String aFormula( '=' ); 4037*cdf0e10cSrcweir aFormula += ScCompiler::GetNativeSymbol( ocDde); 4038*cdf0e10cSrcweir aFormula += ScCompiler::GetNativeSymbol( ocOpen); 4039*cdf0e10cSrcweir aFormula += aQuote; 4040*cdf0e10cSrcweir aFormula += aApp; 4041*cdf0e10cSrcweir aFormula += aQuote; 4042*cdf0e10cSrcweir aFormula += sSep; 4043*cdf0e10cSrcweir aFormula += aQuote; 4044*cdf0e10cSrcweir aFormula += aTopic; 4045*cdf0e10cSrcweir aFormula += aQuote; 4046*cdf0e10cSrcweir aFormula += sSep; 4047*cdf0e10cSrcweir aFormula += aQuote; 4048*cdf0e10cSrcweir aFormula += aItem; 4049*cdf0e10cSrcweir aFormula += aQuote; 4050*cdf0e10cSrcweir aFormula += ScCompiler::GetNativeSymbol( ocClose); 4051*cdf0e10cSrcweir 4052*cdf0e10cSrcweir pView->DoneBlockMode(); 4053*cdf0e10cSrcweir pView->InitBlockMode( nDestPosX, nDestPosY, nThisTab ); 4054*cdf0e10cSrcweir pView->MarkCursor( nDestPosX + nSizeX - 1, 4055*cdf0e10cSrcweir nDestPosY + nSizeY - 1, nThisTab ); 4056*cdf0e10cSrcweir 4057*cdf0e10cSrcweir pView->EnterMatrix( aFormula ); 4058*cdf0e10cSrcweir 4059*cdf0e10cSrcweir pView->MarkRange( aDest, sal_False, sal_False ); 4060*cdf0e10cSrcweir pView->SetCursor( aDest.aEnd.Col(), aDest.aEnd.Row() ); 4061*cdf0e10cSrcweir } 4062*cdf0e10cSrcweir 4063*cdf0e10cSrcweir pDocSh->GetUndoManager()->LeaveListAction(); 4064*cdf0e10cSrcweir } 4065*cdf0e10cSrcweir } 4066*cdf0e10cSrcweir else 4067*cdf0e10cSrcweir { 4068*cdf0e10cSrcweir //! HasSelectedBlockMatrixFragment without selected sheet? 4069*cdf0e10cSrcweir //! or don't start dragging on a part of a matrix 4070*cdf0e10cSrcweir 4071*cdf0e10cSrcweir String aUndo = ScGlobal::GetRscString( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY ); 4072*cdf0e10cSrcweir pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo ); 4073*cdf0e10cSrcweir 4074*cdf0e10cSrcweir bDone = sal_True; 4075*cdf0e10cSrcweir if ( meDragInsertMode != INS_NONE ) 4076*cdf0e10cSrcweir { 4077*cdf0e10cSrcweir // call with bApi = sal_True to avoid error messages in drop handler 4078*cdf0e10cSrcweir bDone = pDocSh->GetDocFunc().InsertCells( aDest, NULL, meDragInsertMode, sal_True /*bRecord*/, sal_True /*bApi*/, sal_True /*bPartOfPaste*/ ); 4079*cdf0e10cSrcweir if ( bDone ) 4080*cdf0e10cSrcweir { 4081*cdf0e10cSrcweir pDocSh->UpdateOle( pViewData ); 4082*cdf0e10cSrcweir pView->CellContentChanged(); 4083*cdf0e10cSrcweir } 4084*cdf0e10cSrcweir } 4085*cdf0e10cSrcweir 4086*cdf0e10cSrcweir if ( bDone ) 4087*cdf0e10cSrcweir { 4088*cdf0e10cSrcweir pView->Unmark(); // before SetCursor, so CheckSelectionTransfer isn't called with a selection 4089*cdf0e10cSrcweir pView->SetCursor( nDestPosX, nDestPosY ); 4090*cdf0e10cSrcweir bDone = pView->PasteFromClip( IDF_ALL, pTransObj->GetDocument() ); // clip-doc 4091*cdf0e10cSrcweir if ( bDone ) 4092*cdf0e10cSrcweir { 4093*cdf0e10cSrcweir pView->MarkRange( aDest, sal_False, sal_False ); 4094*cdf0e10cSrcweir pView->SetCursor( aDest.aEnd.Col(), aDest.aEnd.Row() ); 4095*cdf0e10cSrcweir } 4096*cdf0e10cSrcweir } 4097*cdf0e10cSrcweir 4098*cdf0e10cSrcweir pDocSh->GetUndoManager()->LeaveListAction(); 4099*cdf0e10cSrcweir 4100*cdf0e10cSrcweir // no longer call ResetMark here - the inserted block has been selected 4101*cdf0e10cSrcweir // and may have been copied to primary selection 4102*cdf0e10cSrcweir } 4103*cdf0e10cSrcweir } 4104*cdf0e10cSrcweir 4105*cdf0e10cSrcweir sal_Int8 nRet = bDone ? nDndAction : DND_ACTION_NONE; 4106*cdf0e10cSrcweir return nRet; 4107*cdf0e10cSrcweir } 4108*cdf0e10cSrcweir 4109*cdf0e10cSrcweir sal_Int8 ScGridWindow::ExecuteDrop( const ExecuteDropEvent& rEvt ) 4110*cdf0e10cSrcweir { 4111*cdf0e10cSrcweir DrawMarkDropObj( NULL ); // drawing layer 4112*cdf0e10cSrcweir 4113*cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 4114*cdf0e10cSrcweir const ScDragData& rData = pScMod->GetDragData(); 4115*cdf0e10cSrcweir if (rData.pCellTransfer) 4116*cdf0e10cSrcweir return ExecutePrivateDrop( rEvt ); 4117*cdf0e10cSrcweir 4118*cdf0e10cSrcweir Point aPos = rEvt.maPosPixel; 4119*cdf0e10cSrcweir 4120*cdf0e10cSrcweir if ( rData.aLinkDoc.Len() ) 4121*cdf0e10cSrcweir { 4122*cdf0e10cSrcweir // try to insert a link 4123*cdf0e10cSrcweir 4124*cdf0e10cSrcweir sal_Bool bOk = sal_True; 4125*cdf0e10cSrcweir String aThisName; 4126*cdf0e10cSrcweir ScDocShell* pDocSh = pViewData->GetDocShell(); 4127*cdf0e10cSrcweir if (pDocSh && pDocSh->HasName()) 4128*cdf0e10cSrcweir aThisName = pDocSh->GetMedium()->GetName(); 4129*cdf0e10cSrcweir 4130*cdf0e10cSrcweir if ( rData.aLinkDoc == aThisName ) // error - no link within a document 4131*cdf0e10cSrcweir bOk = sal_False; 4132*cdf0e10cSrcweir else 4133*cdf0e10cSrcweir { 4134*cdf0e10cSrcweir ScViewFunc* pView = pViewData->GetView(); 4135*cdf0e10cSrcweir if ( rData.aLinkTable.Len() ) 4136*cdf0e10cSrcweir pView->InsertTableLink( rData.aLinkDoc, EMPTY_STRING, EMPTY_STRING, 4137*cdf0e10cSrcweir rData.aLinkTable ); 4138*cdf0e10cSrcweir else if ( rData.aLinkArea.Len() ) 4139*cdf0e10cSrcweir { 4140*cdf0e10cSrcweir SCsCOL nPosX; 4141*cdf0e10cSrcweir SCsROW nPosY; 4142*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 4143*cdf0e10cSrcweir pView->MoveCursorAbs( nPosX, nPosY, SC_FOLLOW_NONE, sal_False, sal_False ); 4144*cdf0e10cSrcweir 4145*cdf0e10cSrcweir pView->InsertAreaLink( rData.aLinkDoc, EMPTY_STRING, EMPTY_STRING, 4146*cdf0e10cSrcweir rData.aLinkArea, 0 ); 4147*cdf0e10cSrcweir } 4148*cdf0e10cSrcweir else 4149*cdf0e10cSrcweir { 4150*cdf0e10cSrcweir DBG_ERROR("drop with link: no sheet nor area"); 4151*cdf0e10cSrcweir bOk = sal_False; 4152*cdf0e10cSrcweir } 4153*cdf0e10cSrcweir } 4154*cdf0e10cSrcweir 4155*cdf0e10cSrcweir return bOk ? rEvt.mnAction : DND_ACTION_NONE; // don't try anything else 4156*cdf0e10cSrcweir } 4157*cdf0e10cSrcweir 4158*cdf0e10cSrcweir Point aLogicPos = PixelToLogic(aPos); 4159*cdf0e10cSrcweir 4160*cdf0e10cSrcweir if (rData.pDrawTransfer) 4161*cdf0e10cSrcweir { 4162*cdf0e10cSrcweir sal_uInt16 nFlags = rData.pDrawTransfer->GetDragSourceFlags(); 4163*cdf0e10cSrcweir 4164*cdf0e10cSrcweir sal_Bool bIsNavi = ( nFlags & SC_DROP_NAVIGATOR ) != 0; 4165*cdf0e10cSrcweir sal_Bool bIsMove = ( rEvt.mnAction == DND_ACTION_MOVE && !bIsNavi ); 4166*cdf0e10cSrcweir 4167*cdf0e10cSrcweir bPasteIsMove = bIsMove; 4168*cdf0e10cSrcweir 4169*cdf0e10cSrcweir pViewData->GetView()->PasteDraw( aLogicPos, rData.pDrawTransfer->GetModel() ); 4170*cdf0e10cSrcweir 4171*cdf0e10cSrcweir if (bPasteIsMove) 4172*cdf0e10cSrcweir rData.pDrawTransfer->SetDragWasInternal(); 4173*cdf0e10cSrcweir bPasteIsMove = sal_False; 4174*cdf0e10cSrcweir 4175*cdf0e10cSrcweir return rEvt.mnAction; 4176*cdf0e10cSrcweir } 4177*cdf0e10cSrcweir 4178*cdf0e10cSrcweir 4179*cdf0e10cSrcweir SCsCOL nPosX; 4180*cdf0e10cSrcweir SCsROW nPosY; 4181*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 4182*cdf0e10cSrcweir 4183*cdf0e10cSrcweir if (rData.aJumpTarget.Len()) 4184*cdf0e10cSrcweir { 4185*cdf0e10cSrcweir // internal bookmark (from Navigator) 4186*cdf0e10cSrcweir // bookmark clipboard formats are in PasteScDataObject 4187*cdf0e10cSrcweir 4188*cdf0e10cSrcweir if ( !rData.pJumpLocalDoc || rData.pJumpLocalDoc == pViewData->GetDocument() ) 4189*cdf0e10cSrcweir { 4190*cdf0e10cSrcweir pViewData->GetViewShell()->InsertBookmark( rData.aJumpText, rData.aJumpTarget, 4191*cdf0e10cSrcweir nPosX, nPosY ); 4192*cdf0e10cSrcweir return rEvt.mnAction; 4193*cdf0e10cSrcweir } 4194*cdf0e10cSrcweir } 4195*cdf0e10cSrcweir 4196*cdf0e10cSrcweir sal_Bool bIsLink = ( rEvt.mnAction == DND_ACTION_LINK ); 4197*cdf0e10cSrcweir 4198*cdf0e10cSrcweir ScDocument* pThisDoc = pViewData->GetDocument(); 4199*cdf0e10cSrcweir SdrObject* pHitObj = pThisDoc->GetObjectAtPoint( pViewData->GetTabNo(), PixelToLogic(aPos) ); 4200*cdf0e10cSrcweir if ( pHitObj && bIsLink ) 4201*cdf0e10cSrcweir { 4202*cdf0e10cSrcweir // dropped on drawing object 4203*cdf0e10cSrcweir // PasteOnDrawObject checks for valid formats 4204*cdf0e10cSrcweir if ( pViewData->GetView()->PasteOnDrawObject( rEvt.maDropEvent.Transferable, pHitObj, sal_True ) ) 4205*cdf0e10cSrcweir return rEvt.mnAction; 4206*cdf0e10cSrcweir } 4207*cdf0e10cSrcweir 4208*cdf0e10cSrcweir sal_Bool bDone = sal_False; 4209*cdf0e10cSrcweir 4210*cdf0e10cSrcweir sal_uLong nFormatId = bIsLink ? 4211*cdf0e10cSrcweir lcl_GetDropLinkId( rEvt.maDropEvent.Transferable ) : 4212*cdf0e10cSrcweir lcl_GetDropFormatId( rEvt.maDropEvent.Transferable ); 4213*cdf0e10cSrcweir if ( nFormatId ) 4214*cdf0e10cSrcweir { 4215*cdf0e10cSrcweir pScMod->SetInExecuteDrop( sal_True ); // #i28468# prevent error messages from PasteDataFormat 4216*cdf0e10cSrcweir bPasteIsDrop = sal_True; 4217*cdf0e10cSrcweir bDone = pViewData->GetView()->PasteDataFormat( 4218*cdf0e10cSrcweir nFormatId, rEvt.maDropEvent.Transferable, nPosX, nPosY, &aLogicPos, bIsLink ); 4219*cdf0e10cSrcweir bPasteIsDrop = sal_False; 4220*cdf0e10cSrcweir pScMod->SetInExecuteDrop( sal_False ); 4221*cdf0e10cSrcweir } 4222*cdf0e10cSrcweir 4223*cdf0e10cSrcweir sal_Int8 nRet = bDone ? rEvt.mnAction : DND_ACTION_NONE; 4224*cdf0e10cSrcweir return nRet; 4225*cdf0e10cSrcweir } 4226*cdf0e10cSrcweir 4227*cdf0e10cSrcweir //-------------------------------------------------------- 4228*cdf0e10cSrcweir 4229*cdf0e10cSrcweir void ScGridWindow::PasteSelection( const Point& rPosPixel ) 4230*cdf0e10cSrcweir { 4231*cdf0e10cSrcweir Point aLogicPos = PixelToLogic( rPosPixel ); 4232*cdf0e10cSrcweir 4233*cdf0e10cSrcweir SCsCOL nPosX; 4234*cdf0e10cSrcweir SCsROW nPosY; 4235*cdf0e10cSrcweir pViewData->GetPosFromPixel( rPosPixel.X(), rPosPixel.Y(), eWhich, nPosX, nPosY ); 4236*cdf0e10cSrcweir 4237*cdf0e10cSrcweir ScSelectionTransferObj* pOwnSelection = SC_MOD()->GetSelectionTransfer(); 4238*cdf0e10cSrcweir if ( pOwnSelection ) 4239*cdf0e10cSrcweir { 4240*cdf0e10cSrcweir // within Calc 4241*cdf0e10cSrcweir 4242*cdf0e10cSrcweir ScTransferObj* pCellTransfer = pOwnSelection->GetCellData(); 4243*cdf0e10cSrcweir if ( pCellTransfer ) 4244*cdf0e10cSrcweir { 4245*cdf0e10cSrcweir // keep a reference to the data in case the selection is changed during paste 4246*cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xRef( pCellTransfer ); 4247*cdf0e10cSrcweir DropTransferObj( pCellTransfer, nPosX, nPosY, aLogicPos, DND_ACTION_COPY ); 4248*cdf0e10cSrcweir } 4249*cdf0e10cSrcweir else 4250*cdf0e10cSrcweir { 4251*cdf0e10cSrcweir ScDrawTransferObj* pDrawTransfer = pOwnSelection->GetDrawData(); 4252*cdf0e10cSrcweir if ( pDrawTransfer ) 4253*cdf0e10cSrcweir { 4254*cdf0e10cSrcweir // keep a reference to the data in case the selection is changed during paste 4255*cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xRef( pDrawTransfer ); 4256*cdf0e10cSrcweir 4257*cdf0e10cSrcweir // #96821# bSameDocClipboard argument for PasteDraw is needed 4258*cdf0e10cSrcweir // because only DragData is checked directly inside PasteDraw 4259*cdf0e10cSrcweir pViewData->GetView()->PasteDraw( aLogicPos, pDrawTransfer->GetModel(), sal_False, 4260*cdf0e10cSrcweir pDrawTransfer->GetSourceDocID() == pViewData->GetDocument()->GetDocumentID() ); 4261*cdf0e10cSrcweir } 4262*cdf0e10cSrcweir } 4263*cdf0e10cSrcweir } 4264*cdf0e10cSrcweir else 4265*cdf0e10cSrcweir { 4266*cdf0e10cSrcweir // get selection from system 4267*cdf0e10cSrcweir 4268*cdf0e10cSrcweir TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( this ) ); 4269*cdf0e10cSrcweir uno::Reference<datatransfer::XTransferable> xTransferable = aDataHelper.GetTransferable(); 4270*cdf0e10cSrcweir if ( xTransferable.is() ) 4271*cdf0e10cSrcweir { 4272*cdf0e10cSrcweir sal_uLong nFormatId = lcl_GetDropFormatId( xTransferable, true ); 4273*cdf0e10cSrcweir if ( nFormatId ) 4274*cdf0e10cSrcweir { 4275*cdf0e10cSrcweir bPasteIsDrop = sal_True; 4276*cdf0e10cSrcweir pViewData->GetView()->PasteDataFormat( nFormatId, xTransferable, nPosX, nPosY, &aLogicPos ); 4277*cdf0e10cSrcweir bPasteIsDrop = sal_False; 4278*cdf0e10cSrcweir } 4279*cdf0e10cSrcweir } 4280*cdf0e10cSrcweir } 4281*cdf0e10cSrcweir } 4282*cdf0e10cSrcweir 4283*cdf0e10cSrcweir //-------------------------------------------------------- 4284*cdf0e10cSrcweir 4285*cdf0e10cSrcweir void ScGridWindow::UpdateEditViewPos() 4286*cdf0e10cSrcweir { 4287*cdf0e10cSrcweir if (pViewData->HasEditView(eWhich)) 4288*cdf0e10cSrcweir { 4289*cdf0e10cSrcweir EditView* pView; 4290*cdf0e10cSrcweir SCCOL nCol; 4291*cdf0e10cSrcweir SCROW nRow; 4292*cdf0e10cSrcweir pViewData->GetEditView( eWhich, pView, nCol, nRow ); 4293*cdf0e10cSrcweir SCCOL nEndCol = pViewData->GetEditEndCol(); 4294*cdf0e10cSrcweir SCROW nEndRow = pViewData->GetEditEndRow(); 4295*cdf0e10cSrcweir 4296*cdf0e10cSrcweir // hide EditView? 4297*cdf0e10cSrcweir 4298*cdf0e10cSrcweir sal_Bool bHide = ( nEndCol<pViewData->GetPosX(eHWhich) || nEndRow<pViewData->GetPosY(eVWhich) ); 4299*cdf0e10cSrcweir if ( SC_MOD()->IsFormulaMode() ) 4300*cdf0e10cSrcweir if ( pViewData->GetTabNo() != pViewData->GetRefTabNo() ) 4301*cdf0e10cSrcweir bHide = sal_True; 4302*cdf0e10cSrcweir 4303*cdf0e10cSrcweir if (bHide) 4304*cdf0e10cSrcweir { 4305*cdf0e10cSrcweir Rectangle aRect = pView->GetOutputArea(); 4306*cdf0e10cSrcweir long nHeight = aRect.Bottom() - aRect.Top(); 4307*cdf0e10cSrcweir aRect.Top() = PixelToLogic(GetOutputSizePixel(), pViewData->GetLogicMode()). 4308*cdf0e10cSrcweir Height() * 2; 4309*cdf0e10cSrcweir aRect.Bottom() = aRect.Top() + nHeight; 4310*cdf0e10cSrcweir pView->SetOutputArea( aRect ); 4311*cdf0e10cSrcweir pView->HideCursor(); 4312*cdf0e10cSrcweir } 4313*cdf0e10cSrcweir else 4314*cdf0e10cSrcweir { 4315*cdf0e10cSrcweir // bForceToTop = sal_True for editing 4316*cdf0e10cSrcweir Rectangle aPixRect = pViewData->GetEditArea( eWhich, nCol, nRow, this, NULL, sal_True ); 4317*cdf0e10cSrcweir Point aScrPos = PixelToLogic( aPixRect.TopLeft(), pViewData->GetLogicMode() ); 4318*cdf0e10cSrcweir 4319*cdf0e10cSrcweir Rectangle aRect = pView->GetOutputArea(); 4320*cdf0e10cSrcweir aRect.SetPos( aScrPos ); 4321*cdf0e10cSrcweir pView->SetOutputArea( aRect ); 4322*cdf0e10cSrcweir pView->ShowCursor(); 4323*cdf0e10cSrcweir } 4324*cdf0e10cSrcweir } 4325*cdf0e10cSrcweir } 4326*cdf0e10cSrcweir 4327*cdf0e10cSrcweir void ScGridWindow::ScrollPixel( long nDifX, long nDifY ) 4328*cdf0e10cSrcweir { 4329*cdf0e10cSrcweir ClickExtern(); 4330*cdf0e10cSrcweir HideNoteMarker(); 4331*cdf0e10cSrcweir 4332*cdf0e10cSrcweir bIsInScroll = sal_True; 4333*cdf0e10cSrcweir //sal_Bool bXor=DrawBeforeScroll(); 4334*cdf0e10cSrcweir 4335*cdf0e10cSrcweir SetMapMode(MAP_PIXEL); 4336*cdf0e10cSrcweir Scroll( nDifX, nDifY, SCROLL_CHILDREN ); 4337*cdf0e10cSrcweir SetMapMode( GetDrawMapMode() ); // verschobenen MapMode erzeugen 4338*cdf0e10cSrcweir 4339*cdf0e10cSrcweir UpdateEditViewPos(); 4340*cdf0e10cSrcweir 4341*cdf0e10cSrcweir DrawAfterScroll(); //bXor); 4342*cdf0e10cSrcweir bIsInScroll = sal_False; 4343*cdf0e10cSrcweir } 4344*cdf0e10cSrcweir 4345*cdf0e10cSrcweir // Formeln neu zeichnen ------------------------------------------------- 4346*cdf0e10cSrcweir 4347*cdf0e10cSrcweir void ScGridWindow::UpdateFormulas() 4348*cdf0e10cSrcweir { 4349*cdf0e10cSrcweir if (pViewData->GetView()->IsMinimized()) 4350*cdf0e10cSrcweir return; 4351*cdf0e10cSrcweir 4352*cdf0e10cSrcweir if ( nPaintCount ) 4353*cdf0e10cSrcweir { 4354*cdf0e10cSrcweir // nicht anfangen, verschachtelt zu painten 4355*cdf0e10cSrcweir // (dann wuerde zumindest der MapMode nicht mehr stimmen) 4356*cdf0e10cSrcweir 4357*cdf0e10cSrcweir bNeedsRepaint = sal_True; // -> am Ende vom Paint nochmal Invalidate auf alles 4358*cdf0e10cSrcweir aRepaintPixel = Rectangle(); // alles 4359*cdf0e10cSrcweir return; 4360*cdf0e10cSrcweir } 4361*cdf0e10cSrcweir 4362*cdf0e10cSrcweir SCCOL nX1 = pViewData->GetPosX( eHWhich ); 4363*cdf0e10cSrcweir SCROW nY1 = pViewData->GetPosY( eVWhich ); 4364*cdf0e10cSrcweir SCCOL nX2 = nX1 + pViewData->VisibleCellsX( eHWhich ); 4365*cdf0e10cSrcweir SCROW nY2 = nY1 + pViewData->VisibleCellsY( eVWhich ); 4366*cdf0e10cSrcweir 4367*cdf0e10cSrcweir if (nX2 > MAXCOL) nX2 = MAXCOL; 4368*cdf0e10cSrcweir if (nY2 > MAXROW) nY2 = MAXROW; 4369*cdf0e10cSrcweir 4370*cdf0e10cSrcweir // Draw( nX1, nY1, nX2, nY2, SC_UPDATE_CHANGED ); 4371*cdf0e10cSrcweir 4372*cdf0e10cSrcweir // don't draw directly - instead use OutputData to find changed area and invalidate 4373*cdf0e10cSrcweir 4374*cdf0e10cSrcweir SCROW nPosY = nY1; 4375*cdf0e10cSrcweir 4376*cdf0e10cSrcweir ScDocShell* pDocSh = pViewData->GetDocShell(); 4377*cdf0e10cSrcweir ScDocument* pDoc = pDocSh->GetDocument(); 4378*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 4379*cdf0e10cSrcweir 4380*cdf0e10cSrcweir pDoc->ExtendHidden( nX1, nY1, nX2, nY2, nTab ); 4381*cdf0e10cSrcweir 4382*cdf0e10cSrcweir Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich ); 4383*cdf0e10cSrcweir long nMirrorWidth = GetSizePixel().Width(); 4384*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 4385*cdf0e10cSrcweir // unused variable long nLayoutSign = bLayoutRTL ? -1 : 1; 4386*cdf0e10cSrcweir if ( bLayoutRTL ) 4387*cdf0e10cSrcweir { 4388*cdf0e10cSrcweir long nEndPixel = pViewData->GetScrPos( nX2+1, nPosY, eWhich ).X(); 4389*cdf0e10cSrcweir nMirrorWidth = aScrPos.X() - nEndPixel; 4390*cdf0e10cSrcweir aScrPos.X() = nEndPixel + 1; 4391*cdf0e10cSrcweir } 4392*cdf0e10cSrcweir 4393*cdf0e10cSrcweir long nScrX = aScrPos.X(); 4394*cdf0e10cSrcweir long nScrY = aScrPos.Y(); 4395*cdf0e10cSrcweir 4396*cdf0e10cSrcweir double nPPTX = pViewData->GetPPTX(); 4397*cdf0e10cSrcweir double nPPTY = pViewData->GetPPTY(); 4398*cdf0e10cSrcweir 4399*cdf0e10cSrcweir ScTableInfo aTabInfo; 4400*cdf0e10cSrcweir pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nPPTX, nPPTY, sal_False, sal_False ); 4401*cdf0e10cSrcweir 4402*cdf0e10cSrcweir Fraction aZoomX = pViewData->GetZoomX(); 4403*cdf0e10cSrcweir Fraction aZoomY = pViewData->GetZoomY(); 4404*cdf0e10cSrcweir ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab, 4405*cdf0e10cSrcweir nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY, 4406*cdf0e10cSrcweir &aZoomX, &aZoomY ); 4407*cdf0e10cSrcweir aOutputData.SetMirrorWidth( nMirrorWidth ); 4408*cdf0e10cSrcweir 4409*cdf0e10cSrcweir aOutputData.FindChanged(); 4410*cdf0e10cSrcweir 4411*cdf0e10cSrcweir PolyPolygon aChangedPoly( aOutputData.GetChangedArea() ); // logic (PixelToLogic) 4412*cdf0e10cSrcweir if ( aChangedPoly.Count() ) 4413*cdf0e10cSrcweir { 4414*cdf0e10cSrcweir Invalidate( aChangedPoly ); 4415*cdf0e10cSrcweir } 4416*cdf0e10cSrcweir 4417*cdf0e10cSrcweir CheckNeedsRepaint(); // #i90362# used to be called via Draw() - still needed here 4418*cdf0e10cSrcweir } 4419*cdf0e10cSrcweir 4420*cdf0e10cSrcweir void ScGridWindow::UpdateAutoFillMark(sal_Bool bMarked, const ScRange& rMarkRange) 4421*cdf0e10cSrcweir { 4422*cdf0e10cSrcweir if ( bMarked != bAutoMarkVisible || ( bMarked && rMarkRange.aEnd != aAutoMarkPos ) ) 4423*cdf0e10cSrcweir { 4424*cdf0e10cSrcweir HideCursor(); 4425*cdf0e10cSrcweir bAutoMarkVisible = bMarked; 4426*cdf0e10cSrcweir if ( bMarked ) 4427*cdf0e10cSrcweir aAutoMarkPos = rMarkRange.aEnd; 4428*cdf0e10cSrcweir ShowCursor(); 4429*cdf0e10cSrcweir 4430*cdf0e10cSrcweir UpdateAutoFillOverlay(); 4431*cdf0e10cSrcweir } 4432*cdf0e10cSrcweir } 4433*cdf0e10cSrcweir 4434*cdf0e10cSrcweir void ScGridWindow::UpdateListValPos( sal_Bool bVisible, const ScAddress& rPos ) 4435*cdf0e10cSrcweir { 4436*cdf0e10cSrcweir sal_Bool bOldButton = bListValButton; 4437*cdf0e10cSrcweir ScAddress aOldPos = aListValPos; 4438*cdf0e10cSrcweir 4439*cdf0e10cSrcweir bListValButton = bVisible; 4440*cdf0e10cSrcweir aListValPos = rPos; 4441*cdf0e10cSrcweir 4442*cdf0e10cSrcweir if ( bListValButton ) 4443*cdf0e10cSrcweir { 4444*cdf0e10cSrcweir if ( !bOldButton || aListValPos != aOldPos ) 4445*cdf0e10cSrcweir { 4446*cdf0e10cSrcweir // paint area of new button 4447*cdf0e10cSrcweir Invalidate( PixelToLogic( GetListValButtonRect( aListValPos ) ) ); 4448*cdf0e10cSrcweir } 4449*cdf0e10cSrcweir } 4450*cdf0e10cSrcweir if ( bOldButton ) 4451*cdf0e10cSrcweir { 4452*cdf0e10cSrcweir if ( !bListValButton || aListValPos != aOldPos ) 4453*cdf0e10cSrcweir { 4454*cdf0e10cSrcweir // paint area of old button 4455*cdf0e10cSrcweir Invalidate( PixelToLogic( GetListValButtonRect( aOldPos ) ) ); 4456*cdf0e10cSrcweir } 4457*cdf0e10cSrcweir } 4458*cdf0e10cSrcweir } 4459*cdf0e10cSrcweir 4460*cdf0e10cSrcweir void ScGridWindow::HideCursor() 4461*cdf0e10cSrcweir { 4462*cdf0e10cSrcweir ++nCursorHideCount; 4463*cdf0e10cSrcweir if (nCursorHideCount==1) 4464*cdf0e10cSrcweir { 4465*cdf0e10cSrcweir DrawCursor(); 4466*cdf0e10cSrcweir DrawAutoFillMark(); 4467*cdf0e10cSrcweir } 4468*cdf0e10cSrcweir } 4469*cdf0e10cSrcweir 4470*cdf0e10cSrcweir void ScGridWindow::ShowCursor() 4471*cdf0e10cSrcweir { 4472*cdf0e10cSrcweir if (nCursorHideCount==0) 4473*cdf0e10cSrcweir { 4474*cdf0e10cSrcweir DBG_ERROR("zuviel ShowCursor"); 4475*cdf0e10cSrcweir return; 4476*cdf0e10cSrcweir } 4477*cdf0e10cSrcweir 4478*cdf0e10cSrcweir if (nCursorHideCount==1) 4479*cdf0e10cSrcweir { 4480*cdf0e10cSrcweir // #i57745# Draw the cursor before setting the variable, in case the 4481*cdf0e10cSrcweir // GetSizePixel call from drawing causes a repaint (resize handler is called) 4482*cdf0e10cSrcweir DrawAutoFillMark(); 4483*cdf0e10cSrcweir DrawCursor(); 4484*cdf0e10cSrcweir } 4485*cdf0e10cSrcweir 4486*cdf0e10cSrcweir --nCursorHideCount; 4487*cdf0e10cSrcweir } 4488*cdf0e10cSrcweir 4489*cdf0e10cSrcweir void __EXPORT ScGridWindow::GetFocus() 4490*cdf0e10cSrcweir { 4491*cdf0e10cSrcweir ScTabViewShell* pViewShell = pViewData->GetViewShell(); 4492*cdf0e10cSrcweir pViewShell->GotFocus(); 4493*cdf0e10cSrcweir pViewShell->SetFormShellAtTop( sal_False ); // focus in GridWindow -> FormShell no longer on top 4494*cdf0e10cSrcweir 4495*cdf0e10cSrcweir if (pViewShell->HasAccessibilityObjects()) 4496*cdf0e10cSrcweir pViewShell->BroadcastAccessibility(ScAccGridWinFocusGotHint(eWhich, GetAccessible())); 4497*cdf0e10cSrcweir 4498*cdf0e10cSrcweir 4499*cdf0e10cSrcweir if ( !SC_MOD()->IsFormulaMode() ) 4500*cdf0e10cSrcweir { 4501*cdf0e10cSrcweir pViewShell->UpdateInputHandler(); 4502*cdf0e10cSrcweir // StopMarking(); // falls Dialog (Fehler), weil dann kein ButtonUp 4503*cdf0e10cSrcweir // MO: nur wenn nicht im RefInput-Modus 4504*cdf0e10cSrcweir // -> GetFocus/MouseButtonDown-Reihenfolge 4505*cdf0e10cSrcweir // auf dem Mac 4506*cdf0e10cSrcweir } 4507*cdf0e10cSrcweir 4508*cdf0e10cSrcweir Window::GetFocus(); 4509*cdf0e10cSrcweir } 4510*cdf0e10cSrcweir 4511*cdf0e10cSrcweir void __EXPORT ScGridWindow::LoseFocus() 4512*cdf0e10cSrcweir { 4513*cdf0e10cSrcweir ScTabViewShell* pViewShell = pViewData->GetViewShell(); 4514*cdf0e10cSrcweir pViewShell->LostFocus(); 4515*cdf0e10cSrcweir 4516*cdf0e10cSrcweir if (pViewShell->HasAccessibilityObjects()) 4517*cdf0e10cSrcweir pViewShell->BroadcastAccessibility(ScAccGridWinFocusLostHint(eWhich, GetAccessible())); 4518*cdf0e10cSrcweir 4519*cdf0e10cSrcweir Window::LoseFocus(); 4520*cdf0e10cSrcweir } 4521*cdf0e10cSrcweir 4522*cdf0e10cSrcweir Point ScGridWindow::GetMousePosPixel() const { return aCurMousePos; } 4523*cdf0e10cSrcweir 4524*cdf0e10cSrcweir //------------------------------------------------------------------------ 4525*cdf0e10cSrcweir 4526*cdf0e10cSrcweir sal_Bool ScGridWindow::HitRangeFinder( const Point& rMouse, sal_Bool& rCorner, 4527*cdf0e10cSrcweir sal_uInt16* pIndex, SCsCOL* pAddX, SCsROW* pAddY ) 4528*cdf0e10cSrcweir { 4529*cdf0e10cSrcweir sal_Bool bFound = sal_False; 4530*cdf0e10cSrcweir ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() ); 4531*cdf0e10cSrcweir if (pHdl) 4532*cdf0e10cSrcweir { 4533*cdf0e10cSrcweir ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList(); 4534*cdf0e10cSrcweir if ( pRangeFinder && !pRangeFinder->IsHidden() && 4535*cdf0e10cSrcweir pRangeFinder->GetDocName() == pViewData->GetDocShell()->GetTitle() ) 4536*cdf0e10cSrcweir { 4537*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 4538*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 4539*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 4540*cdf0e10cSrcweir long nLayoutSign = bLayoutRTL ? -1 : 1; 4541*cdf0e10cSrcweir 4542*cdf0e10cSrcweir SCsCOL nPosX; 4543*cdf0e10cSrcweir SCsROW nPosY; 4544*cdf0e10cSrcweir pViewData->GetPosFromPixel( rMouse.X(), rMouse.Y(), eWhich, nPosX, nPosY ); 4545*cdf0e10cSrcweir // zusammengefasste (einzeln/Bereich) ??? 4546*cdf0e10cSrcweir ScAddress aAddr( nPosX, nPosY, nTab ); 4547*cdf0e10cSrcweir 4548*cdf0e10cSrcweir // Point aNext = pViewData->GetScrPos( nPosX+1, nPosY+1, eWhich ); 4549*cdf0e10cSrcweir 4550*cdf0e10cSrcweir Point aNext = pViewData->GetScrPos( nPosX, nPosY, eWhich, sal_True ); 4551*cdf0e10cSrcweir long nSizeXPix; 4552*cdf0e10cSrcweir long nSizeYPix; 4553*cdf0e10cSrcweir pViewData->GetMergeSizePixel( nPosX, nPosY, nSizeXPix, nSizeYPix ); 4554*cdf0e10cSrcweir aNext.X() += nSizeXPix * nLayoutSign; 4555*cdf0e10cSrcweir aNext.Y() += nSizeYPix; 4556*cdf0e10cSrcweir 4557*cdf0e10cSrcweir sal_Bool bCornerHor; 4558*cdf0e10cSrcweir if ( bLayoutRTL ) 4559*cdf0e10cSrcweir bCornerHor = ( rMouse.X() >= aNext.X() && rMouse.X() <= aNext.X() + 8 ); 4560*cdf0e10cSrcweir else 4561*cdf0e10cSrcweir bCornerHor = ( rMouse.X() >= aNext.X() - 8 && rMouse.X() <= aNext.X() ); 4562*cdf0e10cSrcweir 4563*cdf0e10cSrcweir sal_Bool bCellCorner = ( bCornerHor && 4564*cdf0e10cSrcweir rMouse.Y() >= aNext.Y() - 8 && rMouse.Y() <= aNext.Y() ); 4565*cdf0e10cSrcweir // corner is hit only if the mouse is within the cell 4566*cdf0e10cSrcweir 4567*cdf0e10cSrcweir sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count(); 4568*cdf0e10cSrcweir for (sal_uInt16 i=nCount; i;) 4569*cdf0e10cSrcweir { 4570*cdf0e10cSrcweir // rueckwaerts suchen, damit der zuletzt gepaintete Rahmen gefunden wird 4571*cdf0e10cSrcweir --i; 4572*cdf0e10cSrcweir ScRangeFindData* pData = pRangeFinder->GetObject(i); 4573*cdf0e10cSrcweir if ( pData && pData->aRef.In(aAddr) ) 4574*cdf0e10cSrcweir { 4575*cdf0e10cSrcweir if (pIndex) *pIndex = i; 4576*cdf0e10cSrcweir if (pAddX) *pAddX = nPosX - pData->aRef.aStart.Col(); 4577*cdf0e10cSrcweir if (pAddY) *pAddY = nPosY - pData->aRef.aStart.Row(); 4578*cdf0e10cSrcweir bFound = sal_True; 4579*cdf0e10cSrcweir rCorner = ( bCellCorner && aAddr == pData->aRef.aEnd ); 4580*cdf0e10cSrcweir break; 4581*cdf0e10cSrcweir } 4582*cdf0e10cSrcweir } 4583*cdf0e10cSrcweir } 4584*cdf0e10cSrcweir } 4585*cdf0e10cSrcweir return bFound; 4586*cdf0e10cSrcweir } 4587*cdf0e10cSrcweir 4588*cdf0e10cSrcweir #define SCE_TOP 1 4589*cdf0e10cSrcweir #define SCE_BOTTOM 2 4590*cdf0e10cSrcweir #define SCE_LEFT 4 4591*cdf0e10cSrcweir #define SCE_RIGHT 8 4592*cdf0e10cSrcweir #define SCE_ALL 15 4593*cdf0e10cSrcweir 4594*cdf0e10cSrcweir void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, sal_uInt16 nEdges ) 4595*cdf0e10cSrcweir { 4596*cdf0e10cSrcweir // der Range ist immer richtigherum 4597*cdf0e10cSrcweir 4598*cdf0e10cSrcweir SCCOL nCol1 = rRange.aStart.Col(); 4599*cdf0e10cSrcweir SCROW nRow1 = rRange.aStart.Row(); 4600*cdf0e10cSrcweir SCTAB nTab1 = rRange.aStart.Tab(); 4601*cdf0e10cSrcweir SCCOL nCol2 = rRange.aEnd.Col(); 4602*cdf0e10cSrcweir SCROW nRow2 = rRange.aEnd.Row(); 4603*cdf0e10cSrcweir SCTAB nTab2 = rRange.aEnd.Tab(); 4604*cdf0e10cSrcweir sal_Bool bHiddenEdge = sal_False; 4605*cdf0e10cSrcweir SCROW nTmp; 4606*cdf0e10cSrcweir 4607*cdf0e10cSrcweir ScDocument* pDoc = pDocSh->GetDocument(); 4608*cdf0e10cSrcweir while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab1) ) 4609*cdf0e10cSrcweir { 4610*cdf0e10cSrcweir --nCol1; 4611*cdf0e10cSrcweir bHiddenEdge = sal_True; 4612*cdf0e10cSrcweir } 4613*cdf0e10cSrcweir while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab1) ) 4614*cdf0e10cSrcweir { 4615*cdf0e10cSrcweir ++nCol2; 4616*cdf0e10cSrcweir bHiddenEdge = sal_True; 4617*cdf0e10cSrcweir } 4618*cdf0e10cSrcweir nTmp = pDoc->FirstVisibleRow(0, nRow1, nTab1); 4619*cdf0e10cSrcweir if (!ValidRow(nTmp)) 4620*cdf0e10cSrcweir nTmp = 0; 4621*cdf0e10cSrcweir if (nTmp < nRow1) 4622*cdf0e10cSrcweir { 4623*cdf0e10cSrcweir nRow1 = nTmp; 4624*cdf0e10cSrcweir bHiddenEdge = sal_True; 4625*cdf0e10cSrcweir } 4626*cdf0e10cSrcweir nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab1); 4627*cdf0e10cSrcweir if (!ValidRow(nTmp)) 4628*cdf0e10cSrcweir nTmp = MAXROW; 4629*cdf0e10cSrcweir if (nTmp > nRow2) 4630*cdf0e10cSrcweir { 4631*cdf0e10cSrcweir nRow2 = nTmp; 4632*cdf0e10cSrcweir bHiddenEdge = sal_True; 4633*cdf0e10cSrcweir } 4634*cdf0e10cSrcweir 4635*cdf0e10cSrcweir if ( nCol2 > nCol1 + 1 && nRow2 > nRow1 + 1 && !bHiddenEdge ) 4636*cdf0e10cSrcweir { 4637*cdf0e10cSrcweir // nur an den Raendern entlang 4638*cdf0e10cSrcweir // (die Ecken werden evtl. zweimal getroffen) 4639*cdf0e10cSrcweir 4640*cdf0e10cSrcweir if ( nEdges & SCE_TOP ) 4641*cdf0e10cSrcweir pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol2, nRow1, nTab2, PAINT_MARKS ); 4642*cdf0e10cSrcweir if ( nEdges & SCE_LEFT ) 4643*cdf0e10cSrcweir pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol1, nRow2, nTab2, PAINT_MARKS ); 4644*cdf0e10cSrcweir if ( nEdges & SCE_RIGHT ) 4645*cdf0e10cSrcweir pDocSh->PostPaint( nCol2, nRow1, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS ); 4646*cdf0e10cSrcweir if ( nEdges & SCE_BOTTOM ) 4647*cdf0e10cSrcweir pDocSh->PostPaint( nCol1, nRow2, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS ); 4648*cdf0e10cSrcweir } 4649*cdf0e10cSrcweir else // everything in one call 4650*cdf0e10cSrcweir pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS ); 4651*cdf0e10cSrcweir } 4652*cdf0e10cSrcweir 4653*cdf0e10cSrcweir void lcl_PaintRefChanged( ScDocShell* pDocSh, const ScRange& rOldUn, const ScRange& rNewUn ) 4654*cdf0e10cSrcweir { 4655*cdf0e10cSrcweir // Repaint fuer die Teile des Rahmens in Old, die bei New nicht mehr da sind 4656*cdf0e10cSrcweir 4657*cdf0e10cSrcweir ScRange aOld = rOldUn; 4658*cdf0e10cSrcweir ScRange aNew = rNewUn; 4659*cdf0e10cSrcweir aOld.Justify(); 4660*cdf0e10cSrcweir aNew.Justify(); 4661*cdf0e10cSrcweir 4662*cdf0e10cSrcweir if ( aOld.aStart == aOld.aEnd ) //! Tab ignorieren? 4663*cdf0e10cSrcweir pDocSh->GetDocument()->ExtendMerge(aOld); 4664*cdf0e10cSrcweir if ( aNew.aStart == aNew.aEnd ) //! Tab ignorieren? 4665*cdf0e10cSrcweir pDocSh->GetDocument()->ExtendMerge(aNew); 4666*cdf0e10cSrcweir 4667*cdf0e10cSrcweir SCCOL nOldCol1 = aOld.aStart.Col(); 4668*cdf0e10cSrcweir SCROW nOldRow1 = aOld.aStart.Row(); 4669*cdf0e10cSrcweir SCCOL nOldCol2 = aOld.aEnd.Col(); 4670*cdf0e10cSrcweir SCROW nOldRow2 = aOld.aEnd.Row(); 4671*cdf0e10cSrcweir SCCOL nNewCol1 = aNew.aStart.Col(); 4672*cdf0e10cSrcweir SCROW nNewRow1 = aNew.aStart.Row(); 4673*cdf0e10cSrcweir SCCOL nNewCol2 = aNew.aEnd.Col(); 4674*cdf0e10cSrcweir SCROW nNewRow2 = aNew.aEnd.Row(); 4675*cdf0e10cSrcweir SCTAB nTab1 = aOld.aStart.Tab(); // Tab aendert sich nicht 4676*cdf0e10cSrcweir SCTAB nTab2 = aOld.aEnd.Tab(); 4677*cdf0e10cSrcweir 4678*cdf0e10cSrcweir if ( nNewRow2 < nOldRow1 || nNewRow1 > nOldRow2 || 4679*cdf0e10cSrcweir nNewCol2 < nOldCol1 || nNewCol1 > nOldCol2 || 4680*cdf0e10cSrcweir ( nNewCol1 != nOldCol1 && nNewRow1 != nOldRow1 && 4681*cdf0e10cSrcweir nNewCol2 != nOldCol2 && nNewRow2 != nOldRow2 ) ) 4682*cdf0e10cSrcweir { 4683*cdf0e10cSrcweir // komplett weggeschoben oder alle Seiten veraendert 4684*cdf0e10cSrcweir // (Abfrage <= statt < geht schief bei einzelnen Zeilen/Spalten) 4685*cdf0e10cSrcweir 4686*cdf0e10cSrcweir lcl_PaintOneRange( pDocSh, aOld, SCE_ALL ); 4687*cdf0e10cSrcweir } 4688*cdf0e10cSrcweir else // alle vier Kanten einzeln testen 4689*cdf0e10cSrcweir { 4690*cdf0e10cSrcweir // oberer Teil 4691*cdf0e10cSrcweir if ( nNewRow1 < nOldRow1 ) // nur obere Linie loeschen 4692*cdf0e10cSrcweir lcl_PaintOneRange( pDocSh, ScRange( 4693*cdf0e10cSrcweir nOldCol1, nOldRow1, nTab1, nOldCol2, nOldRow1, nTab2 ), SCE_ALL ); 4694*cdf0e10cSrcweir else if ( nNewRow1 > nOldRow1 ) // den Teil, der oben wegkommt 4695*cdf0e10cSrcweir lcl_PaintOneRange( pDocSh, ScRange( 4696*cdf0e10cSrcweir nOldCol1, nOldRow1, nTab1, nOldCol2, nNewRow1-1, nTab2 ), 4697*cdf0e10cSrcweir SCE_ALL &~ SCE_BOTTOM ); 4698*cdf0e10cSrcweir 4699*cdf0e10cSrcweir // unterer Teil 4700*cdf0e10cSrcweir if ( nNewRow2 > nOldRow2 ) // nur untere Linie loeschen 4701*cdf0e10cSrcweir lcl_PaintOneRange( pDocSh, ScRange( 4702*cdf0e10cSrcweir nOldCol1, nOldRow2, nTab1, nOldCol2, nOldRow2, nTab2 ), SCE_ALL ); 4703*cdf0e10cSrcweir else if ( nNewRow2 < nOldRow2 ) // den Teil, der unten wegkommt 4704*cdf0e10cSrcweir lcl_PaintOneRange( pDocSh, ScRange( 4705*cdf0e10cSrcweir nOldCol1, nNewRow2+1, nTab1, nOldCol2, nOldRow2, nTab2 ), 4706*cdf0e10cSrcweir SCE_ALL &~ SCE_TOP ); 4707*cdf0e10cSrcweir 4708*cdf0e10cSrcweir // linker Teil 4709*cdf0e10cSrcweir if ( nNewCol1 < nOldCol1 ) // nur linke Linie loeschen 4710*cdf0e10cSrcweir lcl_PaintOneRange( pDocSh, ScRange( 4711*cdf0e10cSrcweir nOldCol1, nOldRow1, nTab1, nOldCol1, nOldRow2, nTab2 ), SCE_ALL ); 4712*cdf0e10cSrcweir else if ( nNewCol1 > nOldCol1 ) // den Teil, der links wegkommt 4713*cdf0e10cSrcweir lcl_PaintOneRange( pDocSh, ScRange( 4714*cdf0e10cSrcweir nOldCol1, nOldRow1, nTab1, nNewCol1-1, nOldRow2, nTab2 ), 4715*cdf0e10cSrcweir SCE_ALL &~ SCE_RIGHT ); 4716*cdf0e10cSrcweir 4717*cdf0e10cSrcweir // rechter Teil 4718*cdf0e10cSrcweir if ( nNewCol2 > nOldCol2 ) // nur rechte Linie loeschen 4719*cdf0e10cSrcweir lcl_PaintOneRange( pDocSh, ScRange( 4720*cdf0e10cSrcweir nOldCol2, nOldRow1, nTab1, nOldCol2, nOldRow2, nTab2 ), SCE_ALL ); 4721*cdf0e10cSrcweir else if ( nNewCol2 < nOldCol2 ) // den Teil, der rechts wegkommt 4722*cdf0e10cSrcweir lcl_PaintOneRange( pDocSh, ScRange( 4723*cdf0e10cSrcweir nNewCol2+1, nOldRow1, nTab1, nOldCol2, nOldRow2, nTab2 ), 4724*cdf0e10cSrcweir SCE_ALL &~ SCE_LEFT ); 4725*cdf0e10cSrcweir } 4726*cdf0e10cSrcweir } 4727*cdf0e10cSrcweir 4728*cdf0e10cSrcweir void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, sal_Bool bUp ) 4729*cdf0e10cSrcweir { 4730*cdf0e10cSrcweir ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() ); 4731*cdf0e10cSrcweir if (!pHdl) 4732*cdf0e10cSrcweir return; 4733*cdf0e10cSrcweir ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList(); 4734*cdf0e10cSrcweir if (!pRangeFinder || nRFIndex >= pRangeFinder->Count()) 4735*cdf0e10cSrcweir return; 4736*cdf0e10cSrcweir ScRangeFindData* pData = pRangeFinder->GetObject( nRFIndex ); 4737*cdf0e10cSrcweir if (!pData) 4738*cdf0e10cSrcweir return; 4739*cdf0e10cSrcweir 4740*cdf0e10cSrcweir // Mauszeiger 4741*cdf0e10cSrcweir 4742*cdf0e10cSrcweir if (bRFSize) 4743*cdf0e10cSrcweir SetPointer( Pointer( POINTER_CROSS ) ); 4744*cdf0e10cSrcweir else 4745*cdf0e10cSrcweir SetPointer( Pointer( POINTER_HAND ) ); 4746*cdf0e10cSrcweir 4747*cdf0e10cSrcweir // Scrolling 4748*cdf0e10cSrcweir 4749*cdf0e10cSrcweir sal_Bool bTimer = sal_False; 4750*cdf0e10cSrcweir Point aPos = rMEvt.GetPosPixel(); 4751*cdf0e10cSrcweir SCsCOL nDx = 0; 4752*cdf0e10cSrcweir SCsROW nDy = 0; 4753*cdf0e10cSrcweir if ( aPos.X() < 0 ) nDx = -1; 4754*cdf0e10cSrcweir if ( aPos.Y() < 0 ) nDy = -1; 4755*cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 4756*cdf0e10cSrcweir if ( aPos.X() >= aSize.Width() ) 4757*cdf0e10cSrcweir nDx = 1; 4758*cdf0e10cSrcweir if ( aPos.Y() >= aSize.Height() ) 4759*cdf0e10cSrcweir nDy = 1; 4760*cdf0e10cSrcweir if ( nDx != 0 || nDy != 0 ) 4761*cdf0e10cSrcweir { 4762*cdf0e10cSrcweir if ( nDx != 0) pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) ); 4763*cdf0e10cSrcweir if ( nDy != 0 ) pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) ); 4764*cdf0e10cSrcweir bTimer = sal_True; 4765*cdf0e10cSrcweir } 4766*cdf0e10cSrcweir 4767*cdf0e10cSrcweir // Umschalten bei Fixierung (damit Scrolling funktioniert) 4768*cdf0e10cSrcweir 4769*cdf0e10cSrcweir if ( eWhich == pViewData->GetActivePart() ) //?? 4770*cdf0e10cSrcweir { 4771*cdf0e10cSrcweir if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ) 4772*cdf0e10cSrcweir if ( nDx > 0 ) 4773*cdf0e10cSrcweir { 4774*cdf0e10cSrcweir if ( eWhich == SC_SPLIT_TOPLEFT ) 4775*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT ); 4776*cdf0e10cSrcweir else if ( eWhich == SC_SPLIT_BOTTOMLEFT ) 4777*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ); 4778*cdf0e10cSrcweir } 4779*cdf0e10cSrcweir 4780*cdf0e10cSrcweir if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX ) 4781*cdf0e10cSrcweir if ( nDy > 0 ) 4782*cdf0e10cSrcweir { 4783*cdf0e10cSrcweir if ( eWhich == SC_SPLIT_TOPLEFT ) 4784*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT ); 4785*cdf0e10cSrcweir else if ( eWhich == SC_SPLIT_TOPRIGHT ) 4786*cdf0e10cSrcweir pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ); 4787*cdf0e10cSrcweir } 4788*cdf0e10cSrcweir } 4789*cdf0e10cSrcweir 4790*cdf0e10cSrcweir // Verschieben 4791*cdf0e10cSrcweir 4792*cdf0e10cSrcweir SCsCOL nPosX; 4793*cdf0e10cSrcweir SCsROW nPosY; 4794*cdf0e10cSrcweir pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); 4795*cdf0e10cSrcweir 4796*cdf0e10cSrcweir ScRange aOld = pData->aRef; 4797*cdf0e10cSrcweir ScRange aNew = aOld; 4798*cdf0e10cSrcweir if ( bRFSize ) 4799*cdf0e10cSrcweir { 4800*cdf0e10cSrcweir aNew.aEnd.SetCol((SCCOL)nPosX); 4801*cdf0e10cSrcweir aNew.aEnd.SetRow((SCROW)nPosY); 4802*cdf0e10cSrcweir } 4803*cdf0e10cSrcweir else 4804*cdf0e10cSrcweir { 4805*cdf0e10cSrcweir long nStartX = nPosX - nRFAddX; 4806*cdf0e10cSrcweir if ( nStartX < 0 ) nStartX = 0; 4807*cdf0e10cSrcweir long nStartY = nPosY - nRFAddY; 4808*cdf0e10cSrcweir if ( nStartY < 0 ) nStartY = 0; 4809*cdf0e10cSrcweir long nEndX = nStartX + aOld.aEnd.Col() - aOld.aStart.Col(); 4810*cdf0e10cSrcweir if ( nEndX > MAXCOL ) 4811*cdf0e10cSrcweir { 4812*cdf0e10cSrcweir nStartX -= ( nEndX - MAXROW ); 4813*cdf0e10cSrcweir nEndX = MAXCOL; 4814*cdf0e10cSrcweir } 4815*cdf0e10cSrcweir long nEndY = nStartY + aOld.aEnd.Row() - aOld.aStart.Row(); 4816*cdf0e10cSrcweir if ( nEndY > MAXROW ) 4817*cdf0e10cSrcweir { 4818*cdf0e10cSrcweir nStartY -= ( nEndY - MAXROW ); 4819*cdf0e10cSrcweir nEndY = MAXROW; 4820*cdf0e10cSrcweir } 4821*cdf0e10cSrcweir 4822*cdf0e10cSrcweir aNew.aStart.SetCol((SCCOL)nStartX); 4823*cdf0e10cSrcweir aNew.aStart.SetRow((SCROW)nStartY); 4824*cdf0e10cSrcweir aNew.aEnd.SetCol((SCCOL)nEndX); 4825*cdf0e10cSrcweir aNew.aEnd.SetRow((SCROW)nEndY); 4826*cdf0e10cSrcweir } 4827*cdf0e10cSrcweir 4828*cdf0e10cSrcweir if ( bUp ) 4829*cdf0e10cSrcweir aNew.Justify(); // beim ButtonUp wieder richtigherum 4830*cdf0e10cSrcweir 4831*cdf0e10cSrcweir if ( aNew != aOld ) 4832*cdf0e10cSrcweir { 4833*cdf0e10cSrcweir pHdl->UpdateRange( nRFIndex, aNew ); 4834*cdf0e10cSrcweir 4835*cdf0e10cSrcweir ScDocShell* pDocSh = pViewData->GetDocShell(); 4836*cdf0e10cSrcweir 4837*cdf0e10cSrcweir // nur das neuzeichnen, was sich veraendert hat... 4838*cdf0e10cSrcweir lcl_PaintRefChanged( pDocSh, aOld, aNew ); 4839*cdf0e10cSrcweir 4840*cdf0e10cSrcweir // neuen Rahmen nur drueberzeichnen (synchron) 4841*cdf0e10cSrcweir pDocSh->Broadcast( ScIndexHint( SC_HINT_SHOWRANGEFINDER, nRFIndex ) ); 4842*cdf0e10cSrcweir 4843*cdf0e10cSrcweir Update(); // was man bewegt, will man auch sofort sehen 4844*cdf0e10cSrcweir } 4845*cdf0e10cSrcweir 4846*cdf0e10cSrcweir // Timer fuer Scrolling 4847*cdf0e10cSrcweir 4848*cdf0e10cSrcweir if (bTimer) 4849*cdf0e10cSrcweir pViewData->GetView()->SetTimer( this, rMEvt ); // Event wiederholen 4850*cdf0e10cSrcweir else 4851*cdf0e10cSrcweir pViewData->GetView()->ResetTimer(); 4852*cdf0e10cSrcweir } 4853*cdf0e10cSrcweir 4854*cdf0e10cSrcweir //------------------------------------------------------------------------ 4855*cdf0e10cSrcweir 4856*cdf0e10cSrcweir sal_Bool ScGridWindow::GetEditUrl( const Point& rPos, 4857*cdf0e10cSrcweir String* pName, String* pUrl, String* pTarget ) 4858*cdf0e10cSrcweir { 4859*cdf0e10cSrcweir return GetEditUrlOrError( sal_False, rPos, pName, pUrl, pTarget ); 4860*cdf0e10cSrcweir } 4861*cdf0e10cSrcweir 4862*cdf0e10cSrcweir sal_Bool ScGridWindow::GetEditUrlOrError( sal_Bool bSpellErr, const Point& rPos, 4863*cdf0e10cSrcweir String* pName, String* pUrl, String* pTarget ) 4864*cdf0e10cSrcweir { 4865*cdf0e10cSrcweir //! nPosX/Y mit uebergeben? 4866*cdf0e10cSrcweir SCsCOL nPosX; 4867*cdf0e10cSrcweir SCsROW nPosY; 4868*cdf0e10cSrcweir pViewData->GetPosFromPixel( rPos.X(), rPos.Y(), eWhich, nPosX, nPosY ); 4869*cdf0e10cSrcweir 4870*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 4871*cdf0e10cSrcweir ScDocShell* pDocSh = pViewData->GetDocShell(); 4872*cdf0e10cSrcweir ScDocument* pDoc = pDocSh->GetDocument(); 4873*cdf0e10cSrcweir ScBaseCell* pCell = NULL; 4874*cdf0e10cSrcweir 4875*cdf0e10cSrcweir sal_Bool bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell ); 4876*cdf0e10cSrcweir if( !bFound ) 4877*cdf0e10cSrcweir return sal_False; 4878*cdf0e10cSrcweir 4879*cdf0e10cSrcweir ScHideTextCursor aHideCursor( pViewData, eWhich ); // before GetEditArea (MapMode is changed) 4880*cdf0e10cSrcweir 4881*cdf0e10cSrcweir const ScPatternAttr* pPattern = pDoc->GetPattern( nPosX, nPosY, nTab ); 4882*cdf0e10cSrcweir // bForceToTop = sal_False, use the cell's real position 4883*cdf0e10cSrcweir Rectangle aEditRect = pViewData->GetEditArea( eWhich, nPosX, nPosY, this, pPattern, sal_False ); 4884*cdf0e10cSrcweir if (rPos.Y() < aEditRect.Top()) 4885*cdf0e10cSrcweir return sal_False; 4886*cdf0e10cSrcweir 4887*cdf0e10cSrcweir // vertikal kann (noch) nicht angeklickt werden: 4888*cdf0e10cSrcweir 4889*cdf0e10cSrcweir if (pPattern->GetCellOrientation() != SVX_ORIENTATION_STANDARD) 4890*cdf0e10cSrcweir return sal_False; 4891*cdf0e10cSrcweir 4892*cdf0e10cSrcweir sal_Bool bBreak = ((SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue() || 4893*cdf0e10cSrcweir ((SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern-> 4894*cdf0e10cSrcweir GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK); 4895*cdf0e10cSrcweir SvxCellHorJustify eHorJust = (SvxCellHorJustify)((SvxHorJustifyItem&)pPattern-> 4896*cdf0e10cSrcweir GetItem(ATTR_HOR_JUSTIFY)).GetValue(); 4897*cdf0e10cSrcweir 4898*cdf0e10cSrcweir // EditEngine 4899*cdf0e10cSrcweir 4900*cdf0e10cSrcweir ScFieldEditEngine aEngine( pDoc->GetEditPool() ); 4901*cdf0e10cSrcweir ScSizeDeviceProvider aProv(pDocSh); 4902*cdf0e10cSrcweir aEngine.SetRefDevice( aProv.GetDevice() ); 4903*cdf0e10cSrcweir aEngine.SetRefMapMode( MAP_100TH_MM ); 4904*cdf0e10cSrcweir SfxItemSet aDefault( aEngine.GetEmptyItemSet() ); 4905*cdf0e10cSrcweir pPattern->FillEditItemSet( &aDefault ); 4906*cdf0e10cSrcweir SvxAdjust eSvxAdjust = SVX_ADJUST_LEFT; 4907*cdf0e10cSrcweir switch (eHorJust) 4908*cdf0e10cSrcweir { 4909*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_LEFT: 4910*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_REPEAT: // nicht implementiert 4911*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_STANDARD: // always Text if an EditCell type 4912*cdf0e10cSrcweir eSvxAdjust = SVX_ADJUST_LEFT; 4913*cdf0e10cSrcweir break; 4914*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_RIGHT: 4915*cdf0e10cSrcweir eSvxAdjust = SVX_ADJUST_RIGHT; 4916*cdf0e10cSrcweir break; 4917*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_CENTER: 4918*cdf0e10cSrcweir eSvxAdjust = SVX_ADJUST_CENTER; 4919*cdf0e10cSrcweir break; 4920*cdf0e10cSrcweir case SVX_HOR_JUSTIFY_BLOCK: 4921*cdf0e10cSrcweir eSvxAdjust = SVX_ADJUST_BLOCK; 4922*cdf0e10cSrcweir break; 4923*cdf0e10cSrcweir } 4924*cdf0e10cSrcweir aDefault.Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) ); 4925*cdf0e10cSrcweir aEngine.SetDefaults( aDefault ); 4926*cdf0e10cSrcweir if (bSpellErr) 4927*cdf0e10cSrcweir aEngine.SetControlWord( aEngine.GetControlWord() | EE_CNTRL_ONLINESPELLING ); 4928*cdf0e10cSrcweir 4929*cdf0e10cSrcweir MapMode aEditMode = pViewData->GetLogicMode(eWhich); // ohne Drawing-Skalierung 4930*cdf0e10cSrcweir Rectangle aLogicEdit = PixelToLogic( aEditRect, aEditMode ); 4931*cdf0e10cSrcweir long nThisColLogic = aLogicEdit.Right() - aLogicEdit.Left() + 1; 4932*cdf0e10cSrcweir Size aPaperSize = Size( 1000000, 1000000 ); 4933*cdf0e10cSrcweir if(pCell->GetCellType() == CELLTYPE_FORMULA) 4934*cdf0e10cSrcweir { 4935*cdf0e10cSrcweir long nSizeX = 0; 4936*cdf0e10cSrcweir long nSizeY = 0; 4937*cdf0e10cSrcweir pViewData->GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY ); 4938*cdf0e10cSrcweir aPaperSize = Size(nSizeX, nSizeY ); 4939*cdf0e10cSrcweir aPaperSize = PixelToLogic(aPaperSize); 4940*cdf0e10cSrcweir } 4941*cdf0e10cSrcweir 4942*cdf0e10cSrcweir if (bBreak) 4943*cdf0e10cSrcweir aPaperSize.Width() = nThisColLogic; 4944*cdf0e10cSrcweir aEngine.SetPaperSize( aPaperSize ); 4945*cdf0e10cSrcweir 4946*cdf0e10cSrcweir ::std::auto_ptr< EditTextObject > pTextObj; 4947*cdf0e10cSrcweir const EditTextObject* pData; 4948*cdf0e10cSrcweir if(pCell->GetCellType() == CELLTYPE_EDIT) 4949*cdf0e10cSrcweir { 4950*cdf0e10cSrcweir ((ScEditCell*)pCell)->GetData(pData); 4951*cdf0e10cSrcweir if (pData) 4952*cdf0e10cSrcweir aEngine.SetText(*pData); 4953*cdf0e10cSrcweir } 4954*cdf0e10cSrcweir else // HyperLink Formula cell 4955*cdf0e10cSrcweir { 4956*cdf0e10cSrcweir pTextObj.reset((static_cast<ScFormulaCell*>(pCell))->CreateURLObject()); 4957*cdf0e10cSrcweir if (pTextObj.get()) 4958*cdf0e10cSrcweir aEngine.SetText(*pTextObj); 4959*cdf0e10cSrcweir } 4960*cdf0e10cSrcweir 4961*cdf0e10cSrcweir long nStartX = aLogicEdit.Left(); 4962*cdf0e10cSrcweir 4963*cdf0e10cSrcweir long nTextWidth = aEngine.CalcTextWidth(); 4964*cdf0e10cSrcweir long nTextHeight = aEngine.GetTextHeight(); 4965*cdf0e10cSrcweir if ( nTextWidth < nThisColLogic ) 4966*cdf0e10cSrcweir { 4967*cdf0e10cSrcweir if (eHorJust == SVX_HOR_JUSTIFY_RIGHT) 4968*cdf0e10cSrcweir nStartX += nThisColLogic - nTextWidth; 4969*cdf0e10cSrcweir else if (eHorJust == SVX_HOR_JUSTIFY_CENTER) 4970*cdf0e10cSrcweir nStartX += (nThisColLogic - nTextWidth) / 2; 4971*cdf0e10cSrcweir } 4972*cdf0e10cSrcweir 4973*cdf0e10cSrcweir aLogicEdit.Left() = nStartX; 4974*cdf0e10cSrcweir if (!bBreak) 4975*cdf0e10cSrcweir aLogicEdit.Right() = nStartX + nTextWidth; 4976*cdf0e10cSrcweir 4977*cdf0e10cSrcweir // There is one glitch when dealing with a hyperlink cell and 4978*cdf0e10cSrcweir // the cell content is NUMERIC. This defaults to right aligned and 4979*cdf0e10cSrcweir // we need to adjust accordingly. 4980*cdf0e10cSrcweir if(pCell->GetCellType() == CELLTYPE_FORMULA && 4981*cdf0e10cSrcweir static_cast<ScFormulaCell*>(pCell)->IsValue() && 4982*cdf0e10cSrcweir eHorJust == SVX_HOR_JUSTIFY_STANDARD) 4983*cdf0e10cSrcweir { 4984*cdf0e10cSrcweir aLogicEdit.Right() = aLogicEdit.Left() + nThisColLogic - 1; 4985*cdf0e10cSrcweir aLogicEdit.Left() = aLogicEdit.Right() - nTextWidth; 4986*cdf0e10cSrcweir } 4987*cdf0e10cSrcweir aLogicEdit.Bottom() = aLogicEdit.Top() + nTextHeight; 4988*cdf0e10cSrcweir 4989*cdf0e10cSrcweir 4990*cdf0e10cSrcweir Point aLogicClick = PixelToLogic(rPos,aEditMode); 4991*cdf0e10cSrcweir if ( aLogicEdit.IsInside(aLogicClick) ) 4992*cdf0e10cSrcweir { 4993*cdf0e10cSrcweir // aEngine.SetUpdateMode(sal_False); 4994*cdf0e10cSrcweir EditView aTempView( &aEngine, this ); 4995*cdf0e10cSrcweir aTempView.SetOutputArea( aLogicEdit ); 4996*cdf0e10cSrcweir 4997*cdf0e10cSrcweir sal_Bool bRet = sal_False; 4998*cdf0e10cSrcweir MapMode aOld = GetMapMode(); 4999*cdf0e10cSrcweir SetMapMode(aEditMode); // kein return mehr 5000*cdf0e10cSrcweir 5001*cdf0e10cSrcweir if (bSpellErr) // Spelling-Fehler suchen 5002*cdf0e10cSrcweir { 5003*cdf0e10cSrcweir bRet = aTempView.IsWrongSpelledWordAtPos( rPos ); 5004*cdf0e10cSrcweir if ( bRet ) 5005*cdf0e10cSrcweir pViewData->GetView()->SetCursor( nPosX, nPosY ); // Cursor setzen 5006*cdf0e10cSrcweir } 5007*cdf0e10cSrcweir else // URL suchen 5008*cdf0e10cSrcweir { 5009*cdf0e10cSrcweir const SvxFieldItem* pFieldItem = aTempView.GetFieldUnderMousePointer(); 5010*cdf0e10cSrcweir 5011*cdf0e10cSrcweir if (pFieldItem) 5012*cdf0e10cSrcweir { 5013*cdf0e10cSrcweir const SvxFieldData* pField = pFieldItem->GetField(); 5014*cdf0e10cSrcweir if ( pField && pField->ISA(SvxURLField) ) 5015*cdf0e10cSrcweir { 5016*cdf0e10cSrcweir if ( pName || pUrl || pTarget ) 5017*cdf0e10cSrcweir { 5018*cdf0e10cSrcweir const SvxURLField* pURLField = (const SvxURLField*)pField; 5019*cdf0e10cSrcweir if (pName) 5020*cdf0e10cSrcweir *pName = pURLField->GetRepresentation(); 5021*cdf0e10cSrcweir if (pUrl) 5022*cdf0e10cSrcweir *pUrl = pURLField->GetURL(); 5023*cdf0e10cSrcweir if (pTarget) 5024*cdf0e10cSrcweir *pTarget = pURLField->GetTargetFrame(); 5025*cdf0e10cSrcweir } 5026*cdf0e10cSrcweir bRet = sal_True; 5027*cdf0e10cSrcweir } 5028*cdf0e10cSrcweir } 5029*cdf0e10cSrcweir } 5030*cdf0e10cSrcweir 5031*cdf0e10cSrcweir SetMapMode(aOld); 5032*cdf0e10cSrcweir 5033*cdf0e10cSrcweir // text cursor is restored in ScHideTextCursor dtor 5034*cdf0e10cSrcweir 5035*cdf0e10cSrcweir return bRet; 5036*cdf0e10cSrcweir } 5037*cdf0e10cSrcweir return sal_False; 5038*cdf0e10cSrcweir } 5039*cdf0e10cSrcweir 5040*cdf0e10cSrcweir sal_Bool ScGridWindow::HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange ) 5041*cdf0e10cSrcweir { 5042*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 5043*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 5044*cdf0e10cSrcweir SCTAB nTabCount = pDoc->GetTableCount(); 5045*cdf0e10cSrcweir if ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) ) 5046*cdf0e10cSrcweir { 5047*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 5048*cdf0e10cSrcweir 5049*cdf0e10cSrcweir Size aButSize = pViewData->GetScenButSize(); 5050*cdf0e10cSrcweir long nBWidth = aButSize.Width(); 5051*cdf0e10cSrcweir if (!nBWidth) 5052*cdf0e10cSrcweir return sal_False; // noch kein Button gezeichnet -> da ist auch keiner 5053*cdf0e10cSrcweir long nBHeight = aButSize.Height(); 5054*cdf0e10cSrcweir long nHSpace = (long)( SC_SCENARIO_HSPACE * pViewData->GetPPTX() ); 5055*cdf0e10cSrcweir 5056*cdf0e10cSrcweir //! Ranges an der Table cachen!!!! 5057*cdf0e10cSrcweir 5058*cdf0e10cSrcweir ScMarkData aMarks; 5059*cdf0e10cSrcweir for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++) 5060*cdf0e10cSrcweir pDoc->MarkScenario( i, nTab, aMarks, sal_False, SC_SCENARIO_SHOWFRAME ); 5061*cdf0e10cSrcweir ScRangeList aRanges; 5062*cdf0e10cSrcweir aMarks.FillRangeListWithMarks( &aRanges, sal_False ); 5063*cdf0e10cSrcweir 5064*cdf0e10cSrcweir 5065*cdf0e10cSrcweir sal_uLong nRangeCount = aRanges.Count(); 5066*cdf0e10cSrcweir for (sal_uLong j=0; j<nRangeCount; j++) 5067*cdf0e10cSrcweir { 5068*cdf0e10cSrcweir ScRange aRange = *aRanges.GetObject(j); 5069*cdf0e10cSrcweir // Szenario-Rahmen immer dann auf zusammengefasste Zellen erweitern, wenn 5070*cdf0e10cSrcweir // dadurch keine neuen nicht-ueberdeckten Zellen mit umrandet werden 5071*cdf0e10cSrcweir pDoc->ExtendTotalMerge( aRange ); 5072*cdf0e10cSrcweir 5073*cdf0e10cSrcweir sal_Bool bTextBelow = ( aRange.aStart.Row() == 0 ); 5074*cdf0e10cSrcweir 5075*cdf0e10cSrcweir Point aButtonPos; 5076*cdf0e10cSrcweir if ( bTextBelow ) 5077*cdf0e10cSrcweir { 5078*cdf0e10cSrcweir aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, 5079*cdf0e10cSrcweir eWhich, sal_True ); 5080*cdf0e10cSrcweir } 5081*cdf0e10cSrcweir else 5082*cdf0e10cSrcweir { 5083*cdf0e10cSrcweir aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aStart.Row(), 5084*cdf0e10cSrcweir eWhich, sal_True ); 5085*cdf0e10cSrcweir aButtonPos.Y() -= nBHeight; 5086*cdf0e10cSrcweir } 5087*cdf0e10cSrcweir if ( bLayoutRTL ) 5088*cdf0e10cSrcweir aButtonPos.X() -= nHSpace - 1; 5089*cdf0e10cSrcweir else 5090*cdf0e10cSrcweir aButtonPos.X() -= nBWidth - nHSpace; // same for top or bottom 5091*cdf0e10cSrcweir 5092*cdf0e10cSrcweir Rectangle aButRect( aButtonPos, Size(nBWidth,nBHeight) ); 5093*cdf0e10cSrcweir if ( aButRect.IsInside( rPosPixel ) ) 5094*cdf0e10cSrcweir { 5095*cdf0e10cSrcweir rScenRange = aRange; 5096*cdf0e10cSrcweir return sal_True; 5097*cdf0e10cSrcweir } 5098*cdf0e10cSrcweir } 5099*cdf0e10cSrcweir } 5100*cdf0e10cSrcweir 5101*cdf0e10cSrcweir return sal_False; 5102*cdf0e10cSrcweir } 5103*cdf0e10cSrcweir 5104*cdf0e10cSrcweir void ScGridWindow::UpdateVisibleRange() 5105*cdf0e10cSrcweir { 5106*cdf0e10cSrcweir // #163911# Update the visible range outside of paint (called when switching sheets). 5107*cdf0e10cSrcweir // Use the same logic here as in ScGridWindow::Draw. 5108*cdf0e10cSrcweir 5109*cdf0e10cSrcweir SCCOL nPosX = pViewData->GetPosX( eHWhich ); 5110*cdf0e10cSrcweir SCROW nPosY = pViewData->GetPosY( eVWhich ); 5111*cdf0e10cSrcweir 5112*cdf0e10cSrcweir SCCOL nXRight = nPosX + pViewData->VisibleCellsX(eHWhich); 5113*cdf0e10cSrcweir if (nXRight > MAXCOL) nXRight = MAXCOL; 5114*cdf0e10cSrcweir SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich); 5115*cdf0e10cSrcweir if (nYBottom > MAXROW) nYBottom = MAXROW; 5116*cdf0e10cSrcweir 5117*cdf0e10cSrcweir // Store the current visible range. 5118*cdf0e10cSrcweir maVisibleRange.mnCol1 = nPosX; 5119*cdf0e10cSrcweir maVisibleRange.mnCol2 = nXRight; 5120*cdf0e10cSrcweir maVisibleRange.mnRow1 = nPosY; 5121*cdf0e10cSrcweir maVisibleRange.mnRow2 = nYBottom; 5122*cdf0e10cSrcweir } 5123*cdf0e10cSrcweir 5124*cdf0e10cSrcweir // #114409# 5125*cdf0e10cSrcweir void ScGridWindow::DrawLayerCreated() 5126*cdf0e10cSrcweir { 5127*cdf0e10cSrcweir SetMapMode( GetDrawMapMode() ); 5128*cdf0e10cSrcweir 5129*cdf0e10cSrcweir // initially create overlay objects 5130*cdf0e10cSrcweir ImpCreateOverlayObjects(); 5131*cdf0e10cSrcweir } 5132*cdf0e10cSrcweir 5133*cdf0e10cSrcweir // #114409# 5134*cdf0e10cSrcweir void ScGridWindow::CursorChanged() 5135*cdf0e10cSrcweir { 5136*cdf0e10cSrcweir // here the created OverlayObjects may be transformed in later versions. For 5137*cdf0e10cSrcweir // now, just re-create them 5138*cdf0e10cSrcweir 5139*cdf0e10cSrcweir UpdateCursorOverlay(); 5140*cdf0e10cSrcweir } 5141*cdf0e10cSrcweir 5142*cdf0e10cSrcweir // #114409# 5143*cdf0e10cSrcweir void ScGridWindow::ImpCreateOverlayObjects() 5144*cdf0e10cSrcweir { 5145*cdf0e10cSrcweir UpdateCursorOverlay(); 5146*cdf0e10cSrcweir UpdateSelectionOverlay(); 5147*cdf0e10cSrcweir UpdateAutoFillOverlay(); 5148*cdf0e10cSrcweir UpdateDragRectOverlay(); 5149*cdf0e10cSrcweir UpdateHeaderOverlay(); 5150*cdf0e10cSrcweir UpdateShrinkOverlay(); 5151*cdf0e10cSrcweir } 5152*cdf0e10cSrcweir 5153*cdf0e10cSrcweir // #114409# 5154*cdf0e10cSrcweir void ScGridWindow::ImpDestroyOverlayObjects() 5155*cdf0e10cSrcweir { 5156*cdf0e10cSrcweir DeleteCursorOverlay(); 5157*cdf0e10cSrcweir DeleteSelectionOverlay(); 5158*cdf0e10cSrcweir DeleteAutoFillOverlay(); 5159*cdf0e10cSrcweir DeleteDragRectOverlay(); 5160*cdf0e10cSrcweir DeleteHeaderOverlay(); 5161*cdf0e10cSrcweir DeleteShrinkOverlay(); 5162*cdf0e10cSrcweir } 5163*cdf0e10cSrcweir 5164*cdf0e10cSrcweir void ScGridWindow::UpdateAllOverlays() 5165*cdf0e10cSrcweir { 5166*cdf0e10cSrcweir // delete and re-allocate all overlay objects 5167*cdf0e10cSrcweir 5168*cdf0e10cSrcweir ImpDestroyOverlayObjects(); 5169*cdf0e10cSrcweir ImpCreateOverlayObjects(); 5170*cdf0e10cSrcweir } 5171*cdf0e10cSrcweir 5172*cdf0e10cSrcweir void ScGridWindow::DeleteCursorOverlay() 5173*cdf0e10cSrcweir { 5174*cdf0e10cSrcweir DELETEZ( mpOOCursors ); 5175*cdf0e10cSrcweir } 5176*cdf0e10cSrcweir 5177*cdf0e10cSrcweir void ScGridWindow::UpdateCursorOverlay() 5178*cdf0e10cSrcweir { 5179*cdf0e10cSrcweir MapMode aDrawMode = GetDrawMapMode(); 5180*cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); 5181*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5182*cdf0e10cSrcweir SetMapMode( aDrawMode ); 5183*cdf0e10cSrcweir 5184*cdf0e10cSrcweir // Existing OverlayObjects may be transformed in later versions. 5185*cdf0e10cSrcweir // For now, just re-create them. 5186*cdf0e10cSrcweir 5187*cdf0e10cSrcweir DeleteCursorOverlay(); 5188*cdf0e10cSrcweir 5189*cdf0e10cSrcweir std::vector<Rectangle> aPixelRects; 5190*cdf0e10cSrcweir 5191*cdf0e10cSrcweir // 5192*cdf0e10cSrcweir // determine the cursor rectangles in pixels (moved from ScGridWindow::DrawCursor) 5193*cdf0e10cSrcweir // 5194*cdf0e10cSrcweir 5195*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 5196*cdf0e10cSrcweir SCCOL nX = pViewData->GetCurX(); 5197*cdf0e10cSrcweir SCROW nY = pViewData->GetCurY(); 5198*cdf0e10cSrcweir 5199*cdf0e10cSrcweir if (!maVisibleRange.isInside(nX, nY)) 5200*cdf0e10cSrcweir return; 5201*cdf0e10cSrcweir 5202*cdf0e10cSrcweir // don't show the cursor in overlapped cells 5203*cdf0e10cSrcweir 5204*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 5205*cdf0e10cSrcweir const ScPatternAttr* pPattern = pDoc->GetPattern(nX,nY,nTab); 5206*cdf0e10cSrcweir const ScMergeFlagAttr& rMergeFlag = (const ScMergeFlagAttr&) pPattern->GetItem(ATTR_MERGE_FLAG); 5207*cdf0e10cSrcweir sal_Bool bOverlapped = rMergeFlag.IsOverlapped(); 5208*cdf0e10cSrcweir 5209*cdf0e10cSrcweir // left or above of the screen? 5210*cdf0e10cSrcweir 5211*cdf0e10cSrcweir sal_Bool bVis = ( nX>=pViewData->GetPosX(eHWhich) && nY>=pViewData->GetPosY(eVWhich) ); 5212*cdf0e10cSrcweir if (!bVis) 5213*cdf0e10cSrcweir { 5214*cdf0e10cSrcweir SCCOL nEndX = nX; 5215*cdf0e10cSrcweir SCROW nEndY = nY; 5216*cdf0e10cSrcweir const ScMergeAttr& rMerge = (const ScMergeAttr&) pPattern->GetItem(ATTR_MERGE); 5217*cdf0e10cSrcweir if (rMerge.GetColMerge() > 1) 5218*cdf0e10cSrcweir nEndX += rMerge.GetColMerge()-1; 5219*cdf0e10cSrcweir if (rMerge.GetRowMerge() > 1) 5220*cdf0e10cSrcweir nEndY += rMerge.GetRowMerge()-1; 5221*cdf0e10cSrcweir bVis = ( nEndX>=pViewData->GetPosX(eHWhich) && nEndY>=pViewData->GetPosY(eVWhich) ); 5222*cdf0e10cSrcweir } 5223*cdf0e10cSrcweir 5224*cdf0e10cSrcweir if ( bVis && !bOverlapped && !pViewData->HasEditView(eWhich) && pViewData->IsActive() ) 5225*cdf0e10cSrcweir { 5226*cdf0e10cSrcweir Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, sal_True ); 5227*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 5228*cdf0e10cSrcweir 5229*cdf0e10cSrcweir // completely right of/below the screen? 5230*cdf0e10cSrcweir // (test with logical start position in aScrPos) 5231*cdf0e10cSrcweir sal_Bool bMaybeVisible; 5232*cdf0e10cSrcweir if ( bLayoutRTL ) 5233*cdf0e10cSrcweir bMaybeVisible = ( aScrPos.X() >= -2 && aScrPos.Y() >= -2 ); 5234*cdf0e10cSrcweir else 5235*cdf0e10cSrcweir { 5236*cdf0e10cSrcweir Size aOutSize = GetOutputSizePixel(); 5237*cdf0e10cSrcweir bMaybeVisible = ( aScrPos.X() <= aOutSize.Width() + 2 && aScrPos.Y() <= aOutSize.Height() + 2 ); 5238*cdf0e10cSrcweir } 5239*cdf0e10cSrcweir if ( bMaybeVisible ) 5240*cdf0e10cSrcweir { 5241*cdf0e10cSrcweir long nSizeXPix; 5242*cdf0e10cSrcweir long nSizeYPix; 5243*cdf0e10cSrcweir pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); 5244*cdf0e10cSrcweir 5245*cdf0e10cSrcweir if ( bLayoutRTL ) 5246*cdf0e10cSrcweir aScrPos.X() -= nSizeXPix - 2; // move instead of mirroring 5247*cdf0e10cSrcweir 5248*cdf0e10cSrcweir sal_Bool bFix = ( pViewData->GetHSplitMode() == SC_SPLIT_FIX || 5249*cdf0e10cSrcweir pViewData->GetVSplitMode() == SC_SPLIT_FIX ); 5250*cdf0e10cSrcweir if ( pViewData->GetActivePart()==eWhich || bFix ) 5251*cdf0e10cSrcweir { 5252*cdf0e10cSrcweir aScrPos.X() -= 2; 5253*cdf0e10cSrcweir aScrPos.Y() -= 2; 5254*cdf0e10cSrcweir Rectangle aRect( aScrPos, Size( nSizeXPix + 3, nSizeYPix + 3 ) ); 5255*cdf0e10cSrcweir 5256*cdf0e10cSrcweir aPixelRects.push_back(Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() )); 5257*cdf0e10cSrcweir aPixelRects.push_back(Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() )); 5258*cdf0e10cSrcweir aPixelRects.push_back(Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 )); 5259*cdf0e10cSrcweir aPixelRects.push_back(Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() )); 5260*cdf0e10cSrcweir } 5261*cdf0e10cSrcweir else 5262*cdf0e10cSrcweir { 5263*cdf0e10cSrcweir Rectangle aRect( aScrPos, Size( nSizeXPix - 1, nSizeYPix - 1 ) ); 5264*cdf0e10cSrcweir aPixelRects.push_back( aRect ); 5265*cdf0e10cSrcweir } 5266*cdf0e10cSrcweir } 5267*cdf0e10cSrcweir } 5268*cdf0e10cSrcweir 5269*cdf0e10cSrcweir if ( aPixelRects.size() ) 5270*cdf0e10cSrcweir { 5271*cdf0e10cSrcweir // #i70788# get the OverlayManager safely 5272*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager(); 5273*cdf0e10cSrcweir 5274*cdf0e10cSrcweir if(pOverlayManager) 5275*cdf0e10cSrcweir { 5276*cdf0e10cSrcweir const Color aCursorColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor ); 5277*cdf0e10cSrcweir std::vector< basegfx::B2DRange > aRanges; 5278*cdf0e10cSrcweir const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation()); 5279*cdf0e10cSrcweir 5280*cdf0e10cSrcweir for(sal_uInt32 a(0); a < aPixelRects.size(); a++) 5281*cdf0e10cSrcweir { 5282*cdf0e10cSrcweir const Rectangle aRA(aPixelRects[a]); 5283*cdf0e10cSrcweir basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1); 5284*cdf0e10cSrcweir aRB.transform(aTransform); 5285*cdf0e10cSrcweir aRanges.push_back(aRB); 5286*cdf0e10cSrcweir } 5287*cdf0e10cSrcweir 5288*cdf0e10cSrcweir sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection( 5289*cdf0e10cSrcweir sdr::overlay::OVERLAY_SOLID, 5290*cdf0e10cSrcweir aCursorColor, 5291*cdf0e10cSrcweir aRanges, 5292*cdf0e10cSrcweir false); 5293*cdf0e10cSrcweir 5294*cdf0e10cSrcweir pOverlayManager->add(*pOverlay); 5295*cdf0e10cSrcweir mpOOCursors = new ::sdr::overlay::OverlayObjectList; 5296*cdf0e10cSrcweir mpOOCursors->append(*pOverlay); 5297*cdf0e10cSrcweir } 5298*cdf0e10cSrcweir } 5299*cdf0e10cSrcweir 5300*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5301*cdf0e10cSrcweir SetMapMode( aOldMode ); 5302*cdf0e10cSrcweir } 5303*cdf0e10cSrcweir 5304*cdf0e10cSrcweir void ScGridWindow::DeleteSelectionOverlay() 5305*cdf0e10cSrcweir { 5306*cdf0e10cSrcweir DELETEZ( mpOOSelection ); 5307*cdf0e10cSrcweir } 5308*cdf0e10cSrcweir 5309*cdf0e10cSrcweir void ScGridWindow::UpdateSelectionOverlay() 5310*cdf0e10cSrcweir { 5311*cdf0e10cSrcweir MapMode aDrawMode = GetDrawMapMode(); 5312*cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); 5313*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5314*cdf0e10cSrcweir SetMapMode( aDrawMode ); 5315*cdf0e10cSrcweir 5316*cdf0e10cSrcweir DeleteSelectionOverlay(); 5317*cdf0e10cSrcweir std::vector<Rectangle> aPixelRects; 5318*cdf0e10cSrcweir GetSelectionRects( aPixelRects ); 5319*cdf0e10cSrcweir 5320*cdf0e10cSrcweir if ( aPixelRects.size() && pViewData->IsActive() ) 5321*cdf0e10cSrcweir { 5322*cdf0e10cSrcweir // #i70788# get the OverlayManager safely 5323*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager(); 5324*cdf0e10cSrcweir 5325*cdf0e10cSrcweir if(pOverlayManager) 5326*cdf0e10cSrcweir { 5327*cdf0e10cSrcweir std::vector< basegfx::B2DRange > aRanges; 5328*cdf0e10cSrcweir const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation()); 5329*cdf0e10cSrcweir 5330*cdf0e10cSrcweir for(sal_uInt32 a(0); a < aPixelRects.size(); a++) 5331*cdf0e10cSrcweir { 5332*cdf0e10cSrcweir const Rectangle aRA(aPixelRects[a]); 5333*cdf0e10cSrcweir basegfx::B2DRange aRB(aRA.Left() - 1, aRA.Top() - 1, aRA.Right(), aRA.Bottom()); 5334*cdf0e10cSrcweir aRB.transform(aTransform); 5335*cdf0e10cSrcweir aRanges.push_back(aRB); 5336*cdf0e10cSrcweir } 5337*cdf0e10cSrcweir 5338*cdf0e10cSrcweir // #i97672# get the system's hilight color and limit it to the maximum 5339*cdf0e10cSrcweir // allowed luminance. This is needed to react on too bright hilight colors 5340*cdf0e10cSrcweir // which would otherwise vive a bad visualisation 5341*cdf0e10cSrcweir Color aHighlight(GetSettings().GetStyleSettings().GetHighlightColor()); 5342*cdf0e10cSrcweir const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; 5343*cdf0e10cSrcweir const basegfx::BColor aSelection(aHighlight.getBColor()); 5344*cdf0e10cSrcweir const double fLuminance(aSelection.luminance()); 5345*cdf0e10cSrcweir const double fMaxLum(aSvtOptionsDrawinglayer.GetSelectionMaximumLuminancePercent() / 100.0); 5346*cdf0e10cSrcweir 5347*cdf0e10cSrcweir if(fLuminance > fMaxLum) 5348*cdf0e10cSrcweir { 5349*cdf0e10cSrcweir const double fFactor(fMaxLum / fLuminance); 5350*cdf0e10cSrcweir const basegfx::BColor aNewSelection( 5351*cdf0e10cSrcweir aSelection.getRed() * fFactor, 5352*cdf0e10cSrcweir aSelection.getGreen() * fFactor, 5353*cdf0e10cSrcweir aSelection.getBlue() * fFactor); 5354*cdf0e10cSrcweir 5355*cdf0e10cSrcweir aHighlight = Color(aNewSelection); 5356*cdf0e10cSrcweir } 5357*cdf0e10cSrcweir 5358*cdf0e10cSrcweir sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection( 5359*cdf0e10cSrcweir sdr::overlay::OVERLAY_TRANSPARENT, 5360*cdf0e10cSrcweir aHighlight, 5361*cdf0e10cSrcweir aRanges, 5362*cdf0e10cSrcweir true); 5363*cdf0e10cSrcweir 5364*cdf0e10cSrcweir pOverlayManager->add(*pOverlay); 5365*cdf0e10cSrcweir mpOOSelection = new ::sdr::overlay::OverlayObjectList; 5366*cdf0e10cSrcweir mpOOSelection->append(*pOverlay); 5367*cdf0e10cSrcweir } 5368*cdf0e10cSrcweir } 5369*cdf0e10cSrcweir 5370*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5371*cdf0e10cSrcweir SetMapMode( aOldMode ); 5372*cdf0e10cSrcweir } 5373*cdf0e10cSrcweir 5374*cdf0e10cSrcweir void ScGridWindow::DeleteAutoFillOverlay() 5375*cdf0e10cSrcweir { 5376*cdf0e10cSrcweir DELETEZ( mpOOAutoFill ); 5377*cdf0e10cSrcweir mpAutoFillRect.reset(); 5378*cdf0e10cSrcweir } 5379*cdf0e10cSrcweir 5380*cdf0e10cSrcweir void ScGridWindow::UpdateAutoFillOverlay() 5381*cdf0e10cSrcweir { 5382*cdf0e10cSrcweir MapMode aDrawMode = GetDrawMapMode(); 5383*cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); 5384*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5385*cdf0e10cSrcweir SetMapMode( aDrawMode ); 5386*cdf0e10cSrcweir 5387*cdf0e10cSrcweir DeleteAutoFillOverlay(); 5388*cdf0e10cSrcweir 5389*cdf0e10cSrcweir // 5390*cdf0e10cSrcweir // get the AutoFill handle rectangle in pixels (moved from ScGridWindow::DrawAutoFillMark) 5391*cdf0e10cSrcweir // 5392*cdf0e10cSrcweir 5393*cdf0e10cSrcweir if ( bAutoMarkVisible && aAutoMarkPos.Tab() == pViewData->GetTabNo() && 5394*cdf0e10cSrcweir !pViewData->HasEditView(eWhich) && pViewData->IsActive() ) 5395*cdf0e10cSrcweir { 5396*cdf0e10cSrcweir SCCOL nX = aAutoMarkPos.Col(); 5397*cdf0e10cSrcweir SCROW nY = aAutoMarkPos.Row(); 5398*cdf0e10cSrcweir 5399*cdf0e10cSrcweir if (!maVisibleRange.isInside(nX, nY)) 5400*cdf0e10cSrcweir // Autofill mark is not visible. Bail out. 5401*cdf0e10cSrcweir return; 5402*cdf0e10cSrcweir 5403*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 5404*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 5405*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 5406*cdf0e10cSrcweir 5407*cdf0e10cSrcweir Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, sal_True ); 5408*cdf0e10cSrcweir long nSizeXPix; 5409*cdf0e10cSrcweir long nSizeYPix; 5410*cdf0e10cSrcweir pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix ); 5411*cdf0e10cSrcweir if ( bLayoutRTL ) 5412*cdf0e10cSrcweir aFillPos.X() -= nSizeXPix + 3; 5413*cdf0e10cSrcweir else 5414*cdf0e10cSrcweir aFillPos.X() += nSizeXPix - 2; 5415*cdf0e10cSrcweir 5416*cdf0e10cSrcweir aFillPos.Y() += nSizeYPix; 5417*cdf0e10cSrcweir aFillPos.Y() -= 2; 5418*cdf0e10cSrcweir mpAutoFillRect.reset(new Rectangle(aFillPos, Size(6, 6))); 5419*cdf0e10cSrcweir 5420*cdf0e10cSrcweir // #i70788# get the OverlayManager safely 5421*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager(); 5422*cdf0e10cSrcweir 5423*cdf0e10cSrcweir if(pOverlayManager) 5424*cdf0e10cSrcweir { 5425*cdf0e10cSrcweir const Color aHandleColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor ); 5426*cdf0e10cSrcweir std::vector< basegfx::B2DRange > aRanges; 5427*cdf0e10cSrcweir const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation()); 5428*cdf0e10cSrcweir basegfx::B2DRange aRB(mpAutoFillRect->Left(), mpAutoFillRect->Top(), mpAutoFillRect->Right() + 1, mpAutoFillRect->Bottom() + 1); 5429*cdf0e10cSrcweir 5430*cdf0e10cSrcweir aRB.transform(aTransform); 5431*cdf0e10cSrcweir aRanges.push_back(aRB); 5432*cdf0e10cSrcweir 5433*cdf0e10cSrcweir sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection( 5434*cdf0e10cSrcweir sdr::overlay::OVERLAY_SOLID, 5435*cdf0e10cSrcweir aHandleColor, 5436*cdf0e10cSrcweir aRanges, 5437*cdf0e10cSrcweir false); 5438*cdf0e10cSrcweir 5439*cdf0e10cSrcweir pOverlayManager->add(*pOverlay); 5440*cdf0e10cSrcweir mpOOAutoFill = new ::sdr::overlay::OverlayObjectList; 5441*cdf0e10cSrcweir mpOOAutoFill->append(*pOverlay); 5442*cdf0e10cSrcweir } 5443*cdf0e10cSrcweir 5444*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5445*cdf0e10cSrcweir SetMapMode( aOldMode ); 5446*cdf0e10cSrcweir } 5447*cdf0e10cSrcweir } 5448*cdf0e10cSrcweir 5449*cdf0e10cSrcweir void ScGridWindow::DeleteDragRectOverlay() 5450*cdf0e10cSrcweir { 5451*cdf0e10cSrcweir DELETEZ( mpOODragRect ); 5452*cdf0e10cSrcweir } 5453*cdf0e10cSrcweir 5454*cdf0e10cSrcweir void ScGridWindow::UpdateDragRectOverlay() 5455*cdf0e10cSrcweir { 5456*cdf0e10cSrcweir MapMode aDrawMode = GetDrawMapMode(); 5457*cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); 5458*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5459*cdf0e10cSrcweir SetMapMode( aDrawMode ); 5460*cdf0e10cSrcweir 5461*cdf0e10cSrcweir DeleteDragRectOverlay(); 5462*cdf0e10cSrcweir 5463*cdf0e10cSrcweir // 5464*cdf0e10cSrcweir // get the rectangles in pixels (moved from DrawDragRect) 5465*cdf0e10cSrcweir // 5466*cdf0e10cSrcweir 5467*cdf0e10cSrcweir if ( bDragRect || bPagebreakDrawn ) 5468*cdf0e10cSrcweir { 5469*cdf0e10cSrcweir std::vector<Rectangle> aPixelRects; 5470*cdf0e10cSrcweir 5471*cdf0e10cSrcweir SCCOL nX1 = bDragRect ? nDragStartX : aPagebreakDrag.aStart.Col(); 5472*cdf0e10cSrcweir SCROW nY1 = bDragRect ? nDragStartY : aPagebreakDrag.aStart.Row(); 5473*cdf0e10cSrcweir SCCOL nX2 = bDragRect ? nDragEndX : aPagebreakDrag.aEnd.Col(); 5474*cdf0e10cSrcweir SCROW nY2 = bDragRect ? nDragEndY : aPagebreakDrag.aEnd.Row(); 5475*cdf0e10cSrcweir 5476*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 5477*cdf0e10cSrcweir 5478*cdf0e10cSrcweir SCCOL nPosX = pViewData->GetPosX(WhichH(eWhich)); 5479*cdf0e10cSrcweir SCROW nPosY = pViewData->GetPosY(WhichV(eWhich)); 5480*cdf0e10cSrcweir if (nX1 < nPosX) nX1 = nPosX; 5481*cdf0e10cSrcweir if (nX2 < nPosX) nX2 = nPosX; 5482*cdf0e10cSrcweir if (nY1 < nPosY) nY1 = nPosY; 5483*cdf0e10cSrcweir if (nY2 < nPosY) nY2 = nPosY; 5484*cdf0e10cSrcweir 5485*cdf0e10cSrcweir Point aScrPos( pViewData->GetScrPos( nX1, nY1, eWhich ) ); 5486*cdf0e10cSrcweir 5487*cdf0e10cSrcweir long nSizeXPix=0; 5488*cdf0e10cSrcweir long nSizeYPix=0; 5489*cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 5490*cdf0e10cSrcweir double nPPTX = pViewData->GetPPTX(); 5491*cdf0e10cSrcweir double nPPTY = pViewData->GetPPTY(); 5492*cdf0e10cSrcweir SCCOLROW i; 5493*cdf0e10cSrcweir 5494*cdf0e10cSrcweir sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTab ); 5495*cdf0e10cSrcweir long nLayoutSign = bLayoutRTL ? -1 : 1; 5496*cdf0e10cSrcweir 5497*cdf0e10cSrcweir if (ValidCol(nX2) && nX2>=nX1) 5498*cdf0e10cSrcweir for (i=nX1; i<=nX2; i++) 5499*cdf0e10cSrcweir nSizeXPix += ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(i), nTab ), nPPTX ); 5500*cdf0e10cSrcweir else 5501*cdf0e10cSrcweir { 5502*cdf0e10cSrcweir aScrPos.X() -= nLayoutSign; 5503*cdf0e10cSrcweir nSizeXPix += 2; 5504*cdf0e10cSrcweir } 5505*cdf0e10cSrcweir 5506*cdf0e10cSrcweir if (ValidRow(nY2) && nY2>=nY1) 5507*cdf0e10cSrcweir for (i=nY1; i<=nY2; i++) 5508*cdf0e10cSrcweir nSizeYPix += ScViewData::ToPixel( pDoc->GetRowHeight( i, nTab ), nPPTY ); 5509*cdf0e10cSrcweir else 5510*cdf0e10cSrcweir { 5511*cdf0e10cSrcweir aScrPos.Y() -= 1; 5512*cdf0e10cSrcweir nSizeYPix += 2; 5513*cdf0e10cSrcweir } 5514*cdf0e10cSrcweir 5515*cdf0e10cSrcweir aScrPos.X() -= 2 * nLayoutSign; 5516*cdf0e10cSrcweir aScrPos.Y() -= 2; 5517*cdf0e10cSrcweir // Rectangle aRect( aScrPos, Size( nSizeXPix + 3, nSizeYPix + 3 ) ); 5518*cdf0e10cSrcweir Rectangle aRect( aScrPos.X(), aScrPos.Y(), 5519*cdf0e10cSrcweir aScrPos.X() + ( nSizeXPix + 2 ) * nLayoutSign, aScrPos.Y() + nSizeYPix + 2 ); 5520*cdf0e10cSrcweir if ( bLayoutRTL ) 5521*cdf0e10cSrcweir { 5522*cdf0e10cSrcweir aRect.Left() = aRect.Right(); // end position is left 5523*cdf0e10cSrcweir aRect.Right() = aScrPos.X(); 5524*cdf0e10cSrcweir } 5525*cdf0e10cSrcweir 5526*cdf0e10cSrcweir if ( meDragInsertMode == INS_CELLSDOWN ) 5527*cdf0e10cSrcweir { 5528*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Left()+1, aRect.Top()+3, aRect.Left()+1, aRect.Bottom()-2 ) ); 5529*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Right()-1, aRect.Top()+3, aRect.Right()-1, aRect.Bottom()-2 ) ); 5530*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Left()+1, aRect.Top(), aRect.Right()-1, aRect.Top()+2 ) ); 5531*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Left()+1, aRect.Bottom()-1, aRect.Right()-1, aRect.Bottom()-1 ) ); 5532*cdf0e10cSrcweir } 5533*cdf0e10cSrcweir else if ( meDragInsertMode == INS_CELLSRIGHT ) 5534*cdf0e10cSrcweir { 5535*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Left(), aRect.Top()+1, aRect.Left()+2, aRect.Bottom()-1 ) ); 5536*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Right()-1, aRect.Top()+1, aRect.Right()-1, aRect.Bottom()-1 ) ); 5537*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Top()+1, aRect.Right()-2, aRect.Top()+1 ) ); 5538*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Bottom()-1, aRect.Right()-2, aRect.Bottom()-1 ) ); 5539*cdf0e10cSrcweir } 5540*cdf0e10cSrcweir else 5541*cdf0e10cSrcweir { 5542*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() ) ); 5543*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() ) ); 5544*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 ) ); 5545*cdf0e10cSrcweir aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() ) ); 5546*cdf0e10cSrcweir } 5547*cdf0e10cSrcweir 5548*cdf0e10cSrcweir // #i70788# get the OverlayManager safely 5549*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager(); 5550*cdf0e10cSrcweir 5551*cdf0e10cSrcweir if(pOverlayManager) 5552*cdf0e10cSrcweir { 5553*cdf0e10cSrcweir // Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor(); 5554*cdf0e10cSrcweir std::vector< basegfx::B2DRange > aRanges; 5555*cdf0e10cSrcweir const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation()); 5556*cdf0e10cSrcweir 5557*cdf0e10cSrcweir for(sal_uInt32 a(0); a < aPixelRects.size(); a++) 5558*cdf0e10cSrcweir { 5559*cdf0e10cSrcweir const Rectangle aRA(aPixelRects[a]); 5560*cdf0e10cSrcweir basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1); 5561*cdf0e10cSrcweir aRB.transform(aTransform); 5562*cdf0e10cSrcweir aRanges.push_back(aRB); 5563*cdf0e10cSrcweir } 5564*cdf0e10cSrcweir 5565*cdf0e10cSrcweir sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection( 5566*cdf0e10cSrcweir sdr::overlay::OVERLAY_INVERT, 5567*cdf0e10cSrcweir Color(COL_BLACK), 5568*cdf0e10cSrcweir aRanges, 5569*cdf0e10cSrcweir false); 5570*cdf0e10cSrcweir 5571*cdf0e10cSrcweir pOverlayManager->add(*pOverlay); 5572*cdf0e10cSrcweir mpOODragRect = new ::sdr::overlay::OverlayObjectList; 5573*cdf0e10cSrcweir mpOODragRect->append(*pOverlay); 5574*cdf0e10cSrcweir } 5575*cdf0e10cSrcweir } 5576*cdf0e10cSrcweir 5577*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5578*cdf0e10cSrcweir SetMapMode( aOldMode ); 5579*cdf0e10cSrcweir } 5580*cdf0e10cSrcweir 5581*cdf0e10cSrcweir void ScGridWindow::DeleteHeaderOverlay() 5582*cdf0e10cSrcweir { 5583*cdf0e10cSrcweir DELETEZ( mpOOHeader ); 5584*cdf0e10cSrcweir } 5585*cdf0e10cSrcweir 5586*cdf0e10cSrcweir void ScGridWindow::UpdateHeaderOverlay() 5587*cdf0e10cSrcweir { 5588*cdf0e10cSrcweir MapMode aDrawMode = GetDrawMapMode(); 5589*cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); 5590*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5591*cdf0e10cSrcweir SetMapMode( aDrawMode ); 5592*cdf0e10cSrcweir 5593*cdf0e10cSrcweir DeleteHeaderOverlay(); 5594*cdf0e10cSrcweir 5595*cdf0e10cSrcweir // Pixel rectangle is in aInvertRect 5596*cdf0e10cSrcweir if ( !aInvertRect.IsEmpty() ) 5597*cdf0e10cSrcweir { 5598*cdf0e10cSrcweir // #i70788# get the OverlayManager safely 5599*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager(); 5600*cdf0e10cSrcweir 5601*cdf0e10cSrcweir if(pOverlayManager) 5602*cdf0e10cSrcweir { 5603*cdf0e10cSrcweir // Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor(); 5604*cdf0e10cSrcweir std::vector< basegfx::B2DRange > aRanges; 5605*cdf0e10cSrcweir const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation()); 5606*cdf0e10cSrcweir basegfx::B2DRange aRB(aInvertRect.Left(), aInvertRect.Top(), aInvertRect.Right() + 1, aInvertRect.Bottom() + 1); 5607*cdf0e10cSrcweir 5608*cdf0e10cSrcweir aRB.transform(aTransform); 5609*cdf0e10cSrcweir aRanges.push_back(aRB); 5610*cdf0e10cSrcweir 5611*cdf0e10cSrcweir sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection( 5612*cdf0e10cSrcweir sdr::overlay::OVERLAY_INVERT, 5613*cdf0e10cSrcweir Color(COL_BLACK), 5614*cdf0e10cSrcweir aRanges, 5615*cdf0e10cSrcweir false); 5616*cdf0e10cSrcweir 5617*cdf0e10cSrcweir pOverlayManager->add(*pOverlay); 5618*cdf0e10cSrcweir mpOOHeader = new ::sdr::overlay::OverlayObjectList; 5619*cdf0e10cSrcweir mpOOHeader->append(*pOverlay); 5620*cdf0e10cSrcweir } 5621*cdf0e10cSrcweir } 5622*cdf0e10cSrcweir 5623*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5624*cdf0e10cSrcweir SetMapMode( aOldMode ); 5625*cdf0e10cSrcweir } 5626*cdf0e10cSrcweir 5627*cdf0e10cSrcweir void ScGridWindow::DeleteShrinkOverlay() 5628*cdf0e10cSrcweir { 5629*cdf0e10cSrcweir DELETEZ( mpOOShrink ); 5630*cdf0e10cSrcweir } 5631*cdf0e10cSrcweir 5632*cdf0e10cSrcweir void ScGridWindow::UpdateShrinkOverlay() 5633*cdf0e10cSrcweir { 5634*cdf0e10cSrcweir MapMode aDrawMode = GetDrawMapMode(); 5635*cdf0e10cSrcweir MapMode aOldMode = GetMapMode(); 5636*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5637*cdf0e10cSrcweir SetMapMode( aDrawMode ); 5638*cdf0e10cSrcweir 5639*cdf0e10cSrcweir DeleteShrinkOverlay(); 5640*cdf0e10cSrcweir 5641*cdf0e10cSrcweir // 5642*cdf0e10cSrcweir // get the rectangle in pixels 5643*cdf0e10cSrcweir // 5644*cdf0e10cSrcweir 5645*cdf0e10cSrcweir Rectangle aPixRect; 5646*cdf0e10cSrcweir ScRange aRange; 5647*cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 5648*cdf0e10cSrcweir if ( pViewData->IsRefMode() && nTab >= pViewData->GetRefStartZ() && nTab <= pViewData->GetRefEndZ() && 5649*cdf0e10cSrcweir pViewData->GetDelMark( aRange ) ) 5650*cdf0e10cSrcweir { 5651*cdf0e10cSrcweir //! limit to visible area 5652*cdf0e10cSrcweir if ( aRange.aStart.Col() <= aRange.aEnd.Col() && 5653*cdf0e10cSrcweir aRange.aStart.Row() <= aRange.aEnd.Row() ) 5654*cdf0e10cSrcweir { 5655*cdf0e10cSrcweir Point aStart = pViewData->GetScrPos( aRange.aStart.Col(), 5656*cdf0e10cSrcweir aRange.aStart.Row(), eWhich ); 5657*cdf0e10cSrcweir Point aEnd = pViewData->GetScrPos( aRange.aEnd.Col()+1, 5658*cdf0e10cSrcweir aRange.aEnd.Row()+1, eWhich ); 5659*cdf0e10cSrcweir aEnd.X() -= 1; 5660*cdf0e10cSrcweir aEnd.Y() -= 1; 5661*cdf0e10cSrcweir 5662*cdf0e10cSrcweir aPixRect = Rectangle( aStart,aEnd ); 5663*cdf0e10cSrcweir } 5664*cdf0e10cSrcweir } 5665*cdf0e10cSrcweir 5666*cdf0e10cSrcweir if ( !aPixRect.IsEmpty() ) 5667*cdf0e10cSrcweir { 5668*cdf0e10cSrcweir // #i70788# get the OverlayManager safely 5669*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager(); 5670*cdf0e10cSrcweir 5671*cdf0e10cSrcweir if(pOverlayManager) 5672*cdf0e10cSrcweir { 5673*cdf0e10cSrcweir // Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor(); 5674*cdf0e10cSrcweir std::vector< basegfx::B2DRange > aRanges; 5675*cdf0e10cSrcweir const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation()); 5676*cdf0e10cSrcweir basegfx::B2DRange aRB(aPixRect.Left(), aPixRect.Top(), aPixRect.Right() + 1, aPixRect.Bottom() + 1); 5677*cdf0e10cSrcweir 5678*cdf0e10cSrcweir aRB.transform(aTransform); 5679*cdf0e10cSrcweir aRanges.push_back(aRB); 5680*cdf0e10cSrcweir 5681*cdf0e10cSrcweir sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection( 5682*cdf0e10cSrcweir sdr::overlay::OVERLAY_INVERT, 5683*cdf0e10cSrcweir Color(COL_BLACK), 5684*cdf0e10cSrcweir aRanges, 5685*cdf0e10cSrcweir false); 5686*cdf0e10cSrcweir 5687*cdf0e10cSrcweir pOverlayManager->add(*pOverlay); 5688*cdf0e10cSrcweir mpOOShrink = new ::sdr::overlay::OverlayObjectList; 5689*cdf0e10cSrcweir mpOOShrink->append(*pOverlay); 5690*cdf0e10cSrcweir } 5691*cdf0e10cSrcweir } 5692*cdf0e10cSrcweir 5693*cdf0e10cSrcweir if ( aOldMode != aDrawMode ) 5694*cdf0e10cSrcweir SetMapMode( aOldMode ); 5695*cdf0e10cSrcweir } 5696*cdf0e10cSrcweir 5697*cdf0e10cSrcweir // #i70788# central method to get the OverlayManager safely 5698*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* ScGridWindow::getOverlayManager() 5699*cdf0e10cSrcweir { 5700*cdf0e10cSrcweir SdrPageView* pPV = pViewData->GetView()->GetScDrawView()->GetSdrPageView(); 5701*cdf0e10cSrcweir 5702*cdf0e10cSrcweir if(pPV) 5703*cdf0e10cSrcweir { 5704*cdf0e10cSrcweir SdrPageWindow* pPageWin = pPV->FindPageWindow( *this ); 5705*cdf0e10cSrcweir 5706*cdf0e10cSrcweir if ( pPageWin ) 5707*cdf0e10cSrcweir { 5708*cdf0e10cSrcweir return (pPageWin->GetOverlayManager()); 5709*cdf0e10cSrcweir } 5710*cdf0e10cSrcweir } 5711*cdf0e10cSrcweir 5712*cdf0e10cSrcweir return 0L; 5713*cdf0e10cSrcweir } 5714*cdf0e10cSrcweir 5715*cdf0e10cSrcweir void ScGridWindow::flushOverlayManager() 5716*cdf0e10cSrcweir { 5717*cdf0e10cSrcweir // #i70788# get the OverlayManager safely 5718*cdf0e10cSrcweir ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager(); 5719*cdf0e10cSrcweir 5720*cdf0e10cSrcweir if(pOverlayManager) 5721*cdf0e10cSrcweir { 5722*cdf0e10cSrcweir pOverlayManager->flush(); 5723*cdf0e10cSrcweir } 5724*cdf0e10cSrcweir } 5725*cdf0e10cSrcweir 5726*cdf0e10cSrcweir // --------------------------------------------------------------------------- 5727*cdf0e10cSrcweir // eof 5728