1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SC_GRIDWIN_HXX 29 #define SC_GRIDWIN_HXX 30 31 #include <tools/string.hxx> 32 #include <svtools/transfer.hxx> 33 #include "viewutil.hxx" 34 #include "viewdata.hxx" 35 #include "cbutton.hxx" 36 #include <svx/sdr/overlay/overlayobject.hxx> 37 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> 38 #include <basegfx/matrix/b2dhommatrix.hxx> 39 40 #include <vector> 41 #include <memory> 42 #include <boost/shared_ptr.hpp> 43 44 // --------------------------------------------------------------------------- 45 46 struct ScTableInfo; 47 class ScViewSelectionEngine; 48 class ScDPObject; 49 class ScDPFieldPopupWindow; 50 class ScDPFieldButton; 51 class ScOutputData; 52 class ScFilterListBox; 53 class AutoFilterPopup; 54 class SdrObject; 55 class SdrEditView; 56 class ScNoteMarker; 57 class FloatingWindow; 58 class SdrHdlList; 59 class ScTransferObj; 60 struct SpellCallbackInfo; 61 62 // Maus-Status (nMouseStatus) 63 64 #define SC_GM_NONE 0 65 #define SC_GM_TABDOWN 1 66 #define SC_GM_DBLDOWN 2 67 #define SC_GM_FILTER 3 68 #define SC_GM_IGNORE 4 69 #define SC_GM_WATERUNDO 5 70 #define SC_GM_URLDOWN 6 71 72 // Page-Drag-Modus 73 74 #define SC_PD_NONE 0 75 #define SC_PD_RANGE_L 1 76 #define SC_PD_RANGE_R 2 77 #define SC_PD_RANGE_T 4 78 #define SC_PD_RANGE_B 8 79 #define SC_PD_RANGE_TL (SC_PD_RANGE_T|SC_PD_RANGE_L) 80 #define SC_PD_RANGE_TR (SC_PD_RANGE_T|SC_PD_RANGE_R) 81 #define SC_PD_RANGE_BL (SC_PD_RANGE_B|SC_PD_RANGE_L) 82 #define SC_PD_RANGE_BR (SC_PD_RANGE_B|SC_PD_RANGE_R) 83 #define SC_PD_BREAK_H 16 84 #define SC_PD_BREAK_V 32 85 86 87 class ScHideTextCursor 88 { 89 private: 90 ScViewData* pViewData; 91 ScSplitPos eWhich; 92 93 public: 94 ScHideTextCursor( ScViewData* pData, ScSplitPos eW ); 95 ~ScHideTextCursor(); 96 }; 97 98 // --------------------------------------------------------------------------- 99 // predefines 100 namespace sdr { namespace overlay { class OverlayObjectList; }} 101 102 class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHelper 103 { 104 // ScFilterListBox wird immer fuer Auswahlliste benutzt 105 friend class ScFilterListBox; 106 107 private: 108 // #114409# 109 ::sdr::overlay::OverlayObjectList* mpOOCursors; 110 ::sdr::overlay::OverlayObjectList* mpOOSelection; 111 ::sdr::overlay::OverlayObjectList* mpOOAutoFill; 112 ::sdr::overlay::OverlayObjectList* mpOODragRect; 113 ::sdr::overlay::OverlayObjectList* mpOOHeader; 114 ::sdr::overlay::OverlayObjectList* mpOOShrink; 115 116 ::boost::shared_ptr<Rectangle> mpAutoFillRect; 117 118 /** 119 * Stores current visible column and row ranges, used to avoid expensive 120 * operations on objects that are outside visible area. 121 */ 122 struct VisibleRange 123 { 124 SCCOL mnCol1; 125 SCCOL mnCol2; 126 SCROW mnRow1; 127 SCROW mnRow2; 128 129 VisibleRange(); 130 131 bool isInside(SCCOL nCol, SCROW nRow) const; 132 }; 133 VisibleRange maVisibleRange; 134 135 private: 136 ScViewData* pViewData; 137 ScSplitPos eWhich; 138 ScHSplitPos eHWhich; 139 ScVSplitPos eVWhich; 140 141 ScNoteMarker* pNoteMarker; 142 143 ScFilterListBox* pFilterBox; 144 FloatingWindow* pFilterFloat; 145 ::std::auto_ptr<ScDPFieldPopupWindow> mpDPFieldPopup; 146 ::std::auto_ptr<ScDPFieldButton> mpFilterButton; 147 148 sal_uInt16 nCursorHideCount; 149 150 sal_Bool bMarking; 151 152 sal_uInt16 nButtonDown; 153 sal_Bool bEEMouse; // Edit-Engine hat Maus 154 sal_uInt8 nMouseStatus; 155 sal_uInt8 nNestedButtonState; // track nested button up/down calls 156 157 sal_Bool bDPMouse; // DataPilot-D&D (neue Pivottabellen) 158 long nDPField; 159 ScDPObject* pDragDPObj; //! name? 160 161 sal_Bool bRFMouse; // RangeFinder-Drag 162 sal_Bool bRFSize; 163 sal_uInt16 nRFIndex; 164 SCsCOL nRFAddX; 165 SCsROW nRFAddY; 166 167 sal_uInt16 nPagebreakMouse; // Pagebreak-Modus Drag 168 SCCOLROW nPagebreakBreak; 169 SCCOLROW nPagebreakPrev; 170 ScRange aPagebreakSource; 171 ScRange aPagebreakDrag; 172 sal_Bool bPagebreakDrawn; 173 174 sal_uInt8 nPageScript; 175 176 long nLastClickX; 177 long nLastClickY; 178 179 sal_Bool bDragRect; 180 SCCOL nDragStartX; 181 SCROW nDragStartY; 182 SCCOL nDragEndX; 183 SCROW nDragEndY; 184 InsCellCmd meDragInsertMode; 185 186 sal_uInt16 nCurrentPointer; 187 188 sal_Bool bIsInScroll; 189 sal_Bool bIsInPaint; 190 191 ScDDComboBoxButton aComboButton; 192 193 Point aCurMousePos; 194 195 sal_uInt16 nPaintCount; 196 Rectangle aRepaintPixel; 197 sal_Bool bNeedsRepaint; 198 199 sal_Bool bAutoMarkVisible; 200 ScAddress aAutoMarkPos; 201 202 sal_Bool bListValButton; 203 ScAddress aListValPos; 204 205 Rectangle aInvertRect; 206 207 DECL_LINK( PopupModeEndHdl, FloatingWindow* ); 208 DECL_LINK( PopupSpellingHdl, SpellCallbackInfo* ); 209 210 sal_Bool TestMouse( const MouseEvent& rMEvt, sal_Bool bAction ); 211 212 sal_Bool DoPageFieldSelection( SCCOL nCol, SCROW nRow ); 213 bool DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt ); 214 void DoPushButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt ); 215 216 void DPMouseMove( const MouseEvent& rMEvt ); 217 void DPMouseButtonUp( const MouseEvent& rMEvt ); 218 void DPTestMouse( const MouseEvent& rMEvt, sal_Bool bMove ); 219 220 /** 221 * Check if the mouse click is on a field popup button. 222 * 223 * @return bool true if the field popup menu has been launched and no 224 * further mouse event handling is necessary, false otherwise. 225 */ 226 bool DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, ScDPObject* pDPObj); 227 void DPLaunchFieldPopupMenu( 228 const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj); 229 230 void RFMouseMove( const MouseEvent& rMEvt, sal_Bool bUp ); 231 232 void PagebreakMove( const MouseEvent& rMEvt, sal_Bool bUp ); 233 234 void UpdateDragRect( sal_Bool bShowRange, const Rectangle& rPosRect ); 235 236 sal_Bool IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab ); 237 void ExecFilter( sal_uLong nSel, SCCOL nCol, SCROW nRow, 238 const String& aValue, bool bCheckForDates ); 239 void FilterSelect( sal_uLong nSel ); 240 241 void ExecDataSelect( SCCOL nCol, SCROW nRow, const String& rStr ); 242 243 void ExecPageFieldSelect( SCCOL nCol, SCROW nRow, sal_Bool bHasSelection, const String& rStr ); 244 245 sal_Bool HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange ); 246 247 sal_Bool DropScroll( const Point& rMousePos ); 248 249 sal_Int8 AcceptPrivateDrop( const AcceptDropEvent& rEvt ); 250 sal_Int8 ExecutePrivateDrop( const ExecuteDropEvent& rEvt ); 251 sal_Int8 DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY, 252 const Point& rLogicPos, sal_Int8 nDndAction ); 253 254 void HandleMouseButtonDown( const MouseEvent& rMEvt ); 255 256 sal_Bool DrawMouseButtonDown(const MouseEvent& rMEvt); 257 sal_Bool DrawMouseButtonUp(const MouseEvent& rMEvt); 258 sal_Bool DrawMouseMove(const MouseEvent& rMEvt); 259 sal_Bool DrawKeyInput(const KeyEvent& rKEvt); 260 sal_Bool DrawCommand(const CommandEvent& rCEvt); 261 sal_Bool DrawHasMarkedObj(); 262 void DrawEndAction(); 263 void DrawMarkDropObj( SdrObject* pObj ); 264 SdrObject* GetEditObject(); 265 sal_Bool IsMyModel(SdrEditView* pSdrView); 266 //void DrawStartTimer(); 267 268 void DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, sal_uLong nLayer ); 269 void DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev ); 270 //sal_Bool DrawBeforeScroll(); 271 void DrawAfterScroll(/*sal_Bool bVal*/); 272 //void DrawMarks(); 273 //sal_Bool NeedDrawMarks(); 274 void DrawComboButton( const Point& rCellPos, 275 long nCellSizeX, 276 long nCellSizeY, 277 sal_Bool bArrowState, 278 sal_Bool bBtnIn = sal_False ); 279 Rectangle GetListValButtonRect( const ScAddress& rButtonPos ); 280 281 void DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, OutputDevice* pContentDev ); 282 283 sal_Bool GetEditUrl( const Point& rPos, 284 String* pName=0, String* pUrl=0, String* pTarget=0 ); 285 sal_Bool GetEditUrlOrError( sal_Bool bSpellErr, const Point& rPos, 286 String* pName=0, String* pUrl=0, String* pTarget=0 ); 287 288 sal_Bool HitRangeFinder( const Point& rMouse, sal_Bool& rCorner, sal_uInt16* pIndex = NULL, 289 SCsCOL* pAddX = NULL, SCsROW* pAddY = NULL ); 290 291 sal_uInt16 HitPageBreak( const Point& rMouse, ScRange* pSource = NULL, 292 SCCOLROW* pBreak = NULL, SCCOLROW* pPrev = NULL ); 293 294 void PasteSelection( const Point& rPosPixel ); 295 296 void SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY ); 297 298 void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects ); 299 300 protected: 301 using Window::Resize; 302 virtual void Resize( const Size& rSize ); 303 virtual void PrePaint(); 304 virtual void Paint( const Rectangle& rRect ); 305 virtual void KeyInput(const KeyEvent& rKEvt); 306 virtual void GetFocus(); 307 virtual void LoseFocus(); 308 309 virtual void RequestHelp( const HelpEvent& rEvt ); 310 virtual void Command( const CommandEvent& rCEvt ); 311 312 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 313 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 314 virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); 315 316 public: 317 ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos ); 318 ~ScGridWindow(); 319 320 // #i70788# flush and get overlay 321 ::sdr::overlay::OverlayManager* getOverlayManager(); 322 void flushOverlayManager(); 323 324 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 325 326 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 327 virtual void MouseButtonUp( const MouseEvent& rMEvt ); 328 virtual void MouseMove( const MouseEvent& rMEvt ); 329 virtual long PreNotify( NotifyEvent& rNEvt ); 330 virtual void Tracking( const TrackingEvent& rTEvt ); 331 332 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 333 334 void FakeButtonUp(); 335 336 Point GetMousePosPixel() const; 337 void UpdateStatusPosSize(); 338 339 void ClickExtern(); 340 341 void SetPointer( const Pointer& rPointer ); 342 343 void MoveMouseStatus( ScGridWindow &rDestWin ); 344 345 void ScrollPixel( long nDifX, long nDifY ); 346 void UpdateEditViewPos(); 347 348 void UpdateFormulas(); 349 350 void DoAutoFilterMenue( SCCOL nCol, SCROW nRow, sal_Bool bDataSelect ); 351 void DoScenarioMenue( const ScRange& rScenRange ); 352 353 void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow ); 354 void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow ); 355 356 ::com::sun::star::sheet::DataPilotFieldOrientation GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const; 357 358 void DrawButtons( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 359 ScTableInfo& rTabInfo, OutputDevice* pContentDev ); 360 361 using Window::Draw; 362 void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 363 ScUpdateMode eMode = SC_UPDATE_ALL ); 364 365 void InvertSimple( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 366 sal_Bool bTestMerge = sal_False, sal_Bool bRepeat = sal_False ); 367 368 //UNUSED2008-05 void DrawDragRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 ); 369 370 void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress); 371 372 void HideCursor(); 373 void ShowCursor(); 374 void DrawCursor(); 375 void DrawAutoFillMark(); 376 void UpdateAutoFillMark(sal_Bool bMarked, const ScRange& rMarkRange); 377 378 void UpdateListValPos( sal_Bool bVisible, const ScAddress& rPos ); 379 380 sal_Bool ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, sal_Bool bKeyboard ); 381 void HideNoteMarker(); 382 383 MapMode GetDrawMapMode( sal_Bool bForce = sal_False ); 384 385 void ContinueDrag(); 386 387 void StopMarking(); 388 void UpdateInputContext(); 389 390 void CheckInverted() { if (nPaintCount) bNeedsRepaint = sal_True; } 391 392 void DoInvertRect( const Rectangle& rPixel ); 393 394 void CheckNeedsRepaint(); 395 396 void UpdateDPFromFieldPopupMenu(); 397 398 void UpdateVisibleRange(); 399 400 // #114409# 401 void CursorChanged(); 402 void DrawLayerCreated(); 403 404 void DeleteCursorOverlay(); 405 void UpdateCursorOverlay(); 406 void DeleteSelectionOverlay(); 407 void UpdateSelectionOverlay(); 408 void DeleteAutoFillOverlay(); 409 void UpdateAutoFillOverlay(); 410 void DeleteDragRectOverlay(); 411 void UpdateDragRectOverlay(); 412 void DeleteHeaderOverlay(); 413 void UpdateHeaderOverlay(); 414 void DeleteShrinkOverlay(); 415 void UpdateShrinkOverlay(); 416 void UpdateAllOverlays(); 417 418 protected: 419 // #114409# 420 void ImpCreateOverlayObjects(); 421 void ImpDestroyOverlayObjects(); 422 423 }; 424 425 426 427 #endif 428 429