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 #ifndef SC_TABVIEW_HXX 28 #define SC_TABVIEW_HXX 29 30 #include <vcl/scrbar.hxx> 31 32 //REMOVE #ifndef SO2_DECL_SVINPLACECLIENT_DEFINED 33 //REMOVE #define SO2_DECL_SVINPLACECLIENT_DEFINED 34 //REMOVE SO2_DECL_REF(SvInPlaceClient) 35 //REMOVE #endif 36 37 #include <sfx2/ipclient.hxx> 38 39 #include "viewutil.hxx" 40 #include "select.hxx" 41 42 class ScEditEngineDefaulter; 43 class ScGridWindow; 44 class ScOutlineWindow; 45 class ScRowBar; 46 class ScColBar; 47 class ScTabControl; 48 class ScTabViewShell; 49 class SfxPrinter; 50 class ScDrawView; 51 class SvBorder; 52 class FuPoor; 53 class Splitter; 54 class ScTabSplitter; 55 class SdrView; 56 class SdrObject; 57 class ScHintWindow; 58 class ScPageBreakData; 59 class ScHighlightRanges; 60 struct ChartSelectionInfo; 61 class SdrHdlList; 62 63 namespace com { namespace sun { namespace star { 64 namespace chart2 { namespace data { 65 struct HighlightedRange; 66 }}}}} 67 68 #define SPLIT_HANDLE_SIZE 3 69 #define SC_FORCEMODE_NONE 0xff 70 71 // --------------------------------------------------------------------------- 72 // Hilfs - Fenster 73 74 class ScCornerButton : public Window 75 { 76 private: 77 ScViewData* pViewData; 78 sal_Bool bAdd; 79 80 protected: 81 virtual void Paint( const Rectangle& rRect ); 82 virtual void Resize(); 83 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 84 public: 85 ScCornerButton( Window* pParent, ScViewData* pData, sal_Bool bAdditional ); 86 ~ScCornerButton(); 87 88 virtual void StateChanged( StateChangedType nType ); 89 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 90 }; 91 92 93 // --------------------------------------------------------------------------- 94 95 class ScTabView 96 { 97 private: 98 Window* pFrameWin; // als erstes !!! 99 ScViewData aViewData; // muss ganz vorne stehen ! 100 101 ScViewSelectionEngine* pSelEngine; 102 ScViewFunctionSet aFunctionSet; 103 104 ScHeaderSelectionEngine* pHdrSelEng; 105 ScHeaderFunctionSet aHdrFunc; 106 107 SfxInPlaceClient* pIPClient; 108 109 ScDrawView* pDrawView; 110 111 Size aFrameSize; // wie bei DoResize uebergeben 112 Point aBorderPos; 113 114 sal_Bool bDrawSelMode; // nur Zeichenobjekte selektieren ? 115 116 FuPoor* pDrawActual; 117 FuPoor* pDrawOld; 118 119 ScGridWindow* pGridWin[4]; 120 ScColBar* pColBar[2]; 121 ScRowBar* pRowBar[2]; 122 ScOutlineWindow* pColOutline[2]; 123 ScOutlineWindow* pRowOutline[2]; 124 ScTabSplitter* pHSplitter; 125 ScTabSplitter* pVSplitter; 126 ScTabControl* pTabControl; 127 ScrollBar aVScrollTop; 128 ScrollBar aVScrollBottom; // anfangs sichtbar 129 ScrollBar aHScrollLeft; // anfangs sichtbar 130 ScrollBar aHScrollRight; 131 ScCornerButton aCornerButton; 132 ScCornerButton aTopButton; 133 ScrollBarBox aScrollBarBox; 134 135 ScHintWindow* pInputHintWindow; // Eingabemeldung bei Gueltigkeit 136 137 ScPageBreakData* pPageBreakData; // fuer Seitenumbruch-Modus 138 ScHighlightRanges* pHighlightRanges; 139 140 ScDocument* pBrushDocument; // cell formats for format paint brush 141 SfxItemSet* pDrawBrushSet; // drawing object attributes for paint brush 142 sal_Bool bLockPaintBrush; // keep for more than one use? 143 144 Timer aScrollTimer; 145 ScGridWindow* pTimerWindow; 146 MouseEvent aTimerMEvt; 147 148 sal_uLong nTipVisible; 149 150 sal_Bool bDragging; // fuer Scrollbars 151 long nPrevDragPos; 152 153 sal_Bool bIsBlockMode; // Block markieren 154 sal_Bool bBlockNeg; // wird Markierung aufgehoben? 155 sal_Bool bBlockCols; // werden ganze Spalten markiert? 156 sal_Bool bBlockRows; // werden ganze Zeilen markiert? 157 158 SCCOL nBlockStartX; 159 SCCOL nBlockStartXOrig; 160 SCCOL nBlockEndX; 161 162 SCROW nBlockStartY; 163 SCROW nBlockStartYOrig; 164 SCROW nBlockEndY; 165 166 SCTAB nBlockStartZ; 167 SCTAB nBlockEndZ; 168 169 SCCOL nOldCurX; 170 SCROW nOldCurY; 171 172 double mfPendingTabBarWidth; // Tab bar width relative to frame window width. 173 174 sal_Bool bMinimized; 175 sal_Bool bInUpdateHeader; 176 sal_Bool bInActivatePart; 177 sal_Bool bInZoomUpdate; 178 sal_Bool bMoveIsShift; 179 sal_Bool bNewStartIfMarking; 180 181 void Init(); 182 183 void DoAddWin( ScGridWindow* pWin ); 184 185 void InitScrollBar( ScrollBar& rScrollBar, long nMaxVal ); 186 DECL_LINK( ScrollHdl, ScrollBar* ); 187 DECL_LINK( EndScrollHdl, ScrollBar* ); 188 189 DECL_LINK( SplitHdl, Splitter* ); 190 void DoHSplit(long nSplitPos); 191 void DoVSplit(long nSplitPos); 192 193 DECL_LINK( TimerHdl, Timer* ); 194 195 void UpdateVarZoom(); 196 197 void UpdateVisibleRange(); 198 199 static void SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, sal_Bool bLayoutRTL ); 200 static long GetScrollBarPos( ScrollBar& rScroll, sal_Bool bLayoutRTL ); 201 202 protected: 203 void UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL, 204 const SCROW* pPosY = NULL ); 205 206 void HideTip(); 207 void ShowRefTip(); 208 209 void ZoomChanged(); 210 void UpdateShow(); 211 void GetBorderSize( SvBorder& rBorder, const Size& rSize ); 212 213 void ResetDrawDragMode(); 214 sal_Bool IsDrawTextEdit() const; 215 void DrawEnableAnim(sal_Bool bSet); 216 //HMHvoid DrawShowMarkHdl(sal_Bool bShow); 217 218 void MakeDrawView( sal_uInt8 nForceDesignMode = SC_FORCEMODE_NONE ); 219 220 void HideNoteMarker(); 221 222 void UpdateIMap( SdrObject* pObj ); 223 224 public: 225 ScTabView( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ); 226 //UNUSED2009-05 ScTabView( Window* pParent, const ScTabView& rScTabView, ScTabViewShell* pViewShell ); 227 ~ScTabView(); 228 229 void MakeDrawLayer(); 230 231 void HideListBox(); 232 233 sal_Bool HasHintWindow() const { return pInputHintWindow != NULL; } 234 void RemoveHintWindow(); 235 void TestHintWindow(); 236 237 238 DECL_LINK( TabBarResize, void* ); 239 /** Sets an absolute tab bar width (in pixels). */ 240 void SetTabBarWidth( long nNewWidth ); 241 /** Sets a relative tab bar width. 242 @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */ 243 void SetRelTabBarWidth( double fRelTabBarWidth ); 244 /** Sets a relative tab bar width. Tab bar is resized again in next DoResize(). 245 @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */ 246 void SetPendingRelTabBarWidth( double fRelTabBarWidth ); 247 /** Returns the current tab bar width in pixels. */ 248 long GetTabBarWidth() const; 249 /** Returns the current tab bar width relative to the frame window width (0.0 ... 1.0). */ 250 double GetRelTabBarWidth() const; 251 /** Returns the pending tab bar width relative to the frame window width (0.0 ... 1.0). */ 252 double GetPendingRelTabBarWidth() const; 253 254 void DoResize( const Point& rOffset, const Size& rSize, sal_Bool bInner = sal_False ); 255 void RepeatResize( sal_Bool bUpdateFix = sal_True ); 256 void UpdateFixPos(); 257 Point GetGridOffset() const; 258 259 sal_Bool IsDrawSelMode() const { return bDrawSelMode; } 260 void SetDrawSelMode(sal_Bool bNew) { bDrawSelMode = bNew; } 261 262 void SetDrawFuncPtr(FuPoor* pFuncPtr) { pDrawActual = pFuncPtr; } 263 void SetDrawFuncOldPtr(FuPoor* pFuncPtr) { pDrawOld = pFuncPtr; } 264 FuPoor* GetDrawFuncPtr() { return pDrawActual; } 265 FuPoor* GetDrawFuncOldPtr() { return pDrawOld; } 266 267 void DrawDeselectAll(); 268 void DrawMarkListHasChanged(); 269 void UpdateAnchorHandles(); 270 //UNUSED2008-05 String GetSelectedChartName() const; 271 272 ScPageBreakData* GetPageBreakData() { return pPageBreakData; } 273 ScHighlightRanges* GetHighlightRanges() { return pHighlightRanges; } 274 275 void UpdatePageBreakData( sal_Bool bForcePaint = sal_False ); 276 277 void DrawMarkRect( const Rectangle& rRect ); 278 279 ScViewData* GetViewData() { return &aViewData; } 280 const ScViewData* GetViewData() const { return &aViewData; } 281 282 ScViewFunctionSet* GetFunctionSet() { return &aFunctionSet; } 283 ScViewSelectionEngine* GetSelEngine() { return pSelEngine; } 284 285 sal_Bool SelMouseButtonDown( const MouseEvent& rMEvt ); 286 287 ScDrawView* GetScDrawView() { return pDrawView; } 288 SdrView* GetSdrView(); // gegen CLOKs 289 290 sal_Bool IsMinimized() const { return bMinimized; } 291 292 // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet 293 void TabChanged( bool bSameTabButMoved = false ); 294 void SetZoom( const Fraction& rNewX, const Fraction& rNewY, sal_Bool bAll ); 295 SC_DLLPUBLIC void RefreshZoom(); 296 void SetPagebreakMode( sal_Bool bSet ); 297 298 void UpdateLayerLocks(); 299 300 void UpdateDrawTextOutliner(); 301 void DigitLanguageChanged(); 302 303 void UpdateInputLine(); 304 305 void InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eType, 306 sal_Bool bPaint = sal_True ); 307 void DoneRefMode( sal_Bool bContinue = sal_False ); 308 void UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ ); 309 void StopRefMode(); 310 311 //UNUSED2008-05 void EndSelection(); 312 void StopMarking(); 313 void FakeButtonUp( ScSplitPos eWhich ); 314 315 Window* GetActiveWin(); 316 Window* GetWindowByPos( ScSplitPos ePos ); 317 318 ScSplitPos FindWindow( Window* pWindow ) const; 319 320 void SetActivePointer( const Pointer& rPointer ); 321 //UNUSED2008-05 void SetActivePointer( const ResId& rId ); 322 323 void ActiveGrabFocus(); 324 //UNUSED2008-05 void ActiveCaptureMouse(); 325 //UNUSED2008-05 void ActiveReleaseMouse(); 326 //UNUSED2008-05 Point ActivePixelToLogic( const Point& rDevicePoint ); 327 328 void ClickCursor( SCCOL nPosX, SCROW nPosY, sal_Bool bControl ); 329 330 SC_DLLPUBLIC void SetCursor( SCCOL nPosX, SCROW nPosY, sal_Bool bNew = sal_False ); 331 332 SC_DLLPUBLIC void CellContentChanged(); 333 void SelectionChanged(); 334 void CursorPosChanged(); 335 void UpdateInputContext(); 336 337 void CheckSelectionTransfer(); 338 339 void InvertHorizontal( ScVSplitPos eWhich, long nDragPos ); 340 void InvertVertical( ScHSplitPos eWhich, long nDragPos ); 341 342 Point GetInsertPos(); 343 344 Point GetChartInsertPos( const Size& rSize, const ScRange& rCellRange ); 345 Point GetChartDialogPos( const Size& rDialogSize, const Rectangle& rLogicChart ); 346 347 void UpdateAutoFillMark(); 348 349 void HideCursor(); // nur aktiver Teil 350 void ShowCursor(); 351 void HideAllCursors(); 352 void ShowAllCursors(); 353 354 void AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode, 355 const ScSplitPos* pWhich = NULL ); 356 357 SvxZoomType GetZoomType() const; 358 void SetZoomType( SvxZoomType eNew, sal_Bool bAll ); 359 sal_uInt16 CalcZoom( SvxZoomType eType, sal_uInt16 nOldZoom ); 360 361 // void CalcZoom( SvxZoomType eType, sal_uInt16& rZoom, SCCOL& rCol, SCROW& rRow ); 362 363 sal_Bool HasPageFieldDataAtCursor() const; 364 void StartDataSelect(); 365 366 // MoveCursorAbs - absolut 367 // MoveCursorRel - einzelne Zellen 368 // MoveCursorPage - Bildschirmseite 369 // MoveCursorArea - Datenblock 370 // MoveCursorEnd - links oben / benutzter Bereich 371 372 SC_DLLPUBLIC void MoveCursorAbs( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode, 373 sal_Bool bShift, sal_Bool bControl, 374 sal_Bool bKeepOld = sal_False, sal_Bool bKeepSel = sal_False ); 375 void MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, 376 sal_Bool bShift, sal_Bool bKeepSel = sal_False ); 377 void MoveCursorPage( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, 378 sal_Bool bShift, sal_Bool bKeepSel = sal_False ); 379 void MoveCursorArea( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, 380 sal_Bool bShift, sal_Bool bKeepSel = sal_False ); 381 void MoveCursorEnd( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, 382 sal_Bool bShift, sal_Bool bKeepSel = sal_False ); 383 void MoveCursorScreen( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, sal_Bool bShift ); 384 385 void MoveCursorEnter( sal_Bool bShift ); // Shift fuer Richtung (kein Markieren) 386 387 sal_Bool MoveCursorKeyInput( const KeyEvent& rKeyEvent ); 388 389 void FindNextUnprot( sal_Bool bShift, sal_Bool bInSelection = sal_True ); 390 391 void SetNewStartIfMarking(); 392 393 // bSameTabButMoved = true if the same sheet as before is activated, used after moving/copying/inserting/deleting a sheet 394 SC_DLLPUBLIC void SetTabNo( SCTAB nTab, sal_Bool bNew = sal_False, sal_Bool bExtendSelection = sal_False, bool bSameTabButMoved = false ); 395 void SelectNextTab( short nDir, sal_Bool bExtendSelection = sal_False ); 396 397 void ActivateView( sal_Bool bActivate, sal_Bool bFirst ); 398 void ActivatePart( ScSplitPos eWhich ); 399 sal_Bool IsInActivatePart() const { return bInActivatePart; } 400 401 void SetTimer( ScGridWindow* pWin, const MouseEvent& rMEvt ); 402 void ResetTimer(); 403 404 void ScrollX( long nDeltaX, ScHSplitPos eWhich, sal_Bool bUpdBars = sal_True ); 405 void ScrollY( long nDeltaY, ScVSplitPos eWhich, sal_Bool bUpdBars = sal_True ); 406 SC_DLLPUBLIC void ScrollLines( long nDeltaX, long nDeltaY ); // aktives 407 408 sal_Bool ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ); 409 410 void ScrollToObject( SdrObject* pDrawObj ); 411 void MakeVisible( const Rectangle& rHMMRect ); 412 413 // Zeichnen 414 415 void InvertBlockMark(SCCOL nBlockStartX, SCROW nBlockStartY, 416 SCCOL nBlockEndX, SCROW nBlockEndY); 417 418 //UNUSED2008-05 void DrawDragRect( SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, 419 //UNUSED2008-05 ScSplitPos ePos ); 420 //UNUSED2008-05 void PaintCell( SCCOL nCol, SCROW nRow, SCTAB nTab ); 421 //UNUSED2008-05 void PaintLeftRow( SCROW nRow ); 422 //UNUSED2008-05 void PaintTopCol( SCCOL nCol ); 423 424 void PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, 425 ScUpdateMode eMode = SC_UPDATE_ALL ); 426 427 void PaintGrid(); 428 429 void PaintTopArea( SCCOL nStartCol, SCCOL nEndCol ); 430 void PaintTop(); 431 432 void PaintLeftArea( SCROW nStartRow, SCROW nEndRow ); 433 void PaintLeft(); 434 435 sal_Bool PaintExtras(); 436 437 void RecalcPPT(); 438 439 void CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress); 440 441 void UpdateSelectionOverlay(); 442 void UpdateShrinkOverlay(); 443 void UpdateAllOverlays(); 444 445 void UpdateFormulas(); 446 void InterpretVisible(); 447 void CheckNeedsRepaint(); 448 449 void PaintRangeFinder( long nNumber = -1 ); 450 void AddHighlightRange( const ScRange& rRange, const Color& rColor ); 451 void ClearHighlightRanges(); 452 453 void DoChartSelection( const ::com::sun::star::uno::Sequence< 454 ::com::sun::star::chart2::data::HighlightedRange > & rHilightRanges ); 455 456 long GetGridWidth( ScHSplitPos eWhich ); 457 long GetGridHeight( ScVSplitPos eWhich ); 458 459 void UpdateScrollBars(); 460 void SetNewVisArea(); 461 462 void InvalidateAttribs(); 463 464 void MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow ); 465 void KillEditView( sal_Bool bNoPaint ); 466 void UpdateEditView(); 467 468 469 // Bloecke 470 471 void SelectAll( sal_Bool bContinue = sal_False ); 472 void SelectAllTables(); 473 void DeselectAllTables(); 474 475 void MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, 476 sal_Bool bCols = sal_False, sal_Bool bRows = sal_False, sal_Bool bCellSelection = sal_False ); 477 void InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, 478 sal_Bool bTestNeg = sal_False, 479 sal_Bool bCols = sal_False, sal_Bool bRows = sal_False ); 480 void InitOwnBlockMode(); 481 void DoneBlockMode( sal_Bool bContinue = sal_False ); 482 483 sal_Bool IsBlockMode() const { return bIsBlockMode; } 484 485 void MarkColumns(); 486 void MarkRows(); 487 void MarkDataArea( sal_Bool bIncludeCursor = sal_True ); 488 void MarkMatrixFormula(); 489 void Unmark(); 490 491 void MarkRange( const ScRange& rRange, sal_Bool bSetCursor = sal_True, sal_Bool bContinue = sal_False ); 492 493 sal_Bool IsMarking( SCCOL nCol, SCROW nRow, SCTAB nTab ) const; 494 495 void PaintMarks( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ); 496 void PaintBlock( sal_Bool bReset = sal_False ); 497 498 void SetMarkData( const ScMarkData& rNew ); 499 void MarkDataChanged(); 500 501 void LockModifiers( sal_uInt16 nModifiers ); 502 sal_uInt16 GetLockedModifiers() const; 503 void ViewOptionsHasChanged( sal_Bool bHScrollChanged, 504 sal_Bool bGraphicsChanged = sal_False); 505 506 Point GetMousePosPixel(); 507 508 void SnapSplitPos( Point& rScreenPosPixel ); 509 void FreezeSplitters( sal_Bool bFreeze ); 510 void RemoveSplit(); 511 void SplitAtCursor(); 512 void SplitAtPixel( const Point& rPixel, sal_Bool bHor, sal_Bool bVer ); 513 void InvalidateSplit(); 514 515 void ErrorMessage( sal_uInt16 nGlobStrId ); 516 Window* GetParentOrChild( sal_uInt16 nChildId ); 517 518 void EnableRefInput(sal_Bool bFlag=sal_True); 519 520 Window* GetFrameWin() const { return pFrameWin; } 521 522 sal_Bool HasPaintBrush() const { return pBrushDocument || pDrawBrushSet; } 523 ScDocument* GetBrushDocument() const { return pBrushDocument; } 524 SfxItemSet* GetDrawBrushSet() const { return pDrawBrushSet; } 525 sal_Bool IsPaintBrushLocked() const { return bLockPaintBrush; } 526 void SetBrushDocument( ScDocument* pNew, sal_Bool bLock ); 527 void SetDrawBrushSet( SfxItemSet* pNew, sal_Bool bLock ); 528 void ResetBrushDocument(); 529 }; 530 531 532 533 #endif 534 535