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 : 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;
51 :
52 : namespace com { namespace sun { namespace star {
53 : namespace chart2 { namespace data {
54 : struct HighlightedRange;
55 : }}}}}
56 :
57 : #define SC_FORCEMODE_NONE 0xff
58 :
59 : // ---------------------------------------------------------------------------
60 : // Help - Window
61 :
62 : class ScCornerButton : public Window
63 : {
64 : private:
65 : ScViewData* pViewData;
66 : bool bAdd;
67 :
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();
75 :
76 : virtual void StateChanged( StateChangedType nType );
77 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
78 : };
79 :
80 :
81 : // ---------------------------------------------------------------------------
82 :
83 : class ScTabView : boost::noncopyable
84 : {
85 : private:
86 : enum BlockMode { None = 0, Normal = 1, Own = 2 };
87 :
88 : Window* pFrameWin; // First !!!
89 : ScViewData aViewData; // must be at the front !
90 :
91 : ScViewSelectionEngine* pSelEngine;
92 : ScViewFunctionSet aFunctionSet;
93 :
94 : ScHeaderSelectionEngine* pHdrSelEng;
95 : ScHeaderFunctionSet aHdrFunc;
96 :
97 : SfxInPlaceClient* pIPClient;
98 :
99 : ScDrawView* pDrawView;
100 :
101 : Size aFrameSize; // passed on as for DoResize
102 : Point aBorderPos;
103 :
104 : FuPoor* pDrawActual;
105 : FuPoor* pDrawOld;
106 :
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;
122 :
123 : boost::scoped_ptr<ScHintWindow> mpInputHintWindow; // popup window for data validation
124 :
125 : ScPageBreakData* pPageBreakData;
126 : std::vector<ScHighlightEntry> maHighlightRanges;
127 :
128 : ScDocument* pBrushDocument; // cell formats for format paint brush
129 : SfxItemSet* pDrawBrushSet; // drawing object attributes for paint brush
130 :
131 : Timer aScrollTimer;
132 : ScGridWindow* pTimerWindow;
133 : MouseEvent aTimerMEvt;
134 :
135 : sal_uLong nTipVisible;
136 :
137 : long nPrevDragPos;
138 :
139 : BlockMode meBlockMode; // Marks block
140 :
141 : SCCOL nBlockStartX;
142 : SCCOL nBlockStartXOrig;
143 : SCCOL nBlockEndX;
144 :
145 : SCROW nBlockStartY;
146 : SCROW nBlockStartYOrig;
147 : SCROW nBlockEndY;
148 :
149 : SCTAB nBlockStartZ;
150 : SCTAB nBlockEndZ;
151 :
152 : SCCOL nOldCurX;
153 : SCROW nOldCurY;
154 :
155 : double mfPendingTabBarWidth; // Tab bar width relative to frame window width.
156 :
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?
168 :
169 : void Init();
170 :
171 : void DoAddWin( ScGridWindow* pWin );
172 :
173 : void InitScrollBar( ScrollBar& rScrollBar, long nMaxVal );
174 : DECL_LINK( ScrollHdl, ScrollBar* );
175 : DECL_LINK( EndScrollHdl, ScrollBar* );
176 :
177 : DECL_LINK( SplitHdl, Splitter* );
178 : void DoHSplit(long nSplitPos);
179 : void DoVSplit(long nSplitPos);
180 :
181 : DECL_LINK( TimerHdl, void* );
182 :
183 : void UpdateVarZoom();
184 :
185 : static void SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, bool bLayoutRTL );
186 : static long GetScrollBarPos( ScrollBar& rScroll );
187 :
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);
191 :
192 : void SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX);
193 : void SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY);
194 :
195 : /**
196 : *
197 : * @brief Update marks for a selected Range. This is a helper function
198 : * for PaintRangeFinder.
199 : *
200 : * @param pData: Range to update for painting.
201 : * @param nTab: Current tab.
202 : *
203 : **/
204 :
205 : void PaintRangeFinderEntry (ScRangeFindData* pData, SCTAB nTab);
206 :
207 : protected:
208 : void UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
209 : const SCROW* pPosY = NULL );
210 :
211 : void HideTip();
212 : void ShowRefTip();
213 :
214 : void ZoomChanged();
215 : void UpdateShow();
216 : void UpdateVisibleRange();
217 : void GetBorderSize( SvBorder& rBorder, const Size& rSize );
218 :
219 : void ResetDrawDragMode();
220 : bool IsDrawTextEdit() const;
221 : void DrawEnableAnim(bool bSet);
222 :
223 : void MakeDrawView( sal_uInt8 nForceDesignMode = SC_FORCEMODE_NONE );
224 :
225 : void HideNoteMarker();
226 :
227 : void UpdateIMap( SdrObject* pObj );
228 :
229 : public:
230 : ScTabView( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
231 : ~ScTabView();
232 :
233 : void MakeDrawLayer();
234 :
235 : void HideListBox();
236 :
237 : bool HasHintWindow() const;
238 : void RemoveHintWindow();
239 : void TestHintWindow();
240 :
241 :
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;
257 :
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;
262 :
263 0 : bool IsDrawSelMode() const { return bDrawSelMode; }
264 0 : void SetDrawSelMode(bool bNew) { bDrawSelMode = bNew; }
265 :
266 0 : void SetDrawFuncPtr(FuPoor* pFuncPtr) { pDrawActual = pFuncPtr; }
267 0 : void SetDrawFuncOldPtr(FuPoor* pFuncPtr) { pDrawOld = pFuncPtr; }
268 0 : FuPoor* GetDrawFuncPtr() { return pDrawActual; }
269 0 : FuPoor* GetDrawFuncOldPtr() { return pDrawOld; }
270 :
271 : void DrawDeselectAll();
272 : void DrawMarkListHasChanged();
273 : void UpdateAnchorHandles();
274 :
275 0 : ScPageBreakData* GetPageBreakData() { return pPageBreakData; }
276 0 : const std::vector<ScHighlightEntry>& GetHighlightRanges() { return maHighlightRanges; }
277 :
278 : void UpdatePageBreakData( bool bForcePaint = false );
279 :
280 : void DrawMarkRect( const Rectangle& rRect );
281 :
282 0 : ScViewData* GetViewData() { return &aViewData; }
283 0 : const ScViewData* GetViewData() const { return &aViewData; }
284 :
285 0 : ScViewFunctionSet* GetFunctionSet() { return &aFunctionSet; }
286 0 : ScViewSelectionEngine* GetSelEngine() { return pSelEngine; }
287 :
288 : bool SelMouseButtonDown( const MouseEvent& rMEvt );
289 :
290 0 : ScDrawView* GetScDrawView() { return pDrawView; }
291 : SdrView* GetSdrView(); // gegen CLOKs
292 :
293 0 : bool IsMinimized() const { return bMinimized; }
294 :
295 : /**
296 : * Called after moving, copying, inserting or deleting a sheet.
297 : *
298 : * @param bSameTabButMoved true if the same sheet as before is activated.
299 : */
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 );
304 :
305 : void UpdateLayerLocks();
306 :
307 : void UpdateDrawTextOutliner();
308 : void DigitLanguageChanged();
309 :
310 : void UpdateInputLine();
311 :
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();
317 :
318 : void StopMarking();
319 : void FakeButtonUp( ScSplitPos eWhich );
320 :
321 : Window* GetActiveWin();
322 : Window* GetWindowByPos( ScSplitPos ePos );
323 :
324 : ScSplitPos FindWindow( Window* pWindow ) const;
325 :
326 : void SetActivePointer( const Pointer& rPointer );
327 :
328 : void ActiveGrabFocus();
329 :
330 : void ClickCursor( SCCOL nPosX, SCROW nPosY, bool bControl );
331 :
332 : SC_DLLPUBLIC void SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew = false );
333 :
334 : SC_DLLPUBLIC void CellContentChanged();
335 : void SelectionChanged();
336 : void CursorPosChanged();
337 : void UpdateInputContext();
338 :
339 : void CheckSelectionTransfer();
340 :
341 : void InvertHorizontal( ScVSplitPos eWhich, long nDragPos );
342 : void InvertVertical( ScHSplitPos eWhich, long nDragPos );
343 :
344 : Point GetInsertPos();
345 :
346 : Point GetChartInsertPos( const Size& rSize, const ScRange& rCellRange );
347 : Point GetChartDialogPos( const Size& rDialogSize, const Rectangle& rLogicChart );
348 :
349 : void UpdateAutoFillMark();
350 :
351 : void ShowCursor();
352 : void HideAllCursors();
353 : void ShowAllCursors();
354 :
355 : void AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
356 : const ScSplitPos* pWhich = NULL );
357 :
358 : SvxZoomType GetZoomType() const;
359 : void SetZoomType( SvxZoomType eNew, bool bAll );
360 : sal_uInt16 CalcZoom( SvxZoomType eType, sal_uInt16 nOldZoom );
361 :
362 : bool HasPageFieldDataAtCursor() const;
363 : void StartDataSelect();
364 :
365 : // MoveCursorAbs - absolute
366 : // MoveCursorRel - single cells
367 : // MoveCursorPage - screen
368 : // MoveCursorArea - Data block
369 : // MoveCursorEnd - top left / user range
370 :
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 );
383 :
384 : void MoveCursorEnter( bool bShift ); // Shift for direction (select nothing)
385 :
386 : bool MoveCursorKeyInput( const KeyEvent& rKeyEvent );
387 :
388 : void FindNextUnprot( bool bShift, bool bInSelection = true );
389 :
390 : SC_DLLPUBLIC void SetTabNo( SCTAB nTab, bool bNew = false, bool bExtendSelection = false, bool bSameTabButMoved = false );
391 : void SelectNextTab( short nDir, bool bExtendSelection = false );
392 :
393 : void ActivateView( bool bActivate, bool bFirst );
394 : void ActivatePart( ScSplitPos eWhich );
395 0 : bool IsInActivatePart() const { return bInActivatePart; }
396 :
397 : void SetTimer( ScGridWindow* pWin, const MouseEvent& rMEvt );
398 : void ResetTimer();
399 :
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
403 :
404 : bool ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos );
405 :
406 : void ScrollToObject( SdrObject* pDrawObj );
407 : void MakeVisible( const Rectangle& rHMMRect );
408 :
409 : // Zeichnen
410 :
411 : void PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
412 : ScUpdateMode eMode = SC_UPDATE_ALL );
413 :
414 : void PaintGrid();
415 :
416 : void PaintTopArea( SCCOL nStartCol, SCCOL nEndCol );
417 : void PaintTop();
418 :
419 : void PaintLeftArea( SCROW nStartRow, SCROW nEndRow );
420 : void PaintLeft();
421 :
422 : bool PaintExtras();
423 :
424 : void RecalcPPT();
425 :
426 : void CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress);
427 :
428 : void UpdateCopySourceOverlay();
429 : void UpdateSelectionOverlay();
430 : void UpdateShrinkOverlay();
431 : void UpdateAllOverlays();
432 :
433 : void UpdateFormulas();
434 : void InterpretVisible();
435 : void CheckNeedsRepaint();
436 :
437 : void PaintRangeFinder( long nNumber = -1 );
438 : void AddHighlightRange( const ScRange& rRange, const Color& rColor );
439 : void ClearHighlightRanges();
440 :
441 : void DoChartSelection( const ::com::sun::star::uno::Sequence<
442 : ::com::sun::star::chart2::data::HighlightedRange > & rHilightRanges );
443 :
444 : long GetGridWidth( ScHSplitPos eWhich );
445 : long GetGridHeight( ScVSplitPos eWhich );
446 :
447 : void UpdateScrollBars();
448 : void SetNewVisArea();
449 :
450 : void InvalidateAttribs();
451 :
452 : void MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow );
453 : void KillEditView( bool bNoPaint );
454 : void UpdateEditView();
455 :
456 :
457 : // Blocks
458 :
459 : void SelectAll( bool bContinue = false );
460 : void SelectAllTables();
461 : void DeselectAllTables();
462 :
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 );
470 :
471 : bool IsBlockMode() const;
472 :
473 : void ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode);
474 : void ExpandBlockPage(SCsCOL nMovX, SCsROW nMovY);
475 : void ExpandBlockArea(SCsCOL nMovX, SCsROW nMovY);
476 :
477 : void MarkColumns();
478 : void MarkRows();
479 : void MarkDataArea( bool bIncludeCursor = true );
480 : void MarkMatrixFormula();
481 : void Unmark();
482 :
483 : void MarkRange( const ScRange& rRange, bool bSetCursor = true, bool bContinue = false );
484 :
485 : bool IsMarking( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
486 :
487 : void PaintMarks( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
488 : void PaintBlock( bool bReset = false );
489 :
490 : void SetMarkData( const ScMarkData& rNew );
491 : void MarkDataChanged();
492 :
493 : void LockModifiers( sal_uInt16 nModifiers );
494 : sal_uInt16 GetLockedModifiers() const;
495 : void ViewOptionsHasChanged( bool bHScrollChanged,
496 : bool bGraphicsChanged = false);
497 :
498 : Point GetMousePosPixel();
499 :
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();
506 :
507 : void ErrorMessage( sal_uInt16 nGlobStrId );
508 : Window* GetParentOrChild( sal_uInt16 nChildId );
509 :
510 : void EnableRefInput(bool bFlag = true);
511 :
512 0 : Window* GetFrameWin() const { return pFrameWin; }
513 :
514 0 : bool HasPaintBrush() const { return pBrushDocument || pDrawBrushSet; }
515 0 : ScDocument* GetBrushDocument() const { return pBrushDocument; }
516 0 : SfxItemSet* GetDrawBrushSet() const { return pDrawBrushSet; }
517 0 : bool IsPaintBrushLocked() const { return bLockPaintBrush; }
518 : void SetBrushDocument( ScDocument* pNew, bool bLock );
519 : void SetDrawBrushSet( SfxItemSet* pNew, bool bLock );
520 : void ResetBrushDocument();
521 :
522 : void SetInRefMode( bool bRefMode );
523 : };
524 :
525 :
526 :
527 : #endif
528 :
529 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|