1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
30 #include <boost/noncopyable.hpp>
31 #include <boost/scoped_ptr.hpp>
34 struct MisspellRanges
;
37 class ScEditEngineDefaulter
;
39 class ScOutlineWindow
;
44 struct ScRangeFindData
;
53 class ScPageBreakData
;
56 namespace com
{ namespace sun
{ namespace star
{
57 namespace chart2
{ namespace data
{
58 struct HighlightedRange
;
61 #define SC_FORCEMODE_NONE 0xff
63 // ---------------------------------------------------------------------------
66 class ScCornerButton
: public Window
69 ScViewData
* pViewData
;
73 virtual void Paint( const Rectangle
& rRect
);
74 virtual void Resize();
75 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
77 ScCornerButton( Window
* pParent
, ScViewData
* pData
, bool bAdditional
);
80 virtual void StateChanged( StateChangedType nType
);
81 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
85 // ---------------------------------------------------------------------------
87 class ScTabView
: boost::noncopyable
90 enum BlockMode
{ None
= 0, Normal
= 1, Own
= 2 };
92 Window
* pFrameWin
; // First !!!
93 ScViewData aViewData
; // must be at the front !
95 ScViewSelectionEngine
* pSelEngine
;
96 ScViewFunctionSet aFunctionSet
;
98 ScHeaderSelectionEngine
* pHdrSelEng
;
99 ScHeaderFunctionSet aHdrFunc
;
101 SfxInPlaceClient
* pIPClient
;
103 ScDrawView
* pDrawView
;
105 Size aFrameSize
; // passed on as for DoResize
111 ScGridWindow
* pGridWin
[4];
112 ScColBar
* pColBar
[2];
113 ScRowBar
* pRowBar
[2];
114 ScOutlineWindow
* pColOutline
[2];
115 ScOutlineWindow
* pRowOutline
[2];
116 ScTabSplitter
* pHSplitter
;
117 ScTabSplitter
* pVSplitter
;
118 ScTabControl
* pTabControl
;
119 ScrollBar aVScrollTop
;
120 ScrollBar aVScrollBottom
; // initially visible
121 ScrollBar aHScrollLeft
; // initially visible
122 ScrollBar aHScrollRight
;
123 ScCornerButton aCornerButton
;
124 ScCornerButton aTopButton
;
125 ScrollBarBox aScrollBarBox
;
127 boost::scoped_ptr
<ScHintWindow
> mpInputHintWindow
; // popup window for data validation
129 ScPageBreakData
* pPageBreakData
;
130 std::vector
<ScHighlightEntry
> maHighlightRanges
;
132 ScDocument
* pBrushDocument
; // cell formats for format paint brush
133 SfxItemSet
* pDrawBrushSet
; // drawing object attributes for paint brush
136 ScGridWindow
* pTimerWindow
;
137 MouseEvent aTimerMEvt
;
139 sal_uLong nTipVisible
;
143 BlockMode meBlockMode
; // Marks block
146 SCCOL nBlockStartXOrig
;
150 SCROW nBlockStartYOrig
;
159 double mfPendingTabBarWidth
; // Tab bar width relative to frame window width.
162 bool bInUpdateHeader
:1;
163 bool bInActivatePart
:1;
164 bool bInZoomUpdate
:1;
166 bool bDrawSelMode
:1; // Only select draw objects ?
167 bool bLockPaintBrush
:1; // keep for more than one use?
168 bool bDragging
:1; // for scroll bars
169 bool bBlockNeg
:1; // is no longer highlighted?
170 bool bBlockCols
:1; // are whole columns selected?
171 bool bBlockRows
:1; // are whole rows selected?
175 void DoAddWin( ScGridWindow
* pWin
);
177 void InitScrollBar( ScrollBar
& rScrollBar
, long nMaxVal
);
178 DECL_LINK( ScrollHdl
, ScrollBar
* );
179 DECL_LINK( EndScrollHdl
, ScrollBar
* );
181 DECL_LINK( SplitHdl
, Splitter
* );
182 void DoHSplit(long nSplitPos
);
183 void DoVSplit(long nSplitPos
);
185 DECL_LINK( TimerHdl
, void* );
187 void UpdateVarZoom();
189 static void SetScrollBar( ScrollBar
& rScroll
, long nRangeMax
, long nVisible
, long nPos
, bool bLayoutRTL
);
190 static long GetScrollBarPos( ScrollBar
& rScroll
);
192 void GetPageMoveEndPosition(SCsCOL nMovX
, SCsROW nMovY
, SCsCOL
& rPageX
, SCsROW
& rPageY
);
193 void GetAreaMoveEndPosition(SCsCOL nMovX
, SCsROW nMovY
, ScFollowMode eMode
,
194 SCsCOL
& rAreaX
, SCsROW
& rAreaY
, ScFollowMode
& rMode
);
196 void SkipCursorHorizontal(SCsCOL
& rCurX
, SCsROW
& rCurY
, SCsCOL nOldX
, SCsROW nMovX
);
197 void SkipCursorVertical(SCsCOL
& rCurX
, SCsROW
& rCurY
, SCsROW nOldY
, SCsROW nMovY
);
201 * @brief Update marks for a selected Range. This is a helper function
202 * for PaintRangeFinder.
204 * @param pData: Range to update for painting.
205 * @param nTab: Current tab.
209 void PaintRangeFinderEntry (ScRangeFindData
* pData
, SCTAB nTab
);
212 * Check the visible grid area to see if the visible range has changed. If
213 * so, update the stored visible range, and re-paint the grid area.
218 void UpdateHeaderWidth( const ScVSplitPos
* pWhich
= NULL
,
219 const SCROW
* pPosY
= NULL
);
226 bool UpdateVisibleRange();
227 void GetBorderSize( SvBorder
& rBorder
, const Size
& rSize
);
229 void ResetDrawDragMode();
230 bool IsDrawTextEdit() const;
231 void DrawEnableAnim(bool bSet
);
233 void MakeDrawView( sal_uInt8 nForceDesignMode
= SC_FORCEMODE_NONE
);
235 void HideNoteMarker();
237 void UpdateIMap( SdrObject
* pObj
);
240 ScTabView( Window
* pParent
, ScDocShell
& rDocSh
, ScTabViewShell
* pViewShell
);
243 void MakeDrawLayer();
247 bool HasHintWindow() const;
248 void RemoveHintWindow();
249 void TestHintWindow();
252 DECL_LINK( TabBarResize
, void* );
253 /** Sets an absolute tab bar width (in pixels). */
254 void SetTabBarWidth( long nNewWidth
);
255 /** Sets a relative tab bar width.
256 @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */
257 SC_DLLPUBLIC
void SetRelTabBarWidth( double fRelTabBarWidth
);
258 /** Sets a relative tab bar width. Tab bar is resized again in next DoResize().
259 @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */
260 void SetPendingRelTabBarWidth( double fRelTabBarWidth
);
261 /** Returns the current tab bar width in pixels. */
262 long GetTabBarWidth() const;
263 /** Returns the current tab bar width relative to the frame window width (0.0 ... 1.0). */
264 SC_DLLPUBLIC
double GetRelTabBarWidth() const;
265 /** Returns the pending tab bar width relative to the frame window width (0.0 ... 1.0). */
266 double GetPendingRelTabBarWidth() const;
268 void DoResize( const Point
& rOffset
, const Size
& rSize
, bool bInner
= false );
269 void RepeatResize( bool bUpdateFix
= true );
271 Point
GetGridOffset() const;
273 bool IsDrawSelMode() const { return bDrawSelMode
; }
274 void SetDrawSelMode(bool bNew
) { bDrawSelMode
= bNew
; }
276 void SetDrawFuncPtr(FuPoor
* pFuncPtr
) { pDrawActual
= pFuncPtr
; }
277 void SetDrawFuncOldPtr(FuPoor
* pFuncPtr
) { pDrawOld
= pFuncPtr
; }
278 FuPoor
* GetDrawFuncPtr() { return pDrawActual
; }
279 FuPoor
* GetDrawFuncOldPtr() { return pDrawOld
; }
281 void DrawDeselectAll();
282 void DrawMarkListHasChanged();
283 void UpdateAnchorHandles();
285 ScPageBreakData
* GetPageBreakData() { return pPageBreakData
; }
286 const std::vector
<ScHighlightEntry
>& GetHighlightRanges() { return maHighlightRanges
; }
288 void UpdatePageBreakData( bool bForcePaint
= false );
290 void DrawMarkRect( const Rectangle
& rRect
);
292 ScViewData
* GetViewData() { return &aViewData
; }
293 const ScViewData
* GetViewData() const { return &aViewData
; }
295 ScViewFunctionSet
* GetFunctionSet() { return &aFunctionSet
; }
296 ScViewSelectionEngine
* GetSelEngine() { return pSelEngine
; }
298 bool SelMouseButtonDown( const MouseEvent
& rMEvt
);
300 ScDrawView
* GetScDrawView() { return pDrawView
; }
301 SdrView
* GetSdrView(); // gegen CLOKs
303 bool IsMinimized() const { return bMinimized
; }
306 * Called after moving, copying, inserting or deleting a sheet.
308 * @param bSameTabButMoved true if the same sheet as before is activated.
310 void TabChanged( bool bSameTabButMoved
= false );
311 void SetZoom( const Fraction
& rNewX
, const Fraction
& rNewY
, bool bAll
);
312 SC_DLLPUBLIC
void RefreshZoom();
313 void SetPagebreakMode( bool bSet
);
315 void UpdateLayerLocks();
317 void UpdateDrawTextOutliner();
318 void DigitLanguageChanged();
320 void UpdateInputLine();
322 void InitRefMode( SCCOL nCurX
, SCROW nCurY
, SCTAB nCurZ
, ScRefType eType
,
323 bool bPaint
= true );
324 void DoneRefMode( bool bContinue
= false );
325 void UpdateRef( SCCOL nCurX
, SCROW nCurY
, SCTAB nCurZ
);
329 void FakeButtonUp( ScSplitPos eWhich
);
331 Window
* GetActiveWin();
332 Window
* GetWindowByPos( ScSplitPos ePos
);
334 ScSplitPos
FindWindow( Window
* pWindow
) const;
336 void SetActivePointer( const Pointer
& rPointer
);
338 void ActiveGrabFocus();
340 void ClickCursor( SCCOL nPosX
, SCROW nPosY
, bool bControl
);
342 SC_DLLPUBLIC
void SetCursor( SCCOL nPosX
, SCROW nPosY
, bool bNew
= false );
344 SC_DLLPUBLIC
void CellContentChanged();
345 void SelectionChanged();
346 void CursorPosChanged();
347 void UpdateInputContext();
349 void CheckSelectionTransfer();
351 void InvertHorizontal( ScVSplitPos eWhich
, long nDragPos
);
352 void InvertVertical( ScHSplitPos eWhich
, long nDragPos
);
354 Point
GetInsertPos();
356 Point
GetChartInsertPos( const Size
& rSize
, const ScRange
& rCellRange
);
357 Point
GetChartDialogPos( const Size
& rDialogSize
, const Rectangle
& rLogicChart
);
359 void UpdateAutoFillMark();
362 void HideAllCursors();
363 void ShowAllCursors();
365 void AlignToCursor( SCsCOL nCurX
, SCsROW nCurY
, ScFollowMode eMode
,
366 const ScSplitPos
* pWhich
= NULL
);
368 SvxZoomType
GetZoomType() const;
369 void SetZoomType( SvxZoomType eNew
, bool bAll
);
370 sal_uInt16
CalcZoom( SvxZoomType eType
, sal_uInt16 nOldZoom
);
372 bool HasPageFieldDataAtCursor() const;
373 void StartDataSelect();
375 // MoveCursorAbs - absolute
376 // MoveCursorRel - single cells
377 // MoveCursorPage - screen
378 // MoveCursorArea - Data block
379 // MoveCursorEnd - top left / user range
381 SC_DLLPUBLIC
void MoveCursorAbs( SCsCOL nCurX
, SCsROW nCurY
, ScFollowMode eMode
,
382 bool bShift
, bool bControl
,
383 bool bKeepOld
= false, bool bKeepSel
= false );
384 void MoveCursorRel( SCsCOL nMovX
, SCsROW nMovY
, ScFollowMode eMode
,
385 bool bShift
, bool bKeepSel
= false );
386 void MoveCursorPage( SCsCOL nMovX
, SCsROW nMovY
, ScFollowMode eMode
,
387 bool bShift
, bool bKeepSel
= false );
388 void MoveCursorArea( SCsCOL nMovX
, SCsROW nMovY
, ScFollowMode eMode
,
389 bool bShift
, bool bKeepSel
= false );
390 void MoveCursorEnd( SCsCOL nMovX
, SCsROW nMovY
, ScFollowMode eMode
,
391 bool bShift
, bool bKeepSel
= false );
392 void MoveCursorScreen( SCsCOL nMovX
, SCsROW nMovY
, ScFollowMode eMode
, bool bShift
);
394 void MoveCursorEnter( bool bShift
); // Shift for direction (select nothing)
396 bool MoveCursorKeyInput( const KeyEvent
& rKeyEvent
);
398 void FindNextUnprot( bool bShift
, bool bInSelection
= true );
400 SC_DLLPUBLIC
void SetTabNo( SCTAB nTab
, bool bNew
= false, bool bExtendSelection
= false, bool bSameTabButMoved
= false );
401 void SelectNextTab( short nDir
, bool bExtendSelection
= false );
403 void ActivateView( bool bActivate
, bool bFirst
);
404 void ActivatePart( ScSplitPos eWhich
);
405 bool IsInActivatePart() const { return bInActivatePart
; }
407 void SetTimer( ScGridWindow
* pWin
, const MouseEvent
& rMEvt
);
410 void ScrollX( long nDeltaX
, ScHSplitPos eWhich
, bool bUpdBars
= true );
411 void ScrollY( long nDeltaY
, ScVSplitPos eWhich
, bool bUpdBars
= true );
412 SC_DLLPUBLIC
void ScrollLines( long nDeltaX
, long nDeltaY
); // active
414 bool ScrollCommand( const CommandEvent
& rCEvt
, ScSplitPos ePos
);
416 void ScrollToObject( SdrObject
* pDrawObj
);
417 void MakeVisible( const Rectangle
& rHMMRect
);
421 void PaintArea( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
422 ScUpdateMode eMode
= SC_UPDATE_ALL
);
426 void PaintTopArea( SCCOL nStartCol
, SCCOL nEndCol
);
429 void PaintLeftArea( SCROW nStartRow
, SCROW nEndRow
);
436 void CreateAnchorHandles(SdrHdlList
& rHdl
, const ScAddress
& rAddress
);
438 void UpdateCopySourceOverlay();
439 void UpdateSelectionOverlay();
440 void UpdateShrinkOverlay();
441 void UpdateAllOverlays();
443 void UpdateFormulas();
444 void InterpretVisible();
445 void CheckNeedsRepaint();
448 void PaintRangeFinder( long nNumber
= -1 );
449 void AddHighlightRange( const ScRange
& rRange
, const Color
& rColor
);
450 void ClearHighlightRanges();
452 void DoChartSelection( const ::com::sun::star::uno::Sequence
<
453 ::com::sun::star::chart2::data::HighlightedRange
> & rHilightRanges
);
455 long GetGridWidth( ScHSplitPos eWhich
);
456 long GetGridHeight( ScVSplitPos eWhich
);
458 void UpdateScrollBars();
459 void SetNewVisArea();
461 void InvalidateAttribs();
463 void MakeEditView( ScEditEngineDefaulter
* pEngine
, SCCOL nCol
, SCROW nRow
);
464 void KillEditView( bool bNoPaint
);
465 void UpdateEditView();
470 void SelectAll( bool bContinue
= false );
471 void SelectAllTables();
472 void DeselectAllTables();
474 void MarkCursor( SCCOL nCurX
, SCROW nCurY
, SCTAB nCurZ
,
475 bool bCols
= false, bool bRows
= false, bool bCellSelection
= false );
476 void InitBlockMode( SCCOL nCurX
, SCROW nCurY
, SCTAB nCurZ
,
477 bool bTestNeg
= false,
478 bool bCols
= false, bool bRows
= false );
479 void InitOwnBlockMode();
480 void DoneBlockMode( bool bContinue
= false );
482 bool IsBlockMode() const;
484 void ExpandBlock(SCsCOL nMovX
, SCsROW nMovY
, ScFollowMode eMode
);
485 void ExpandBlockPage(SCsCOL nMovX
, SCsROW nMovY
);
486 void ExpandBlockArea(SCsCOL nMovX
, SCsROW nMovY
);
490 void MarkDataArea( bool bIncludeCursor
= true );
491 void MarkMatrixFormula();
494 void MarkRange( const ScRange
& rRange
, bool bSetCursor
= true, bool bContinue
= false );
496 bool IsMarking( SCCOL nCol
, SCROW nRow
, SCTAB nTab
) const;
498 void PaintMarks( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
);
499 void PaintBlock( bool bReset
= false );
501 void SetMarkData( const ScMarkData
& rNew
);
502 void MarkDataChanged();
504 void LockModifiers( sal_uInt16 nModifiers
);
505 sal_uInt16
GetLockedModifiers() const;
506 void ViewOptionsHasChanged( bool bHScrollChanged
,
507 bool bGraphicsChanged
= false);
509 Point
GetMousePosPixel();
511 void SnapSplitPos( Point
& rScreenPosPixel
);
512 void FreezeSplitters( bool bFreeze
);
514 void SplitAtCursor();
515 void SplitAtPixel( const Point
& rPixel
, bool bHor
, bool bVer
);
516 void InvalidateSplit();
518 void ErrorMessage( sal_uInt16 nGlobStrId
);
519 Window
* GetParentOrChild( sal_uInt16 nChildId
);
521 void EnableRefInput(bool bFlag
= true);
523 Window
* GetFrameWin() const { return pFrameWin
; }
525 bool HasPaintBrush() const { return pBrushDocument
|| pDrawBrushSet
; }
526 ScDocument
* GetBrushDocument() const { return pBrushDocument
; }
527 SfxItemSet
* GetDrawBrushSet() const { return pDrawBrushSet
; }
528 bool IsPaintBrushLocked() const { return bLockPaintBrush
; }
529 void SetBrushDocument( ScDocument
* pNew
, bool bLock
);
530 void SetDrawBrushSet( SfxItemSet
* pNew
, bool bLock
);
531 void ResetBrushDocument();
533 void SetInRefMode( bool bRefMode
);
535 bool ContinueOnlineSpelling();
536 void EnableAutoSpell( bool bEnable
);
537 void ResetAutoSpell();
538 void SetAutoSpellData( SCCOL nPosX
, SCROW nPosY
, const std::vector
<editeng::MisspellRanges
>* pRanges
);
545 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */