bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / inc / tabview.hxx
blob9b971da8cb96bc81d3ac11516c76be69b39bad2b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef SC_TABVIEW_HXX
20 #define SC_TABVIEW_HXX
22 #include <vcl/scrbar.hxx>
24 #include <sfx2/ipclient.hxx>
26 #include "hiranges.hxx"
27 #include "viewutil.hxx"
28 #include "select.hxx"
30 #include <boost/noncopyable.hpp>
31 #include <boost/scoped_ptr.hpp>
33 class ScEditEngineDefaulter;
34 class ScGridWindow;
35 class ScOutlineWindow;
36 class ScRowBar;
37 class ScColBar;
38 class ScTabControl;
39 class ScTabViewShell;
40 struct ScRangeFindData;
41 class ScDrawView;
42 class SvBorder;
43 class FuPoor;
44 class Splitter;
45 class ScTabSplitter;
46 class SdrView;
47 class SdrObject;
48 class ScHintWindow;
49 class ScPageBreakData;
50 class SdrHdlList;
52 namespace com { namespace sun { namespace star {
53 namespace chart2 { namespace data {
54 struct HighlightedRange;
55 }}}}}
57 #define SC_FORCEMODE_NONE 0xff
59 // ---------------------------------------------------------------------------
60 // Help - Window
62 class ScCornerButton : public Window
64 private:
65 ScViewData* pViewData;
66 bool bAdd;
68 protected:
69 virtual void Paint( const Rectangle& rRect );
70 virtual void Resize();
71 virtual void MouseButtonDown( const MouseEvent& rMEvt );
72 public:
73 ScCornerButton( Window* pParent, ScViewData* pData, bool bAdditional );
74 ~ScCornerButton();
76 virtual void StateChanged( StateChangedType nType );
77 virtual void DataChanged( const DataChangedEvent& rDCEvt );
81 // ---------------------------------------------------------------------------
83 class ScTabView : boost::noncopyable
85 private:
86 enum BlockMode { None = 0, Normal = 1, Own = 2 };
88 Window* pFrameWin; // First !!!
89 ScViewData aViewData; // must be at the front !
91 ScViewSelectionEngine* pSelEngine;
92 ScViewFunctionSet aFunctionSet;
94 ScHeaderSelectionEngine* pHdrSelEng;
95 ScHeaderFunctionSet aHdrFunc;
97 SfxInPlaceClient* pIPClient;
99 ScDrawView* pDrawView;
101 Size aFrameSize; // passed on as for DoResize
102 Point aBorderPos;
104 FuPoor* pDrawActual;
105 FuPoor* pDrawOld;
107 ScGridWindow* pGridWin[4];
108 ScColBar* pColBar[2];
109 ScRowBar* pRowBar[2];
110 ScOutlineWindow* pColOutline[2];
111 ScOutlineWindow* pRowOutline[2];
112 ScTabSplitter* pHSplitter;
113 ScTabSplitter* pVSplitter;
114 ScTabControl* pTabControl;
115 ScrollBar aVScrollTop;
116 ScrollBar aVScrollBottom; // initially visible
117 ScrollBar aHScrollLeft; // initially visible
118 ScrollBar aHScrollRight;
119 ScCornerButton aCornerButton;
120 ScCornerButton aTopButton;
121 ScrollBarBox aScrollBarBox;
123 boost::scoped_ptr<ScHintWindow> mpInputHintWindow; // popup window for data validation
125 ScPageBreakData* pPageBreakData;
126 std::vector<ScHighlightEntry> maHighlightRanges;
128 ScDocument* pBrushDocument; // cell formats for format paint brush
129 SfxItemSet* pDrawBrushSet; // drawing object attributes for paint brush
131 Timer aScrollTimer;
132 ScGridWindow* pTimerWindow;
133 MouseEvent aTimerMEvt;
135 sal_uLong nTipVisible;
137 long nPrevDragPos;
139 BlockMode meBlockMode; // Marks block
141 SCCOL nBlockStartX;
142 SCCOL nBlockStartXOrig;
143 SCCOL nBlockEndX;
145 SCROW nBlockStartY;
146 SCROW nBlockStartYOrig;
147 SCROW nBlockEndY;
149 SCTAB nBlockStartZ;
150 SCTAB nBlockEndZ;
152 SCCOL nOldCurX;
153 SCROW nOldCurY;
155 double mfPendingTabBarWidth; // Tab bar width relative to frame window width.
157 bool bMinimized:1;
158 bool bInUpdateHeader:1;
159 bool bInActivatePart:1;
160 bool bInZoomUpdate:1;
161 bool bMoveIsShift:1;
162 bool bDrawSelMode:1; // Only select draw objects ?
163 bool bLockPaintBrush:1; // keep for more than one use?
164 bool bDragging:1; // for scroll bars
165 bool bBlockNeg:1; // is no longer highlighted?
166 bool bBlockCols:1; // are whole columns selected?
167 bool bBlockRows:1; // are whole rows selected?
169 void Init();
171 void DoAddWin( ScGridWindow* pWin );
173 void InitScrollBar( ScrollBar& rScrollBar, long nMaxVal );
174 DECL_LINK( ScrollHdl, ScrollBar* );
175 DECL_LINK( EndScrollHdl, ScrollBar* );
177 DECL_LINK( SplitHdl, Splitter* );
178 void DoHSplit(long nSplitPos);
179 void DoVSplit(long nSplitPos);
181 DECL_LINK( TimerHdl, void* );
183 void UpdateVarZoom();
185 static void SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, bool bLayoutRTL );
186 static long GetScrollBarPos( ScrollBar& rScroll );
188 void GetPageMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, SCsCOL& rPageX, SCsROW& rPageY);
189 void GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
190 SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode);
192 void SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX);
193 void SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY);
197 * @brief Update marks for a selected Range. This is a helper function
198 * for PaintRangeFinder.
200 * @param pData: Range to update for painting.
201 * @param nTab: Current tab.
205 void PaintRangeFinderEntry (ScRangeFindData* pData, SCTAB nTab);
207 protected:
208 void UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
209 const SCROW* pPosY = NULL );
211 void HideTip();
212 void ShowRefTip();
214 void ZoomChanged();
215 void UpdateShow();
216 void UpdateVisibleRange();
217 void GetBorderSize( SvBorder& rBorder, const Size& rSize );
219 void ResetDrawDragMode();
220 bool IsDrawTextEdit() const;
221 void DrawEnableAnim(bool bSet);
223 void MakeDrawView( sal_uInt8 nForceDesignMode = SC_FORCEMODE_NONE );
225 void HideNoteMarker();
227 void UpdateIMap( SdrObject* pObj );
229 public:
230 ScTabView( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
231 ~ScTabView();
233 void MakeDrawLayer();
235 void HideListBox();
237 bool HasHintWindow() const;
238 void RemoveHintWindow();
239 void TestHintWindow();
242 DECL_LINK( TabBarResize, void* );
243 /** Sets an absolute tab bar width (in pixels). */
244 void SetTabBarWidth( long nNewWidth );
245 /** Sets a relative tab bar width.
246 @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */
247 SC_DLLPUBLIC void SetRelTabBarWidth( double fRelTabBarWidth );
248 /** Sets a relative tab bar width. Tab bar is resized again in next DoResize().
249 @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */
250 void SetPendingRelTabBarWidth( double fRelTabBarWidth );
251 /** Returns the current tab bar width in pixels. */
252 long GetTabBarWidth() const;
253 /** Returns the current tab bar width relative to the frame window width (0.0 ... 1.0). */
254 SC_DLLPUBLIC double GetRelTabBarWidth() const;
255 /** Returns the pending tab bar width relative to the frame window width (0.0 ... 1.0). */
256 double GetPendingRelTabBarWidth() const;
258 void DoResize( const Point& rOffset, const Size& rSize, bool bInner = false );
259 void RepeatResize( bool bUpdateFix = true );
260 void UpdateFixPos();
261 Point GetGridOffset() const;
263 bool IsDrawSelMode() const { return bDrawSelMode; }
264 void SetDrawSelMode(bool bNew) { bDrawSelMode = bNew; }
266 void SetDrawFuncPtr(FuPoor* pFuncPtr) { pDrawActual = pFuncPtr; }
267 void SetDrawFuncOldPtr(FuPoor* pFuncPtr) { pDrawOld = pFuncPtr; }
268 FuPoor* GetDrawFuncPtr() { return pDrawActual; }
269 FuPoor* GetDrawFuncOldPtr() { return pDrawOld; }
271 void DrawDeselectAll();
272 void DrawMarkListHasChanged();
273 void UpdateAnchorHandles();
275 ScPageBreakData* GetPageBreakData() { return pPageBreakData; }
276 const std::vector<ScHighlightEntry>& GetHighlightRanges() { return maHighlightRanges; }
278 void UpdatePageBreakData( bool bForcePaint = false );
280 void DrawMarkRect( const Rectangle& rRect );
282 ScViewData* GetViewData() { return &aViewData; }
283 const ScViewData* GetViewData() const { return &aViewData; }
285 ScViewFunctionSet* GetFunctionSet() { return &aFunctionSet; }
286 ScViewSelectionEngine* GetSelEngine() { return pSelEngine; }
288 bool SelMouseButtonDown( const MouseEvent& rMEvt );
290 ScDrawView* GetScDrawView() { return pDrawView; }
291 SdrView* GetSdrView(); // gegen CLOKs
293 bool IsMinimized() const { return bMinimized; }
296 * Called after moving, copying, inserting or deleting a sheet.
298 * @param bSameTabButMoved true if the same sheet as before is activated.
300 void TabChanged( bool bSameTabButMoved = false );
301 void SetZoom( const Fraction& rNewX, const Fraction& rNewY, bool bAll );
302 SC_DLLPUBLIC void RefreshZoom();
303 void SetPagebreakMode( bool bSet );
305 void UpdateLayerLocks();
307 void UpdateDrawTextOutliner();
308 void DigitLanguageChanged();
310 void UpdateInputLine();
312 void InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eType,
313 bool bPaint = true );
314 void DoneRefMode( bool bContinue = false );
315 void UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ );
316 void StopRefMode();
318 void StopMarking();
319 void FakeButtonUp( ScSplitPos eWhich );
321 Window* GetActiveWin();
322 Window* GetWindowByPos( ScSplitPos ePos );
324 ScSplitPos FindWindow( Window* pWindow ) const;
326 void SetActivePointer( const Pointer& rPointer );
328 void ActiveGrabFocus();
330 void ClickCursor( SCCOL nPosX, SCROW nPosY, bool bControl );
332 SC_DLLPUBLIC void SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew = false );
334 SC_DLLPUBLIC void CellContentChanged();
335 void SelectionChanged();
336 void CursorPosChanged();
337 void UpdateInputContext();
339 void CheckSelectionTransfer();
341 void InvertHorizontal( ScVSplitPos eWhich, long nDragPos );
342 void InvertVertical( ScHSplitPos eWhich, long nDragPos );
344 Point GetInsertPos();
346 Point GetChartInsertPos( const Size& rSize, const ScRange& rCellRange );
347 Point GetChartDialogPos( const Size& rDialogSize, const Rectangle& rLogicChart );
349 void UpdateAutoFillMark();
351 void ShowCursor();
352 void HideAllCursors();
353 void ShowAllCursors();
355 void AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
356 const ScSplitPos* pWhich = NULL );
358 SvxZoomType GetZoomType() const;
359 void SetZoomType( SvxZoomType eNew, bool bAll );
360 sal_uInt16 CalcZoom( SvxZoomType eType, sal_uInt16 nOldZoom );
362 bool HasPageFieldDataAtCursor() const;
363 void StartDataSelect();
365 // MoveCursorAbs - absolute
366 // MoveCursorRel - single cells
367 // MoveCursorPage - screen
368 // MoveCursorArea - Data block
369 // MoveCursorEnd - top left / user range
371 SC_DLLPUBLIC void MoveCursorAbs( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
372 bool bShift, bool bControl,
373 bool bKeepOld = false, bool bKeepSel = false );
374 void MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
375 bool bShift, bool bKeepSel = false );
376 void MoveCursorPage( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
377 bool bShift, bool bKeepSel = false );
378 void MoveCursorArea( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
379 bool bShift, bool bKeepSel = false );
380 void MoveCursorEnd( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
381 bool bShift, bool bKeepSel = false );
382 void MoveCursorScreen( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift );
384 void MoveCursorEnter( bool bShift ); // Shift for direction (select nothing)
386 bool MoveCursorKeyInput( const KeyEvent& rKeyEvent );
388 void FindNextUnprot( bool bShift, bool bInSelection = true );
390 SC_DLLPUBLIC void SetTabNo( SCTAB nTab, bool bNew = false, bool bExtendSelection = false, bool bSameTabButMoved = false );
391 void SelectNextTab( short nDir, bool bExtendSelection = false );
393 void ActivateView( bool bActivate, bool bFirst );
394 void ActivatePart( ScSplitPos eWhich );
395 bool IsInActivatePart() const { return bInActivatePart; }
397 void SetTimer( ScGridWindow* pWin, const MouseEvent& rMEvt );
398 void ResetTimer();
400 void ScrollX( long nDeltaX, ScHSplitPos eWhich, bool bUpdBars = true );
401 void ScrollY( long nDeltaY, ScVSplitPos eWhich, bool bUpdBars = true );
402 SC_DLLPUBLIC void ScrollLines( long nDeltaX, long nDeltaY ); // active
404 bool ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos );
406 void ScrollToObject( SdrObject* pDrawObj );
407 void MakeVisible( const Rectangle& rHMMRect );
409 // Zeichnen
411 void PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
412 ScUpdateMode eMode = SC_UPDATE_ALL );
414 void PaintGrid();
416 void PaintTopArea( SCCOL nStartCol, SCCOL nEndCol );
417 void PaintTop();
419 void PaintLeftArea( SCROW nStartRow, SCROW nEndRow );
420 void PaintLeft();
422 bool PaintExtras();
424 void RecalcPPT();
426 void CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress);
428 void UpdateCopySourceOverlay();
429 void UpdateSelectionOverlay();
430 void UpdateShrinkOverlay();
431 void UpdateAllOverlays();
433 void UpdateFormulas();
434 void InterpretVisible();
435 void CheckNeedsRepaint();
437 void PaintRangeFinder( long nNumber = -1 );
438 void AddHighlightRange( const ScRange& rRange, const Color& rColor );
439 void ClearHighlightRanges();
441 void DoChartSelection( const ::com::sun::star::uno::Sequence<
442 ::com::sun::star::chart2::data::HighlightedRange > & rHilightRanges );
444 long GetGridWidth( ScHSplitPos eWhich );
445 long GetGridHeight( ScVSplitPos eWhich );
447 void UpdateScrollBars();
448 void SetNewVisArea();
450 void InvalidateAttribs();
452 void MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow );
453 void KillEditView( bool bNoPaint );
454 void UpdateEditView();
457 // Blocks
459 void SelectAll( bool bContinue = false );
460 void SelectAllTables();
461 void DeselectAllTables();
463 void MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
464 bool bCols = false, bool bRows = false, bool bCellSelection = false );
465 void InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
466 bool bTestNeg = false,
467 bool bCols = false, bool bRows = false );
468 void InitOwnBlockMode();
469 void DoneBlockMode( bool bContinue = false );
471 bool IsBlockMode() const;
473 void ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode);
474 void ExpandBlockPage(SCsCOL nMovX, SCsROW nMovY);
475 void ExpandBlockArea(SCsCOL nMovX, SCsROW nMovY);
477 void MarkColumns();
478 void MarkRows();
479 void MarkDataArea( bool bIncludeCursor = true );
480 void MarkMatrixFormula();
481 void Unmark();
483 void MarkRange( const ScRange& rRange, bool bSetCursor = true, bool bContinue = false );
485 bool IsMarking( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
487 void PaintMarks( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
488 void PaintBlock( bool bReset = false );
490 void SetMarkData( const ScMarkData& rNew );
491 void MarkDataChanged();
493 void LockModifiers( sal_uInt16 nModifiers );
494 sal_uInt16 GetLockedModifiers() const;
495 void ViewOptionsHasChanged( bool bHScrollChanged,
496 bool bGraphicsChanged = false);
498 Point GetMousePosPixel();
500 void SnapSplitPos( Point& rScreenPosPixel );
501 void FreezeSplitters( bool bFreeze );
502 void RemoveSplit();
503 void SplitAtCursor();
504 void SplitAtPixel( const Point& rPixel, bool bHor, bool bVer );
505 void InvalidateSplit();
507 void ErrorMessage( sal_uInt16 nGlobStrId );
508 Window* GetParentOrChild( sal_uInt16 nChildId );
510 void EnableRefInput(bool bFlag = true);
512 Window* GetFrameWin() const { return pFrameWin; }
514 bool HasPaintBrush() const { return pBrushDocument || pDrawBrushSet; }
515 ScDocument* GetBrushDocument() const { return pBrushDocument; }
516 SfxItemSet* GetDrawBrushSet() const { return pDrawBrushSet; }
517 bool IsPaintBrushLocked() const { return bLockPaintBrush; }
518 void SetBrushDocument( ScDocument* pNew, bool bLock );
519 void SetDrawBrushSet( SfxItemSet* pNew, bool bLock );
520 void ResetBrushDocument();
522 void SetInRefMode( bool bRefMode );
527 #endif
529 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */