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