bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / view / tabview3.cxx
blob30750750a69797c1457daead6d2574440cbc799a
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 .
20 #include <rangelst.hxx>
21 #include "scitems.hxx"
22 #include <editeng/eeitem.hxx>
25 #include <editeng/brushitem.hxx>
26 #include <editeng/editview.hxx>
27 #include <svx/fmshell.hxx>
28 #include <svx/svdoole2.hxx>
29 #include <sfx2/bindings.hxx>
30 #include <sfx2/viewfrm.hxx>
31 #include <vcl/cursor.hxx>
33 #include "tabview.hxx"
34 #include "tabvwsh.hxx"
35 #include "docsh.hxx"
36 #include "gridwin.hxx"
37 #include "olinewin.hxx"
38 #include "colrowba.hxx"
39 #include "tabcont.hxx"
40 #include "scmod.hxx"
41 #include "uiitems.hxx"
42 #include "sc.hrc"
43 #include "viewutil.hxx"
44 #include "editutil.hxx"
45 #include "inputhdl.hxx"
46 #include "inputwin.hxx"
47 #include "validat.hxx"
48 #include "hintwin.hxx"
49 #include "inputopt.hxx"
50 #include "rfindlst.hxx"
51 #include "hiranges.hxx"
52 #include "viewuno.hxx"
53 #include "chartarr.hxx"
54 #include "anyrefdg.hxx"
55 #include "dpobject.hxx"
56 #include "patattr.hxx"
57 #include "dociter.hxx"
58 #include "seltrans.hxx"
59 #include "fillinfo.hxx"
60 #include "AccessibilityHints.hxx"
61 #include "rangeutl.hxx"
62 #include "client.hxx"
63 #include "tabprotection.hxx"
64 #include "markdata.hxx"
65 #include "formula/FormulaCompiler.hxx"
67 #include <com/sun/star/chart2/data/HighlightedRange.hpp>
69 namespace
72 ScRange lcl_getSubRangeByIndex( const ScRange& rRange, sal_Int32 nIndex )
74 ScAddress aResult( rRange.aStart );
76 SCCOL nWidth = rRange.aEnd.Col() - rRange.aStart.Col() + 1;
77 SCROW nHeight = rRange.aEnd.Row() - rRange.aStart.Row() + 1;
78 SCTAB nDepth = rRange.aEnd.Tab() - rRange.aStart.Tab() + 1;
79 if( (nWidth > 0) && (nHeight > 0) && (nDepth > 0) )
81 // row by row from first to last sheet
82 sal_Int32 nArea = nWidth * nHeight;
83 aResult.IncCol( static_cast< SCsCOL >( nIndex % nWidth ) );
84 aResult.IncRow( static_cast< SCsROW >( (nIndex % nArea) / nWidth ) );
85 aResult.IncTab( static_cast< SCsTAB >( nIndex / nArea ) );
86 if( !rRange.In( aResult ) )
87 aResult = rRange.aStart;
90 return ScRange( aResult );
93 } // anonymous namespace
95 using namespace com::sun::star;
97 // -----------------------------------------------------------------------
100 // --- Public-Funktionen
103 void ScTabView::ClickCursor( SCCOL nPosX, SCROW nPosY, bool bControl )
105 ScDocument* pDoc = aViewData.GetDocument();
106 SCTAB nTab = aViewData.GetTabNo();
107 pDoc->SkipOverlapped(nPosX, nPosY, nTab);
109 bool bRefMode = SC_MOD()->IsFormulaMode();
111 if ( bRefMode )
113 DoneRefMode( false );
115 if (bControl)
116 SC_MOD()->AddRefEntry();
118 InitRefMode( nPosX, nPosY, nTab, SC_REFTYPE_REF );
120 else
122 DoneBlockMode( bControl );
123 aViewData.ResetOldCursor();
124 SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
128 void ScTabView::UpdateAutoFillMark()
130 // single selection or cursor
131 ScRange aMarkRange;
132 bool bMarked = (aViewData.GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE);
134 sal_uInt16 i;
135 for (i=0; i<4; i++)
136 if (pGridWin[i] && pGridWin[i]->IsVisible())
137 pGridWin[i]->UpdateAutoFillMark( bMarked, aMarkRange );
139 for (i=0; i<2; i++)
141 if (pColBar[i] && pColBar[i]->IsVisible())
142 pColBar[i]->SetMark( bMarked, aMarkRange.aStart.Col(), aMarkRange.aEnd.Col() );
143 if (pRowBar[i] && pRowBar[i]->IsVisible())
144 pRowBar[i]->SetMark( bMarked, aMarkRange.aStart.Row(), aMarkRange.aEnd.Row() );
147 // selection transfer object is checked together with AutoFill marks,
148 // because it has the same requirement of a single continuous block.
149 CheckSelectionTransfer(); // update selection transfer object
152 void ScTabView::FakeButtonUp( ScSplitPos eWhich )
154 if (pGridWin[eWhich])
155 pGridWin[eWhich]->FakeButtonUp();
158 void ScTabView::HideAllCursors()
160 for (sal_uInt16 i=0; i<4; i++)
161 if (pGridWin[i])
162 if (pGridWin[i]->IsVisible())
164 Cursor* pCur = pGridWin[i]->GetCursor();
165 if (pCur)
166 if (pCur->IsVisible())
167 pCur->Hide();
168 pGridWin[i]->HideCursor();
172 void ScTabView::ShowAllCursors()
174 for (sal_uInt16 i=0; i<4; i++)
175 if (pGridWin[i])
176 if (pGridWin[i]->IsVisible())
178 pGridWin[i]->ShowCursor();
180 // #114409#
181 pGridWin[i]->CursorChanged();
185 void ScTabView::ShowCursor()
187 pGridWin[aViewData.GetActivePart()]->ShowCursor();
189 // #114409#
190 pGridWin[aViewData.GetActivePart()]->CursorChanged();
193 void ScTabView::InvalidateAttribs()
195 SfxBindings& rBindings = aViewData.GetBindings();
197 rBindings.Invalidate( SID_STYLE_APPLY );
198 rBindings.Invalidate( SID_STYLE_FAMILY2 );
199 // StarCalc kennt nur Absatz- bzw. Zellformat-Vorlagen
201 rBindings.Invalidate( SID_ATTR_CHAR_FONT );
202 rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
203 rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
205 rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
206 rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
207 rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
208 rBindings.Invalidate( SID_ULINE_VAL_NONE );
209 rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
210 rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
211 rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
213 rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
215 rBindings.Invalidate( SID_ATTR_CHAR_KERNING );
216 rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
217 rBindings.Invalidate( SID_SET_SUB_SCRIPT );
218 rBindings.Invalidate( SID_ATTR_CHAR_STRIKEOUT );
219 rBindings.Invalidate( SID_ATTR_CHAR_SHADOWED );
221 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_LEFT );
222 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_RIGHT );
223 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_BLOCK );
224 rBindings.Invalidate( SID_ATTR_PARA_ADJUST_CENTER);
225 rBindings.Invalidate( SID_NUMBER_TYPE_FORMAT);
227 rBindings.Invalidate( SID_ALIGNLEFT );
228 rBindings.Invalidate( SID_ALIGNRIGHT );
229 rBindings.Invalidate( SID_ALIGNBLOCK );
230 rBindings.Invalidate( SID_ALIGNCENTERHOR );
232 rBindings.Invalidate( SID_ALIGNTOP );
233 rBindings.Invalidate( SID_ALIGNBOTTOM );
234 rBindings.Invalidate( SID_ALIGNCENTERVER );
236 // stuff for sidebar panels
238 rBindings.Invalidate( SID_H_ALIGNCELL );
239 rBindings.Invalidate( SID_V_ALIGNCELL );
240 rBindings.Invalidate( SID_ATTR_ALIGN_INDENT );
241 rBindings.Invalidate( SID_FRAME_LINECOLOR );
242 rBindings.Invalidate( SID_FRAME_LINESTYLE );
243 rBindings.Invalidate( SID_ATTR_BORDER_OUTER );
244 rBindings.Invalidate( SID_ATTR_BORDER_INNER );
245 rBindings.Invalidate( SID_SCGRIDSHOW );
246 rBindings.Invalidate( SID_ATTR_BORDER_DIAG_TLBR );
247 rBindings.Invalidate( SID_ATTR_BORDER_DIAG_BLTR );
248 rBindings.Invalidate( SID_NUMBER_TYPE_FORMAT );
251 rBindings.Invalidate( SID_BACKGROUND_COLOR );
253 rBindings.Invalidate( SID_ATTR_ALIGN_LINEBREAK );
254 rBindings.Invalidate( SID_NUMBER_FORMAT );
256 rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
257 rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
258 rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
259 rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
261 // pseudo slots for Format menu
262 rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
263 rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
264 rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
265 rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
266 rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
267 rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
268 rBindings.Invalidate( SID_ALIGN_ANY_TOP );
269 rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
270 rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
272 rBindings.Invalidate( SID_NUMBER_CURRENCY );
273 rBindings.Invalidate( SID_NUMBER_SCIENTIFIC );
274 rBindings.Invalidate( SID_NUMBER_DATE );
275 rBindings.Invalidate( SID_NUMBER_CURRENCY );
276 rBindings.Invalidate( SID_NUMBER_PERCENT );
277 rBindings.Invalidate( SID_NUMBER_TIME );
280 // SetCursor - Cursor setzen, zeichnen, InputWin updaten
281 // oder Referenz verschicken
282 // ohne Optimierung wegen BugId 29307
284 void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
286 SCCOL nOldX = aViewData.GetCurX();
287 SCROW nOldY = aViewData.GetCurY();
289 // DeactivateIP nur noch bei MarkListHasChanged
291 if ( nPosX != nOldX || nPosY != nOldY || bNew )
293 ScTabViewShell* pViewShell = aViewData.GetViewShell();
294 bool bRefMode = ( pViewShell ? pViewShell->IsRefInputMode() : false );
295 if ( aViewData.HasEditView( aViewData.GetActivePart() ) && !bRefMode ) // 23259 oder so
297 UpdateInputLine();
300 HideAllCursors();
302 aViewData.SetCurX( nPosX );
303 aViewData.SetCurY( nPosY );
305 ShowAllCursors();
307 CursorPosChanged();
311 void ScTabView::CheckSelectionTransfer()
313 if ( aViewData.IsActive() ) // only for active view
315 ScModule* pScMod = SC_MOD();
316 ScSelectionTransferObj* pOld = pScMod->GetSelectionTransfer();
317 if ( pOld && pOld->GetView() == this && pOld->StillValid() )
319 // selection not changed - nothing to do
321 else
323 ScSelectionTransferObj* pNew = ScSelectionTransferObj::CreateFromView( this );
324 if ( pNew )
326 // create new selection
328 if (pOld)
329 pOld->ForgetView();
331 uno::Reference<datatransfer::XTransferable> xRef( pNew );
332 pScMod->SetSelectionTransfer( pNew );
333 pNew->CopyToSelection( GetActiveWin() ); // may delete pOld
335 else if ( pOld && pOld->GetView() == this )
337 // remove own selection
339 pOld->ForgetView();
340 pScMod->SetSelectionTransfer( NULL );
341 TransferableHelper::ClearSelection( GetActiveWin() ); // may delete pOld
343 // else: selection from outside: leave unchanged
348 // Eingabezeile / Menues updaten
349 // CursorPosChanged ruft SelectionChanged
350 // SelectionChanged ruft CellContentChanged
352 void ScTabView::CellContentChanged()
354 SfxBindings& rBindings = aViewData.GetBindings();
356 rBindings.Invalidate( SID_ATTR_SIZE ); // -> Fehlermeldungen anzeigen
357 rBindings.Invalidate( SID_THESAURUS );
358 rBindings.Invalidate( SID_HYPERLINK_GETLINK );
360 InvalidateAttribs(); // Attribut-Updates
362 aViewData.GetViewShell()->UpdateInputHandler();
365 void ScTabView::SelectionChanged()
367 SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
368 if (pViewFrame)
370 uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
371 if (xController.is())
373 ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
374 if (pImp)
375 pImp->SelectionChanged();
379 UpdateAutoFillMark(); // also calls CheckSelectionTransfer
381 SfxBindings& rBindings = aViewData.GetBindings();
383 rBindings.Invalidate( SID_CURRENTCELL ); // -> Navigator
384 rBindings.Invalidate( SID_AUTO_FILTER ); // -> Menue
385 rBindings.Invalidate( FID_NOTE_VISIBLE );
386 rBindings.Invalidate( FID_SHOW_NOTE );
387 rBindings.Invalidate( FID_HIDE_NOTE );
388 rBindings.Invalidate( SID_DELETE_NOTE );
390 // Funktionen, die evtl disabled werden muessen
392 rBindings.Invalidate( FID_INS_ROWBRK );
393 rBindings.Invalidate( FID_INS_COLBRK );
394 rBindings.Invalidate( FID_DEL_ROWBRK );
395 rBindings.Invalidate( FID_DEL_COLBRK );
396 rBindings.Invalidate( FID_MERGE_ON );
397 rBindings.Invalidate( FID_MERGE_OFF );
398 rBindings.Invalidate( FID_MERGE_TOGGLE );
399 rBindings.Invalidate( SID_AUTOFILTER_HIDE );
400 rBindings.Invalidate( SID_UNFILTER );
401 rBindings.Invalidate( SID_REIMPORT_DATA );
402 rBindings.Invalidate( SID_REFRESH_DBAREA );
403 rBindings.Invalidate( SID_OUTLINE_SHOW );
404 rBindings.Invalidate( SID_OUTLINE_HIDE );
405 rBindings.Invalidate( SID_OUTLINE_REMOVE );
406 rBindings.Invalidate( FID_FILL_TO_BOTTOM );
407 rBindings.Invalidate( FID_FILL_TO_RIGHT );
408 rBindings.Invalidate( FID_FILL_TO_TOP );
409 rBindings.Invalidate( FID_FILL_TO_LEFT );
410 rBindings.Invalidate( FID_FILL_SERIES );
411 rBindings.Invalidate( SID_SCENARIOS );
412 rBindings.Invalidate( SID_AUTOFORMAT );
413 rBindings.Invalidate( SID_OPENDLG_TABOP );
414 rBindings.Invalidate( SID_DATA_SELECT );
416 rBindings.Invalidate( SID_CUT );
417 rBindings.Invalidate( SID_COPY );
418 rBindings.Invalidate( SID_PASTE );
419 rBindings.Invalidate( SID_PASTE_SPECIAL );
421 rBindings.Invalidate( FID_INS_ROW );
422 rBindings.Invalidate( FID_INS_COLUMN );
423 rBindings.Invalidate( FID_INS_CELL );
424 rBindings.Invalidate( FID_INS_CELLSDOWN );
425 rBindings.Invalidate( FID_INS_CELLSRIGHT );
427 rBindings.Invalidate( FID_CHG_COMMENT );
429 // nur wegen Zellschutz:
431 rBindings.Invalidate( SID_CELL_FORMAT_RESET );
432 rBindings.Invalidate( SID_DELETE );
433 rBindings.Invalidate( SID_DELETE_CONTENTS );
434 rBindings.Invalidate( FID_DELETE_CELL );
435 rBindings.Invalidate( FID_CELL_FORMAT );
436 rBindings.Invalidate( SID_ENABLE_HYPHENATION );
437 rBindings.Invalidate( SID_INSERT_POSTIT );
438 rBindings.Invalidate( SID_CHARMAP );
439 rBindings.Invalidate( SID_OPENDLG_FUNCTION );
440 rBindings.Invalidate( FID_VALIDATION );
441 rBindings.Invalidate( SID_EXTERNAL_SOURCE );
442 rBindings.Invalidate( SID_TEXT_TO_COLUMNS );
443 rBindings.Invalidate( SID_SORT_ASCENDING );
444 rBindings.Invalidate( SID_SORT_DESCENDING );
446 if (aViewData.GetViewShell()->HasAccessibilityObjects())
447 aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_CURSORCHANGED));
449 CellContentChanged();
452 void ScTabView::CursorPosChanged()
454 bool bRefMode = SC_MOD()->IsFormulaMode();
455 if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert
456 aViewData.GetDocShell()->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
458 // Broadcast, damit andere Views des Dokuments auch umschalten
460 ScDocument* pDoc = aViewData.GetDocument();
461 bool bDP = NULL != pDoc->GetDPAtCursor(
462 aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
463 aViewData.GetViewShell()->SetPivotShell(bDP);
465 // UpdateInputHandler jetzt in CellContentChanged
467 SelectionChanged();
469 aViewData.SetTabStartCol( SC_TABSTART_NONE );
472 namespace {
474 Point calcHintWindowPosition(
475 const Point& rCellPos, const Size& rCellSize, const Size& rFrameWndSize, const Size& rHintWndSize)
477 const long nMargin = 20;
479 long nMLeft = rCellPos.X();
480 long nMRight = rFrameWndSize.Width() - rCellPos.X() - rCellSize.Width();
481 long nMTop = rCellPos.Y();
482 long nMBottom = rFrameWndSize.Height() - rCellPos.Y() - rCellSize.Height();
484 // First, see if we can fit the entire hint window in the visible region.
486 if (nMRight - nMargin >= rHintWndSize.Width())
488 // Right margin is wide enough.
489 if (rFrameWndSize.Height() >= rHintWndSize.Height())
491 // The frame has enough height. Take it.
492 Point aPos = rCellPos;
493 aPos.X() += rCellSize.Width() + nMargin;
494 if (aPos.Y() + rHintWndSize.Height() > rFrameWndSize.Height())
496 // Push the hint window up a bit to make it fit.
497 aPos.Y() = rFrameWndSize.Height() - rHintWndSize.Height();
499 return aPos;
503 if (nMBottom - nMargin >= rHintWndSize.Height())
505 // Bottom margin is high enough.
506 if (rFrameWndSize.Width() >= rHintWndSize.Width())
508 // The frame has enough width. Take it.
509 Point aPos = rCellPos;
510 aPos.Y() += rCellSize.Height() + nMargin;
511 if (aPos.X() + rHintWndSize.Width() > rFrameWndSize.Width())
513 // Move the hint window to the left to make it fit.
514 aPos.X() = rFrameWndSize.Width() - rHintWndSize.Width();
516 return aPos;
520 if (nMLeft - nMargin >= rHintWndSize.Width())
522 // Left margin is wide enough.
523 if (rFrameWndSize.Height() >= rHintWndSize.Height())
525 // The frame is high enough. Take it.
526 Point aPos = rCellPos;
527 aPos.X() -= rHintWndSize.Width() + nMargin;
528 if (aPos.Y() + rHintWndSize.Height() > rFrameWndSize.Height())
530 // Push the hint window up a bit to make it fit.
531 aPos.Y() = rFrameWndSize.Height() - rHintWndSize.Height();
533 return aPos;
537 if (nMTop - nMargin >= rHintWndSize.Height())
539 // Top margin is high enough.
540 if (rFrameWndSize.Width() >= rHintWndSize.Width())
542 // The frame is wide enough. Take it.
543 Point aPos = rCellPos;
544 aPos.Y() -= rHintWndSize.Height() + nMargin;
545 if (aPos.X() + rHintWndSize.Width() > rFrameWndSize.Width())
547 // Move the hint window to the left to make it fit.
548 aPos.X() = rFrameWndSize.Width() - rHintWndSize.Width();
550 return aPos;
554 // The popup doesn't fit in any direction in its entirety. Do our best.
556 if (nMRight - nMargin >= rHintWndSize.Width())
558 // Right margin is good enough.
559 Point aPos = rCellPos;
560 aPos.X() += nMargin + rCellSize.Width();
561 aPos.Y() = 0;
562 return aPos;
565 if (nMBottom - nMargin >= rHintWndSize.Height())
567 // Bottom margin is good enough.
568 Point aPos = rCellPos;
569 aPos.Y() += nMargin + rCellSize.Height();
570 aPos.X() = 0;
571 return aPos;
574 if (nMLeft - nMargin >= rHintWndSize.Width())
576 // Left margin is good enough.
577 Point aPos = rCellPos;
578 aPos.X() -= rHintWndSize.Width() + nMargin;
579 aPos.Y() = 0;
580 return aPos;
583 if (nMTop - nMargin >= rHintWndSize.Height())
585 // Top margin is good enough.
586 Point aPos = rCellPos;
587 aPos.Y() -= rHintWndSize.Height() + nMargin;
588 aPos.X() = 0;
589 return aPos;
592 // None of the above. Hopeless. At least try not to cover the current
593 // cell.
594 Point aPos = rCellPos;
595 aPos.X() += rCellSize.Width();
596 return aPos;
601 void ScTabView::TestHintWindow()
603 // show input help window and list drop-down button for validity
605 bool bListValButton = false;
606 ScAddress aListValPos;
608 ScDocument* pDoc = aViewData.GetDocument();
609 const SfxUInt32Item* pItem = (const SfxUInt32Item*)
610 pDoc->GetAttr( aViewData.GetCurX(),
611 aViewData.GetCurY(),
612 aViewData.GetTabNo(),
613 ATTR_VALIDDATA );
614 if ( pItem->GetValue() )
616 const ScValidationData* pData = pDoc->GetValidationEntry( pItem->GetValue() );
617 OSL_ENSURE(pData,"ValidationData nicht gefunden");
618 String aTitle, aMessage;
619 if ( pData && pData->GetInput( aTitle, aMessage ) && aMessage.Len() > 0 )
621 //! Abfrage, ob an gleicher Stelle !!!!
623 mpInputHintWindow.reset();
625 ScSplitPos eWhich = aViewData.GetActivePart();
626 ScGridWindow* pWin = pGridWin[eWhich];
627 SCCOL nCol = aViewData.GetCurX();
628 SCROW nRow = aViewData.GetCurY();
629 Point aPos = aViewData.GetScrPos( nCol, nRow, eWhich );
630 Size aWinSize = pWin->GetOutputSizePixel();
631 // Cursor sichtbar?
632 if ( nCol >= aViewData.GetPosX(WhichH(eWhich)) &&
633 nRow >= aViewData.GetPosY(WhichV(eWhich)) &&
634 aPos.X() < aWinSize.Width() && aPos.Y() < aWinSize.Height() )
636 // HintWindow anlegen, bestimmt seine Groesse selbst
637 mpInputHintWindow.reset(new ScHintWindow(pWin, aTitle, aMessage));
638 Size aHintWndSize = mpInputHintWindow->GetSizePixel();
639 long nCellSizeX = 0;
640 long nCellSizeY = 0;
641 aViewData.GetMergeSizePixel(nCol, nRow, nCellSizeX, nCellSizeY);
643 Point aHintPos = calcHintWindowPosition(
644 aPos, Size(nCellSizeX,nCellSizeY), aWinSize, aHintWndSize);
646 mpInputHintWindow->SetPosPixel( aHintPos );
647 mpInputHintWindow->ToTop();
648 mpInputHintWindow->Show();
651 else
652 mpInputHintWindow.reset();
654 // list drop-down button
655 if ( pData && pData->HasSelectionList() )
657 aListValPos.Set( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
658 bListValButton = true;
661 else
662 mpInputHintWindow.reset();
664 for ( sal_uInt16 i=0; i<4; i++ )
665 if ( pGridWin[i] && pGridWin[i]->IsVisible() )
666 pGridWin[i]->UpdateListValPos( bListValButton, aListValPos );
669 bool ScTabView::HasHintWindow() const
671 return mpInputHintWindow.get() != NULL;
674 void ScTabView::RemoveHintWindow()
676 mpInputHintWindow.reset();
680 // find window that should not be over the cursor
681 static Window* lcl_GetCareWin(SfxViewFrame* pViewFrm)
683 //! auch Spelling ??? (dann beim Aufruf Membervariable setzen)
685 // Suchen & Ersetzen
686 if ( pViewFrm->HasChildWindow(SID_SEARCH_DLG) )
688 SfxChildWindow* pChild = pViewFrm->GetChildWindow(SID_SEARCH_DLG);
689 if (pChild)
691 Window* pWin = pChild->GetWindow();
692 if (pWin && pWin->IsVisible())
693 return pWin;
697 // Aenderungen uebernehmen
698 if ( pViewFrm->HasChildWindow(FID_CHG_ACCEPT) )
700 SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_CHG_ACCEPT);
701 if (pChild)
703 Window* pWin = pChild->GetWindow();
704 if (pWin && pWin->IsVisible())
705 return pWin;
709 return NULL;
713 // Bildschirm an Cursorposition anpassen
716 void ScTabView::AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
717 const ScSplitPos* pWhich )
720 // aktiven Teil umschalten jetzt hier
723 ScSplitPos eActive = aViewData.GetActivePart();
724 ScHSplitPos eActiveX = WhichH(eActive);
725 ScVSplitPos eActiveY = WhichV(eActive);
726 bool bHFix = (aViewData.GetHSplitMode() == SC_SPLIT_FIX);
727 bool bVFix = (aViewData.GetVSplitMode() == SC_SPLIT_FIX);
728 if (bHFix)
729 if (eActiveX == SC_SPLIT_LEFT && nCurX >= (SCsCOL)aViewData.GetFixPosX())
731 ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT );
732 eActiveX = SC_SPLIT_RIGHT;
734 if (bVFix)
735 if (eActiveY == SC_SPLIT_TOP && nCurY >= (SCsROW)aViewData.GetFixPosY())
737 ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
738 eActiveY = SC_SPLIT_BOTTOM;
742 // eigentliches Align
745 if ( eMode != SC_FOLLOW_NONE )
747 ScSplitPos eAlign;
748 if (pWhich)
749 eAlign = *pWhich;
750 else
751 eAlign = aViewData.GetActivePart();
752 ScHSplitPos eAlignX = WhichH(eAlign);
753 ScVSplitPos eAlignY = WhichV(eAlign);
755 SCsCOL nDeltaX = (SCsCOL) aViewData.GetPosX(eAlignX);
756 SCsROW nDeltaY = (SCsROW) aViewData.GetPosY(eAlignY);
757 SCsCOL nSizeX = (SCsCOL) aViewData.VisibleCellsX(eAlignX);
758 SCsROW nSizeY = (SCsROW) aViewData.VisibleCellsY(eAlignY);
760 long nCellSizeX;
761 long nCellSizeY;
762 if ( nCurX >= 0 && nCurY >= 0 )
763 aViewData.GetMergeSizePixel( (SCCOL)nCurX, (SCROW)nCurY, nCellSizeX, nCellSizeY );
764 else
765 nCellSizeX = nCellSizeY = 0;
766 Size aScrSize = aViewData.GetScrSize();
767 long nSpaceX = ( aScrSize.Width() - nCellSizeX ) / 2;
768 long nSpaceY = ( aScrSize.Height() - nCellSizeY ) / 2;
769 // nSpaceY: desired start position of cell for FOLLOW_JUMP, modified if dialog interferes
771 bool bForceNew = false; // force new calculation of JUMP position (vertical only)
773 // VisibleCellsY == CellsAtY( GetPosY( eWhichY ), 1, eWhichY )
775 //-------------------------------------------------------------------------------
776 // falls z.B. Suchen-Dialog offen ist, Cursor nicht hinter den Dialog stellen
777 // wenn moeglich, die Zeile mit dem Cursor oberhalb oder unterhalb des Dialogs
779 //! nicht, wenn schon komplett sichtbar
781 if ( eMode == SC_FOLLOW_JUMP )
783 Window* pCare = lcl_GetCareWin( aViewData.GetViewShell()->GetViewFrame() );
784 if (pCare)
786 bool bLimit = false;
787 Rectangle aDlgPixel;
788 Size aWinSize;
789 Window* pWin = GetActiveWin();
790 if (pWin)
792 aDlgPixel = pCare->GetWindowExtentsRelative( pWin );
793 aWinSize = pWin->GetOutputSizePixel();
794 // ueberdeckt der Dialog das GridWin?
795 if ( aDlgPixel.Right() >= 0 && aDlgPixel.Left() < aWinSize.Width() )
797 if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX ||
798 nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY )
799 bLimit = true; // es wird sowieso gescrollt
800 else
802 // Cursor ist auf dem Bildschirm
803 Point aStart = aViewData.GetScrPos( nCurX, nCurY, eAlign );
804 long nCSX, nCSY;
805 aViewData.GetMergeSizePixel( nCurX, nCurY, nCSX, nCSY );
806 Rectangle aCursor( aStart, Size( nCSX, nCSY ) );
807 if ( aCursor.IsOver( aDlgPixel ) )
808 bLimit = true; // Zelle vom Dialog ueberdeckt
813 if (bLimit)
815 bool bBottom = false;
816 long nTopSpace = aDlgPixel.Top();
817 long nBotSpace = aWinSize.Height() - aDlgPixel.Bottom();
818 if ( nBotSpace > 0 && nBotSpace > nTopSpace )
820 long nDlgBot = aDlgPixel.Bottom();
821 SCsCOL nWPosX;
822 SCsROW nWPosY;
823 aViewData.GetPosFromPixel( 0,nDlgBot, eAlign, nWPosX, nWPosY );
824 ++nWPosY; // unter der letzten betroffenen Zelle
826 SCsROW nDiff = nWPosY - nDeltaY;
827 if ( nCurY >= nDiff ) // Pos. kann nicht negativ werden
829 nSpaceY = nDlgBot + ( nBotSpace - nCellSizeY ) / 2;
830 bBottom = true;
831 bForceNew = true;
834 if ( !bBottom && nTopSpace > 0 )
836 nSpaceY = ( nTopSpace - nCellSizeY ) / 2;
837 bForceNew = true;
842 //-------------------------------------------------------------------------------
844 SCsCOL nNewDeltaX = nDeltaX;
845 SCsROW nNewDeltaY = nDeltaY;
846 bool bDoLine = false;
848 switch (eMode)
850 case SC_FOLLOW_JUMP:
851 if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX )
853 nNewDeltaX = nCurX - static_cast<SCsCOL>(aViewData.CellsAtX( nCurX, -1, eAlignX, static_cast<sal_uInt16>(nSpaceX) ));
854 if (nNewDeltaX < 0) nNewDeltaX = 0;
855 nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
857 if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY || bForceNew )
859 nNewDeltaY = nCurY - static_cast<SCsROW>(aViewData.CellsAtY( nCurY, -1, eAlignY, static_cast<sal_uInt16>(nSpaceY) ));
860 if (nNewDeltaY < 0) nNewDeltaY = 0;
861 nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
863 bDoLine = true;
864 break;
866 case SC_FOLLOW_LINE:
867 bDoLine = true;
868 break;
870 case SC_FOLLOW_FIX:
871 if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX )
873 nNewDeltaX = nDeltaX + nCurX - aViewData.GetCurX();
874 if (nNewDeltaX < 0) nNewDeltaX = 0;
875 nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
877 if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY )
879 nNewDeltaY = nDeltaY + nCurY - aViewData.GetCurY();
880 if (nNewDeltaY < 0) nNewDeltaY = 0;
881 nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
884 // like old version of SC_FOLLOW_JUMP:
886 if ( nCurX < nNewDeltaX || nCurX >= nNewDeltaX+nSizeX )
888 nNewDeltaX = nCurX - (nSizeX / 2);
889 if (nNewDeltaX < 0) nNewDeltaX = 0;
890 nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
892 if ( nCurY < nNewDeltaY || nCurY >= nNewDeltaY+nSizeY )
894 nNewDeltaY = nCurY - (nSizeY / 2);
895 if (nNewDeltaY < 0) nNewDeltaY = 0;
896 nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
899 bDoLine = true;
900 break;
902 case SC_FOLLOW_NONE:
903 break;
904 default:
905 OSL_FAIL("Falscher Cursormodus");
906 break;
909 if (bDoLine)
911 while ( nCurX >= nNewDeltaX+nSizeX )
913 nNewDeltaX = nCurX-nSizeX+1;
914 ScDocument* pDoc = aViewData.GetDocument();
915 SCTAB nTab = aViewData.GetTabNo();
916 while ( nNewDeltaX < MAXCOL && !pDoc->GetColWidth( nNewDeltaX, nTab ) )
917 ++nNewDeltaX;
918 nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
920 while ( nCurY >= nNewDeltaY+nSizeY )
922 nNewDeltaY = nCurY-nSizeY+1;
923 ScDocument* pDoc = aViewData.GetDocument();
924 SCTAB nTab = aViewData.GetTabNo();
925 while ( nNewDeltaY < MAXROW && !pDoc->GetRowHeight( nNewDeltaY, nTab ) )
926 ++nNewDeltaY;
927 nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
929 if ( nCurX < nNewDeltaX ) nNewDeltaX = nCurX;
930 if ( nCurY < nNewDeltaY ) nNewDeltaY = nCurY;
933 if ( nNewDeltaX != nDeltaX )
934 nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
935 if (nNewDeltaX+nSizeX-1 > MAXCOL) nNewDeltaX = MAXCOL-nSizeX+1;
936 if (nNewDeltaX < 0) nNewDeltaX = 0;
938 if ( nNewDeltaY != nDeltaY )
939 nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
940 if (nNewDeltaY+nSizeY-1 > MAXROW) nNewDeltaY = MAXROW-nSizeY+1;
941 if (nNewDeltaY < 0) nNewDeltaY = 0;
943 if ( nNewDeltaX != nDeltaX ) ScrollX( nNewDeltaX - nDeltaX, eAlignX );
944 if ( nNewDeltaY != nDeltaY ) ScrollY( nNewDeltaY - nDeltaY, eAlignY );
948 // nochmal aktiven Teil umschalten
951 if (bHFix)
952 if (eActiveX == SC_SPLIT_RIGHT && nCurX < (SCsCOL)aViewData.GetFixPosX())
954 ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT );
955 eActiveX = SC_SPLIT_LEFT;
957 if (bVFix)
958 if (eActiveY == SC_SPLIT_BOTTOM && nCurY < (SCsROW)aViewData.GetFixPosY())
960 ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT );
961 eActiveY = SC_SPLIT_TOP;
965 bool ScTabView::SelMouseButtonDown( const MouseEvent& rMEvt )
967 bool bRet = false;
969 // #i3875# *Hack*
970 bool bMod1Locked = aViewData.GetViewShell()->GetLockedModifiers() & KEY_MOD1 ? true : false;
971 aViewData.SetSelCtrlMouseClick( rMEvt.IsMod1() || bMod1Locked );
973 if ( pSelEngine )
975 bMoveIsShift = rMEvt.IsShift();
976 bRet = pSelEngine->SelMouseButtonDown( rMEvt );
977 bMoveIsShift = false;
980 aViewData.SetSelCtrlMouseClick( false ); // #i3875# *Hack*
982 return bRet;
986 // MoveCursor - mit Anpassung des Bildausschnitts
989 void ScTabView::MoveCursorAbs( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
990 bool bShift, bool bControl, bool bKeepOld, bool bKeepSel )
992 if (!bKeepOld)
993 aViewData.ResetOldCursor();
995 if (nCurX < 0) nCurX = 0;
996 if (nCurY < 0) nCurY = 0;
997 if (nCurX > MAXCOL) nCurX = MAXCOL;
998 if (nCurY > MAXROW) nCurY = MAXROW;
1000 HideAllCursors();
1002 // aktiven Teil umschalten jetzt in AlignToCursor
1004 AlignToCursor( nCurX, nCurY, eMode );
1005 //! auf OS/2: SC_FOLLOW_JUMP statt SC_FOLLOW_LINE, um Nachlaufen zu verhindern ???
1007 if (bKeepSel)
1009 SetCursor( nCurX, nCurY ); // Markierung stehenlassen
1011 // If the cursor is in existing selection, it's a cursor movement by
1012 // ENTER or TAB. If not, then it's a new selection during ADD
1013 // selection mode.
1015 const ScMarkData& rMark = aViewData.GetMarkData();
1016 ScRangeList aSelList;
1017 rMark.FillRangeListWithMarks(&aSelList, false);
1018 if (!aSelList.In(ScRange(nCurX, nCurY, aViewData.GetTabNo())))
1019 // Cursor not in existing selection. Start a new selection.
1020 DoneBlockMode(true);
1022 else
1024 if (!bShift)
1026 // Remove all marked data on cursor movement unless the Shift is locked.
1027 ScMarkData aData(aViewData.GetMarkData());
1028 aData.ResetMark();
1029 SetMarkData(aData);
1032 bool bSame = ( nCurX == aViewData.GetCurX() && nCurY == aViewData.GetCurY() );
1033 bMoveIsShift = bShift;
1034 pSelEngine->CursorPosChanging( bShift, bControl );
1035 bMoveIsShift = false;
1036 aFunctionSet.SetCursorAtCell( nCurX, nCurY, false );
1038 // Wenn der Cursor nicht bewegt wurde, muss das SelectionChanged fuer das
1039 // Aufheben der Selektion hier einzeln passieren:
1040 if (bSame)
1041 SelectionChanged();
1044 ShowAllCursors();
1045 TestHintWindow();
1048 void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
1049 bool bShift, bool bKeepSel )
1051 ScDocument* pDoc = aViewData.GetDocument();
1052 SCTAB nTab = aViewData.GetTabNo();
1054 bool bSkipProtected = false, bSkipUnprotected = false;
1055 ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
1056 if ( pProtect && pProtect->isProtected() )
1058 bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
1059 bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
1062 if ( bSkipProtected && bSkipUnprotected )
1063 return;
1065 SCsCOL nOldX;
1066 SCsROW nOldY;
1067 SCsCOL nCurX;
1068 SCsROW nCurY;
1069 if ( aViewData.IsRefMode() )
1071 nOldX = (SCsCOL) aViewData.GetRefEndX();
1072 nOldY = (SCsROW) aViewData.GetRefEndY();
1073 nCurX = nOldX + nMovX;
1074 nCurY = nOldY + nMovY;
1076 else
1078 nOldX = (SCsCOL) aViewData.GetCurX();
1079 nOldY = (SCsROW) aViewData.GetCurY();
1080 nCurX = (nMovX != 0) ? nOldX+nMovX : (SCsCOL) aViewData.GetOldCurX();
1081 nCurY = (nMovY != 0) ? nOldY+nMovY : (SCsROW) aViewData.GetOldCurY();
1084 aViewData.ResetOldCursor();
1086 if (nMovX != 0 && ValidColRow(nCurX,nCurY))
1087 SkipCursorHorizontal(nCurX, nCurY, nOldX, nMovX);
1089 if (nMovY != 0 && ValidColRow(nCurX,nCurY))
1090 SkipCursorVertical(nCurX, nCurY, nOldY, nMovY);
1092 MoveCursorAbs( nCurX, nCurY, eMode, bShift, false, true, bKeepSel );
1095 void ScTabView::MoveCursorPage( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel )
1097 SCsCOL nPageX;
1098 SCsROW nPageY;
1099 GetPageMoveEndPosition(nMovX, nMovY, nPageX, nPageY);
1100 MoveCursorRel( nPageX, nPageY, eMode, bShift, bKeepSel );
1103 void ScTabView::MoveCursorArea( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel )
1105 SCsCOL nNewX;
1106 SCsROW nNewY;
1107 GetAreaMoveEndPosition(nMovX, nMovY, eMode, nNewX, nNewY, eMode);
1108 MoveCursorRel(nNewX, nNewY, eMode, bShift, bKeepSel);
1111 void ScTabView::MoveCursorEnd( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel )
1113 ScDocument* pDoc = aViewData.GetDocument();
1114 SCTAB nTab = aViewData.GetTabNo();
1116 SCCOL nCurX;
1117 SCROW nCurY;
1118 aViewData.GetMoveCursor( nCurX,nCurY );
1119 SCCOL nNewX = nCurX;
1120 SCROW nNewY = nCurY;
1122 SCCOL nUsedX = 0;
1123 SCROW nUsedY = 0;
1124 if ( nMovX > 0 || nMovY > 0 )
1125 pDoc->GetPrintArea( nTab, nUsedX, nUsedY ); // Ende holen
1127 if (nMovX<0)
1128 nNewX=0;
1129 else if (nMovX>0)
1130 nNewX=nUsedX; // letzter benutzter Bereich
1132 if (nMovY<0)
1133 nNewY=0;
1134 else if (nMovY>0)
1135 nNewY=nUsedY;
1137 aViewData.ResetOldCursor();
1138 MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY, eMode, bShift, bKeepSel );
1141 void ScTabView::MoveCursorScreen( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift )
1143 ScDocument* pDoc = aViewData.GetDocument();
1144 SCTAB nTab = aViewData.GetTabNo();
1146 SCCOL nCurX;
1147 SCROW nCurY;
1148 aViewData.GetMoveCursor( nCurX,nCurY );
1149 SCCOL nNewX = nCurX;
1150 SCROW nNewY = nCurY;
1152 ScSplitPos eWhich = aViewData.GetActivePart();
1153 SCCOL nPosX = aViewData.GetPosX( WhichH(eWhich) );
1154 SCROW nPosY = aViewData.GetPosY( WhichV(eWhich) );
1156 SCCOL nAddX = aViewData.VisibleCellsX( WhichH(eWhich) );
1157 if (nAddX != 0)
1158 --nAddX;
1159 SCROW nAddY = aViewData.VisibleCellsY( WhichV(eWhich) );
1160 if (nAddY != 0)
1161 --nAddY;
1163 if (nMovX<0)
1164 nNewX=nPosX;
1165 else if (nMovX>0)
1166 nNewX=nPosX+nAddX;
1168 if (nMovY<0)
1169 nNewY=nPosY;
1170 else if (nMovY>0)
1171 nNewY=nPosY+nAddY;
1173 aViewData.SetOldCursor( nNewX,nNewY );
1174 pDoc->SkipOverlapped(nNewX, nNewY, nTab);
1175 MoveCursorAbs( nNewX, nNewY, eMode, bShift, false, true );
1178 void ScTabView::MoveCursorEnter( bool bShift ) // bShift -> hoch/runter
1180 const ScInputOptions& rOpt = SC_MOD()->GetInputOptions();
1181 if (!rOpt.GetMoveSelection())
1183 aViewData.UpdateInputHandler(true);
1184 return;
1187 SCsCOL nMoveX = 0;
1188 SCsROW nMoveY = 0;
1189 switch ((ScDirection)rOpt.GetMoveDir())
1191 case DIR_BOTTOM:
1192 nMoveY = bShift ? -1 : 1;
1193 break;
1194 case DIR_RIGHT:
1195 nMoveX = bShift ? -1 : 1;
1196 break;
1197 case DIR_TOP:
1198 nMoveY = bShift ? 1 : -1;
1199 break;
1200 case DIR_LEFT:
1201 nMoveX = bShift ? 1 : -1;
1202 break;
1205 ScMarkData& rMark = aViewData.GetMarkData();
1206 if (rMark.IsMarked() || rMark.IsMultiMarked())
1208 SCCOL nCurX;
1209 SCROW nCurY;
1210 aViewData.GetMoveCursor( nCurX,nCurY );
1211 SCCOL nNewX = nCurX;
1212 SCROW nNewY = nCurY;
1213 SCTAB nTab = aViewData.GetTabNo();
1215 ScDocument* pDoc = aViewData.GetDocument();
1216 pDoc->GetNextPos( nNewX,nNewY, nTab, nMoveX,nMoveY, true, false, rMark );
1218 MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY,
1219 SC_FOLLOW_LINE, false, true );
1221 // update input line even if cursor was not moved
1222 if ( nNewX == nCurX && nNewY == nCurY )
1223 aViewData.UpdateInputHandler(true);
1225 else
1227 if ( nMoveY != 0 && !nMoveX )
1229 // nach Tab und Enter wieder zur Ausgangsspalte
1230 SCCOL nTabCol = aViewData.GetTabStartCol();
1231 if (nTabCol != SC_TABSTART_NONE)
1233 SCCOL nCurX;
1234 SCROW nCurY;
1235 aViewData.GetMoveCursor( nCurX,nCurY );
1236 nMoveX = ((SCsCOL)nTabCol)-(SCsCOL)nCurX;
1240 MoveCursorRel( nMoveX,nMoveY, SC_FOLLOW_LINE, false );
1245 bool ScTabView::MoveCursorKeyInput( const KeyEvent& rKeyEvent )
1247 const KeyCode& rKCode = rKeyEvent.GetKeyCode();
1249 enum { MOD_NONE, MOD_CTRL, MOD_ALT, MOD_BOTH } eModifier =
1250 rKCode.IsMod1() ?
1251 (rKCode.IsMod2() ? MOD_BOTH : MOD_CTRL) :
1252 (rKCode.IsMod2() ? MOD_ALT : MOD_NONE);
1254 bool bSel = rKCode.IsShift();
1255 sal_uInt16 nCode = rKCode.GetCode();
1257 // CURSOR keys
1258 SCsCOL nDX = 0;
1259 SCsROW nDY = 0;
1260 switch( nCode )
1262 case KEY_LEFT: nDX = -1; break;
1263 case KEY_RIGHT: nDX = 1; break;
1264 case KEY_UP: nDY = -1; break;
1265 case KEY_DOWN: nDY = 1; break;
1267 if( nDX != 0 || nDY != 0 )
1269 switch( eModifier )
1271 case MOD_NONE: MoveCursorRel( nDX, nDY, SC_FOLLOW_LINE, bSel ); break;
1272 case MOD_CTRL: MoveCursorArea( nDX, nDY, SC_FOLLOW_JUMP, bSel ); break;
1273 default:
1275 // added to avoid warnings
1278 // always true to suppress changes of col/row size (ALT+CURSOR)
1279 return true;
1282 // PAGEUP/PAGEDOWN
1283 if( (nCode == KEY_PAGEUP) || (nCode == KEY_PAGEDOWN) )
1285 nDX = (nCode == KEY_PAGEUP) ? -1 : 1;
1286 switch( eModifier )
1288 case MOD_NONE: MoveCursorPage( 0, static_cast<SCsCOLROW>(nDX), SC_FOLLOW_FIX, bSel ); break;
1289 case MOD_ALT: MoveCursorPage( nDX, 0, SC_FOLLOW_FIX, bSel ); break;
1290 case MOD_CTRL: SelectNextTab( nDX ); break;
1291 default:
1293 // added to avoid warnings
1296 return true;
1299 // HOME/END
1300 if( (nCode == KEY_HOME) || (nCode == KEY_END) )
1302 nDX = (nCode == KEY_HOME) ? -1 : 1;
1303 ScFollowMode eMode = (nCode == KEY_HOME) ? SC_FOLLOW_LINE : SC_FOLLOW_JUMP;
1304 switch( eModifier )
1306 case MOD_NONE: MoveCursorEnd( nDX, 0, eMode, bSel ); break;
1307 case MOD_CTRL: MoveCursorEnd( nDX, static_cast<SCsCOLROW>(nDX), eMode, bSel ); break;
1308 default:
1310 // added to avoid warnings
1313 return true;
1316 return false;
1320 // naechste/vorherige nicht geschuetzte Zelle
1321 void ScTabView::FindNextUnprot( bool bShift, bool bInSelection )
1323 short nMove = bShift ? -1 : 1;
1325 ScMarkData& rMark = aViewData.GetMarkData();
1326 bool bMarked = bInSelection && (rMark.IsMarked() || rMark.IsMultiMarked());
1328 SCCOL nCurX;
1329 SCROW nCurY;
1330 aViewData.GetMoveCursor( nCurX,nCurY );
1331 SCCOL nNewX = nCurX;
1332 SCROW nNewY = nCurY;
1333 SCTAB nTab = aViewData.GetTabNo();
1335 ScDocument* pDoc = aViewData.GetDocument();
1336 pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, bMarked, true, rMark );
1338 SCCOL nTabCol = aViewData.GetTabStartCol();
1339 if ( nTabCol == SC_TABSTART_NONE )
1340 nTabCol = nCurX; // auf diese Spalte zurueck bei Enter
1342 MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY,
1343 SC_FOLLOW_LINE, false, true );
1345 // in MoveCursorRel wird die TabCol zurueckgesetzt...
1346 aViewData.SetTabStartCol( nTabCol );
1349 void ScTabView::MarkColumns()
1351 SCCOL nStartCol;
1352 SCCOL nEndCol;
1354 ScMarkData& rMark = aViewData.GetMarkData();
1355 if (rMark.IsMarked())
1357 ScRange aMarkRange;
1358 rMark.GetMarkArea( aMarkRange );
1359 nStartCol = aMarkRange.aStart.Col();
1360 nEndCol = aMarkRange.aEnd.Col();
1362 else
1364 SCROW nDummy;
1365 aViewData.GetMoveCursor( nStartCol, nDummy );
1366 nEndCol=nStartCol;
1369 SCTAB nTab = aViewData.GetTabNo();
1370 DoneBlockMode();
1371 InitBlockMode( nStartCol,0, nTab );
1372 MarkCursor( nEndCol,MAXROW, nTab );
1373 SelectionChanged();
1376 void ScTabView::MarkRows()
1378 SCROW nStartRow;
1379 SCROW nEndRow;
1381 ScMarkData& rMark = aViewData.GetMarkData();
1382 if (rMark.IsMarked())
1384 ScRange aMarkRange;
1385 rMark.GetMarkArea( aMarkRange );
1386 nStartRow = aMarkRange.aStart.Row();
1387 nEndRow = aMarkRange.aEnd.Row();
1389 else
1391 SCCOL nDummy;
1392 aViewData.GetMoveCursor( nDummy, nStartRow );
1393 nEndRow=nStartRow;
1396 SCTAB nTab = aViewData.GetTabNo();
1397 DoneBlockMode();
1398 InitBlockMode( 0,nStartRow, nTab );
1399 MarkCursor( MAXCOL,nEndRow, nTab );
1400 SelectionChanged();
1403 void ScTabView::MarkDataArea( bool bIncludeCursor )
1405 ScDocument* pDoc = aViewData.GetDocument();
1406 SCTAB nTab = aViewData.GetTabNo();
1407 SCCOL nStartCol = aViewData.GetCurX();
1408 SCROW nStartRow = aViewData.GetCurY();
1409 SCCOL nEndCol = nStartCol;
1410 SCROW nEndRow = nStartRow;
1412 pDoc->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, bIncludeCursor, false );
1414 HideAllCursors();
1415 DoneBlockMode();
1416 InitBlockMode( nStartCol, nStartRow, nTab );
1417 MarkCursor( nEndCol, nEndRow, nTab );
1418 ShowAllCursors();
1420 SelectionChanged();
1423 void ScTabView::MarkMatrixFormula()
1425 ScDocument* pDoc = aViewData.GetDocument();
1426 ScAddress aCursor( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
1427 ScRange aMatrix;
1428 if ( pDoc->GetMatrixFormulaRange( aCursor, aMatrix ) )
1430 MarkRange( aMatrix, false ); // cursor is already within the range
1434 void ScTabView::MarkRange( const ScRange& rRange, bool bSetCursor, bool bContinue )
1436 SCTAB nTab = rRange.aStart.Tab();
1437 SetTabNo( nTab );
1439 HideAllCursors();
1440 DoneBlockMode( bContinue ); // bContinue==true -> clear old mark
1441 if (bSetCursor) // Wenn Cursor gesetzt wird, immer auch alignen
1443 SCCOL nAlignX = rRange.aStart.Col();
1444 SCROW nAlignY = rRange.aStart.Row();
1445 bool bCol = ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) && !aViewData.GetDocument()->IsInVBAMode();
1446 bool bRow = ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW );
1447 if ( bCol )
1448 nAlignX = aViewData.GetPosX(WhichH(aViewData.GetActivePart()));
1449 if ( bRow )
1450 nAlignY = aViewData.GetPosY(WhichV(aViewData.GetActivePart()));
1451 AlignToCursor( nAlignX, nAlignY, SC_FOLLOW_JUMP );
1453 InitBlockMode( rRange.aStart.Col(), rRange.aStart.Row(), nTab );
1454 MarkCursor( rRange.aEnd.Col(), rRange.aEnd.Row(), nTab );
1455 if (bSetCursor)
1457 SCCOL nPosX = rRange.aStart.Col();
1458 SCROW nPosY = rRange.aStart.Row();
1459 ScDocument* pDoc = aViewData.GetDocument();
1460 pDoc->SkipOverlapped(nPosX, nPosY, nTab);
1462 aViewData.ResetOldCursor();
1463 SetCursor( nPosX, nPosY );
1465 ShowAllCursors();
1467 SelectionChanged();
1470 void ScTabView::Unmark()
1472 ScMarkData& rMark = aViewData.GetMarkData();
1473 if ( rMark.IsMarked() || rMark.IsMultiMarked() )
1475 SCCOL nCurX;
1476 SCROW nCurY;
1477 aViewData.GetMoveCursor( nCurX,nCurY );
1478 MoveCursorAbs( nCurX, nCurY, SC_FOLLOW_NONE, false, false );
1480 SelectionChanged();
1484 void ScTabView::SetMarkData( const ScMarkData& rNew )
1486 DoneBlockMode();
1487 InitOwnBlockMode();
1488 aViewData.GetMarkData() = rNew;
1490 MarkDataChanged();
1493 void ScTabView::MarkDataChanged()
1495 // has to be called after making direct changes to mark data (not via MarkCursor etc)
1497 UpdateSelectionOverlay();
1500 void ScTabView::SelectNextTab( short nDir, bool bExtendSelection )
1502 if (!nDir) return;
1503 OSL_ENSURE( nDir==-1 || nDir==1, "SelectNextTab: falscher Wert");
1505 ScDocument* pDoc = aViewData.GetDocument();
1506 SCTAB nTab = aViewData.GetTabNo();
1507 if (nDir<0)
1509 if (!nTab) return;
1510 --nTab;
1511 while (!pDoc->IsVisible(nTab))
1513 if (!nTab) return;
1514 --nTab;
1517 else
1519 SCTAB nCount = pDoc->GetTableCount();
1520 ++nTab;
1521 if (nTab >= nCount) return;
1522 while (!pDoc->IsVisible(nTab))
1524 ++nTab;
1525 if (nTab >= nCount) return;
1529 SetTabNo( nTab, false, bExtendSelection );
1530 PaintExtras();
1534 // SetTabNo - angezeigte Tabelle
1536 void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSameTabButMoved )
1538 if ( !ValidTab(nTab) )
1540 OSL_FAIL("SetTabNo: falsche Tabelle");
1541 return;
1544 if ( nTab != aViewData.GetTabNo() || bNew )
1546 // Die FormShell moechte vor dem Umschalten benachrichtigt werden
1547 FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell();
1548 if (pFormSh)
1550 bool bAllowed = static_cast<bool>(pFormSh->PrepareClose(true));
1551 if (!bAllowed)
1553 //! Fehlermeldung? oder macht das die FormShell selber?
1554 //! Fehler-Flag zurueckgeben und Aktionen abbrechen
1556 return; // Die FormShell sagt, es kann nicht umgeschaltet werden
1560 // nicht InputEnterHandler wegen Referenzeingabe !
1562 ScDocument* pDoc = aViewData.GetDocument();
1564 pDoc->MakeTable( nTab );
1566 // Update pending row heights before switching the sheet, so Reschedule from the progress bar
1567 // doesn't paint the new sheet with old heights
1568 aViewData.GetDocShell()->UpdatePendingRowHeights( nTab );
1570 SCTAB nTabCount = pDoc->GetTableCount();
1571 SCTAB nOldPos = nTab;
1572 while (!pDoc->IsVisible(nTab)) // naechste sichtbare suchen
1574 bool bUp = (nTab>=nOldPos);
1575 if (bUp)
1577 ++nTab;
1578 if (nTab>=nTabCount)
1580 nTab = nOldPos;
1581 bUp = false;
1585 if (!bUp)
1587 if (nTab != 0)
1588 --nTab;
1589 else
1591 OSL_FAIL("keine sichtbare Tabelle");
1592 pDoc->SetVisible( 0, true );
1597 // #i71490# Deselect drawing objects before changing the sheet number in view data,
1598 // so the handling of notes still has the sheet selected on which the notes are.
1599 DrawDeselectAll();
1601 ScModule* pScMod = SC_MOD();
1602 bool bRefMode = pScMod->IsFormulaMode();
1603 if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert
1605 DoneBlockMode();
1606 pSelEngine->Reset(); // reset all flags, including locked modifiers
1607 aViewData.SetRefTabNo( nTab );
1610 ScSplitPos eOldActive = aViewData.GetActivePart(); // before switching
1611 bool bFocus = pGridWin[eOldActive]->HasFocus();
1613 aViewData.SetTabNo( nTab );
1614 // UpdateShow noch vor SetCursor, damit UpdateAutoFillMark die richtigen
1615 // Fenster findet (wird aus SetCursor gerufen)
1616 UpdateShow();
1617 aViewData.ResetOldCursor();
1619 SfxBindings& rBindings = aViewData.GetBindings();
1620 ScMarkData& rMark = aViewData.GetMarkData();
1622 bool bAllSelected = true;
1623 for (SCTAB nSelTab = 0; nSelTab < nTabCount; ++nSelTab)
1625 if (!pDoc->IsVisible(nSelTab) || rMark.GetTableSelect(nSelTab))
1627 if (nTab == nSelTab)
1628 // This tab is already in selection. Keep the current
1629 // selection.
1630 bExtendSelection = true;
1632 else
1634 bAllSelected = false;
1635 if (bExtendSelection)
1636 // We got what we need. No need to stay in the loop.
1637 break;
1640 if (bAllSelected && !bNew)
1641 // #i6327# if all tables are selected, a selection event (#i6330#) will deselect all
1642 // (not if called with bNew to update settings)
1643 bExtendSelection = false;
1645 if (bExtendSelection)
1646 rMark.SelectTable( nTab, true );
1647 else
1649 rMark.SelectOneTable( nTab );
1650 rBindings.Invalidate( FID_FILL_TAB );
1651 rBindings.Invalidate( FID_TAB_DESELECTALL );
1654 SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), true );
1655 bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
1657 // recalc zoom-dependent values (before TabChanged, before UpdateEditViewPos)
1658 RefreshZoom();
1659 UpdateVarZoom();
1661 if ( bRefMode ) // hide EditView if necessary (after aViewData.SetTabNo !)
1663 for (sal_uInt16 i = 0; i < 4; ++i)
1664 if (pGridWin[i] && pGridWin[i]->IsVisible())
1665 pGridWin[i]->UpdateEditViewPos();
1668 TabChanged(bSameTabButMoved); // DrawView
1669 UpdateVisibleRange();
1671 aViewData.GetViewShell()->WindowChanged(); // falls das aktive Fenster anders ist
1672 if ( !bUnoRefDialog )
1673 aViewData.GetViewShell()->DisconnectAllClients(); // important for floating frames
1674 else
1676 // hide / show inplace client
1678 ScClient* pClient = static_cast<ScClient*>(aViewData.GetViewShell()->GetIPClient());
1679 if ( pClient && pClient->IsObjectInPlaceActive() )
1681 Rectangle aObjArea = pClient->GetObjArea();
1682 if ( nTab == aViewData.GetRefTabNo() )
1684 // move to its original position
1686 SdrOle2Obj* pDrawObj = pClient->GetDrawObj();
1687 if ( pDrawObj )
1689 Rectangle aRect = pDrawObj->GetLogicRect();
1690 MapMode aMapMode( MAP_100TH_MM );
1691 Size aOleSize = pDrawObj->GetOrigObjSize( &aMapMode );
1692 aRect.SetSize( aOleSize );
1693 aObjArea = aRect;
1696 else
1698 // move to an invisible position
1700 aObjArea.SetPos( Point( 0, -2*aObjArea.GetHeight() ) );
1702 pClient->SetObjArea( aObjArea );
1706 if ( bFocus && aViewData.GetActivePart() != eOldActive && !bRefMode )
1707 ActiveGrabFocus(); // grab focus to the pane that's active now
1709 // Fixierungen
1711 bool bResize = false;
1712 if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
1713 if (aViewData.UpdateFixX())
1714 bResize = true;
1715 if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
1716 if (aViewData.UpdateFixY())
1717 bResize = true;
1718 if (bResize)
1719 RepeatResize();
1720 InvalidateSplit();
1722 if ( aViewData.IsPagebreakMode() )
1723 UpdatePageBreakData(); //! asynchron ??
1725 // Form-Layer muss den sichtbaren Ausschnitt der neuen Tabelle kennen
1726 // dafuer muss hier schon der MapMode stimmen
1727 for (sal_uInt16 i=0; i<4; i++)
1728 if (pGridWin[i])
1729 pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
1730 SetNewVisArea();
1732 PaintGrid();
1733 PaintTop();
1734 PaintLeft();
1735 PaintExtras();
1737 DoResize( aBorderPos, aFrameSize );
1738 rBindings.Invalidate( SID_DELETE_PRINTAREA ); // Menue
1739 rBindings.Invalidate( FID_DEL_MANUALBREAKS );
1740 rBindings.Invalidate( FID_RESET_PRINTZOOM );
1741 rBindings.Invalidate( SID_STATUS_DOCPOS ); // Statusbar
1742 rBindings.Invalidate( SID_STATUS_PAGESTYLE ); // Statusbar
1743 rBindings.Invalidate( SID_CURRENTTAB ); // Navigator
1744 rBindings.Invalidate( SID_STYLE_FAMILY2 ); // Gestalter
1745 rBindings.Invalidate( SID_STYLE_FAMILY4 ); // Gestalter
1746 rBindings.Invalidate( SID_TABLES_COUNT );
1748 if(pScMod->IsRefDialogOpen())
1750 sal_uInt16 nCurRefDlgId=pScMod->GetCurRefDlgId();
1751 SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame();
1752 SfxChildWindow* pChildWnd = pViewFrm->GetChildWindow( nCurRefDlgId );
1753 if ( pChildWnd )
1755 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
1756 pRefDlg->ViewShellChanged();
1763 // Paint-Funktionen - nur fuer diese View
1766 void ScTabView::MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow )
1768 DrawDeselectAll();
1770 if (pDrawView)
1771 DrawEnableAnim( false );
1773 EditView* pSpellingView = aViewData.GetSpellingView();
1775 for (sal_uInt16 i=0; i<4; i++)
1776 if (pGridWin[i])
1777 if ( pGridWin[i]->IsVisible() && !aViewData.HasEditView((ScSplitPos)i) )
1779 ScHSplitPos eHWhich = WhichH( (ScSplitPos) i );
1780 ScVSplitPos eVWhich = WhichV( (ScSplitPos) i );
1781 SCCOL nScrX = aViewData.GetPosX( eHWhich );
1782 SCROW nScrY = aViewData.GetPosY( eVWhich );
1784 bool bPosVisible =
1785 ( nCol >= nScrX && nCol <= nScrX + aViewData.VisibleCellsX(eHWhich) + 1 &&
1786 nRow >= nScrY && nRow <= nScrY + aViewData.VisibleCellsY(eVWhich) + 1 );
1788 // for the active part, create edit view even if outside the visible area,
1789 // so input isn't lost (and the edit view may be scrolled into the visible area)
1791 // #i26433# during spelling, the spelling view must be active
1792 if ( bPosVisible || aViewData.GetActivePart() == (ScSplitPos) i ||
1793 ( pSpellingView && aViewData.GetEditView((ScSplitPos) i) == pSpellingView ) )
1795 pGridWin[i]->HideCursor();
1797 pGridWin[i]->DeleteCursorOverlay();
1798 pGridWin[i]->DeleteAutoFillOverlay();
1799 pGridWin[i]->DeleteCopySourceOverlay();
1801 // flush OverlayManager before changing MapMode to text edit
1802 pGridWin[i]->flushOverlayManager();
1804 // MapMode must be set after HideCursor
1805 pGridWin[i]->SetMapMode(aViewData.GetLogicMode());
1807 aViewData.SetEditEngine( (ScSplitPos) i, pEngine, pGridWin[i], nCol, nRow );
1809 if ( !bPosVisible )
1811 // move the edit view area to the real (possibly negative) position,
1812 // or hide if completely above or left of the window
1813 pGridWin[i]->UpdateEditViewPos();
1818 if (aViewData.GetViewShell()->HasAccessibilityObjects())
1819 aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_ENTEREDITMODE));
1822 void ScTabView::UpdateEditView()
1824 ScSplitPos eActive = aViewData.GetActivePart();
1825 for (sal_uInt16 i=0; i<4; i++)
1826 if (aViewData.HasEditView( (ScSplitPos) i ))
1828 EditView* pEditView = aViewData.GetEditView( (ScSplitPos) i );
1829 aViewData.SetEditEngine( (ScSplitPos) i,
1830 static_cast<ScEditEngineDefaulter*>(pEditView->GetEditEngine()),
1831 pGridWin[i], GetViewData()->GetCurX(), GetViewData()->GetCurY() );
1832 if ( (ScSplitPos)i == eActive )
1833 pEditView->ShowCursor( false );
1837 void ScTabView::KillEditView( bool bNoPaint )
1839 sal_uInt16 i;
1840 SCCOL nCol1 = aViewData.GetEditStartCol();
1841 SCROW nRow1 = aViewData.GetEditStartRow();
1842 SCCOL nCol2 = aViewData.GetEditEndCol();
1843 SCROW nRow2 = aViewData.GetEditEndRow();
1844 bool bPaint[4];
1845 bool bNotifyAcc = false;
1847 bool bExtended = nRow1 != nRow2; // Col wird sowieso bis zum Ende gezeichnet
1848 bool bAtCursor = nCol1 <= aViewData.GetCurX() &&
1849 nCol2 >= aViewData.GetCurX() &&
1850 nRow1 == aViewData.GetCurY();
1851 for (i=0; i<4; i++)
1853 bPaint[i] = aViewData.HasEditView( (ScSplitPos) i );
1854 if (bPaint[i])
1855 bNotifyAcc = true;
1858 // #108931#; notify accessibility before all things happen
1859 if ((bNotifyAcc) && (aViewData.GetViewShell()->HasAccessibilityObjects()))
1860 aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_LEAVEEDITMODE));
1862 aViewData.ResetEditView();
1863 for (i=0; i<4; i++)
1864 if (pGridWin[i] && bPaint[i])
1865 if (pGridWin[i]->IsVisible())
1867 pGridWin[i]->ShowCursor();
1869 pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode());
1871 // #i73567# the cell still has to be repainted
1872 if (bExtended || ( bAtCursor && !bNoPaint ))
1874 pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2 );
1875 pGridWin[i]->UpdateSelectionOverlay();
1879 if (pDrawView)
1880 DrawEnableAnim( true );
1882 // GrabFocus immer dann, wenn diese View aktiv ist und
1883 // die Eingabezeile den Focus hat
1885 bool bGrabFocus = false;
1886 if (aViewData.IsActive())
1888 ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
1889 if ( pInputHdl )
1891 ScInputWindow* pInputWin = pInputHdl->GetInputWindow();
1892 if (pInputWin && pInputWin->IsInputActive())
1893 bGrabFocus = true;
1897 if (bGrabFocus)
1899 // So soll es gemacht werden, damit der Sfx es mitbekommt, klappt aber nicht:
1900 //! aViewData.GetViewShell()->GetViewFrame()->GetWindow().GrabFocus();
1901 // deshalb erstmal so:
1902 GetActiveWin()->GrabFocus();
1905 // Cursor-Abfrage erst nach GrabFocus
1907 for (i=0; i<4; i++)
1908 if (pGridWin[i] && pGridWin[i]->IsVisible())
1910 Cursor* pCur = pGridWin[i]->GetCursor();
1911 if (pCur && pCur->IsVisible())
1912 pCur->Hide();
1914 if(bPaint[i])
1916 pGridWin[i]->UpdateCursorOverlay();
1917 pGridWin[i]->UpdateAutoFillOverlay();
1922 void ScTabView::UpdateFormulas()
1924 if ( aViewData.GetDocument()->IsAutoCalcShellDisabled() )
1925 return ;
1927 sal_uInt16 i;
1928 for (i=0; i<4; i++)
1929 if (pGridWin[i])
1930 if (pGridWin[i]->IsVisible())
1931 pGridWin[i]->UpdateFormulas();
1933 if ( aViewData.IsPagebreakMode() )
1934 UpdatePageBreakData(); //! asynchron
1936 UpdateHeaderWidth();
1938 // if in edit mode, adjust edit view area because widths/heights may have changed
1939 if ( aViewData.HasEditView( aViewData.GetActivePart() ) )
1940 UpdateEditView();
1943 // PaintArea -Block neu zeichnen
1945 void ScTabView::PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1946 ScUpdateMode eMode )
1948 SCCOL nCol1;
1949 SCROW nRow1;
1950 SCCOL nCol2;
1951 SCROW nRow2;
1953 PutInOrder( nStartCol, nEndCol );
1954 PutInOrder( nStartRow, nEndRow );
1956 for (size_t i = 0; i < 4; ++i)
1958 if (!pGridWin[i] || !pGridWin[i]->IsVisible())
1959 continue;
1961 ScHSplitPos eHWhich = WhichH( (ScSplitPos) i );
1962 ScVSplitPos eVWhich = WhichV( (ScSplitPos) i );
1963 bool bOut = false;
1965 nCol1 = nStartCol;
1966 nRow1 = nStartRow;
1967 nCol2 = nEndCol;
1968 nRow2 = nEndRow;
1970 SCCOL nScrX = aViewData.GetPosX( eHWhich );
1971 SCROW nScrY = aViewData.GetPosY( eVWhich );
1972 if (nCol1 < nScrX) nCol1 = nScrX;
1973 if (nCol2 < nScrX)
1975 if ( eMode == SC_UPDATE_ALL ) // for UPDATE_ALL, paint anyway
1976 nCol2 = nScrX; // (because of extending strings to the right)
1977 else
1978 bOut = true; // completely outside the window
1980 if (nRow1 < nScrY) nRow1 = nScrY;
1981 if (nRow2 < nScrY) bOut = true;
1983 SCCOL nLastX = nScrX + aViewData.VisibleCellsX( eHWhich ) + 1;
1984 SCROW nLastY = nScrY + aViewData.VisibleCellsY( eVWhich ) + 1;
1985 if (nCol1 > nLastX) bOut = true;
1986 if (nCol2 > nLastX) nCol2 = nLastX;
1987 if (nRow1 > nLastY) bOut = true;
1988 if (nRow2 > nLastY) nRow2 = nLastY;
1990 if (bOut)
1991 continue;
1993 if ( eMode == SC_UPDATE_CHANGED )
1994 pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2, eMode );
1995 else // ALL oder MARKS
1997 bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
1998 long nLayoutSign = bLayoutRTL ? -1 : 1;
2000 Point aStart = aViewData.GetScrPos( nCol1, nRow1, (ScSplitPos) i );
2001 Point aEnd = aViewData.GetScrPos( nCol2+1, nRow2+1, (ScSplitPos) i );
2002 if ( eMode == SC_UPDATE_ALL )
2003 aEnd.X() = bLayoutRTL ? 0 : (pGridWin[i]->GetOutputSizePixel().Width());
2004 aEnd.X() -= nLayoutSign;
2005 aEnd.Y() -= 1;
2007 // #i85232# include area below cells (could be done in GetScrPos?)
2008 if ( eMode == SC_UPDATE_ALL && nRow2 >= MAXROW )
2009 aEnd.Y() = pGridWin[i]->GetOutputSizePixel().Height();
2011 bool bShowChanges = true; //! ...
2012 if (bShowChanges)
2014 aStart.X() -= nLayoutSign; // include change marks
2015 aStart.Y() -= 1;
2018 bool bMarkClipped = aViewData.GetOptions().GetOption( VOPT_CLIPMARKS );
2019 if (bMarkClipped)
2021 // dazu muesste ScColumn::IsEmptyBlock optimiert werden
2022 // (auf Search() umstellen)
2023 //!if ( nCol1 > 0 && !aViewData.GetDocument()->IsBlockEmpty(
2024 //! aViewData.GetTabNo(),
2025 //! 0, nRow1, nCol1-1, nRow2 ) )
2027 long nMarkPixel = (long)( SC_CLIPMARK_SIZE * aViewData.GetPPTX() );
2028 aStart.X() -= nMarkPixel * nLayoutSign;
2029 if (!bShowChanges)
2030 aStart.X() -= nLayoutSign; // cell grid
2034 pGridWin[i]->Invalidate( pGridWin[i]->PixelToLogic( Rectangle( aStart,aEnd ) ) );
2038 // #i79909# Calling UpdateAllOverlays here isn't necessary and would lead to overlay calls from a timer,
2039 // with a wrong MapMode if editing in a cell (reference input).
2040 // #i80499# Overlays need updates in a lot of cases, e.g. changing row/column size,
2041 // or showing/hiding outlines. TODO: selections in inactive windows are vanishing.
2042 // #i84689# With relative conditional formats, PaintArea may be called often (for each changed cell),
2043 // so UpdateAllOverlays was moved to ScTabViewShell::Notify and is called only if PAINT_LEFT/PAINT_TOP
2044 // is set (width or height changed).
2047 void ScTabView::PaintRangeFinderEntry (ScRangeFindData* pData, const SCTAB nTab)
2049 ScRange aRef = pData->aRef;
2050 aRef.Justify(); // Justify fuer die Abfragen unten
2052 if ( aRef.aStart == aRef.aEnd ) //! Tab ignorieren?
2053 aViewData.GetDocument()->ExtendMerge(aRef);
2055 if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
2057 SCCOL nCol1 = aRef.aStart.Col();
2058 SCROW nRow1 = aRef.aStart.Row();
2059 SCCOL nCol2 = aRef.aEnd.Col();
2060 SCROW nRow2 = aRef.aEnd.Row();
2062 // wegnehmen -> Repaint
2063 // SC_UPDATE_MARKS: Invalidate, nicht bis zum Zeilenende
2065 bool bHiddenEdge = false;
2066 SCROW nTmp;
2067 ScDocument* pDoc = aViewData.GetDocument();
2068 while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab) )
2070 --nCol1;
2071 bHiddenEdge = true;
2073 while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab) )
2075 ++nCol2;
2076 bHiddenEdge = true;
2078 nTmp = pDoc->LastVisibleRow(0, nRow1, nTab);
2079 if (!ValidRow(nTmp))
2080 nTmp = 0;
2081 if (nTmp < nRow1)
2083 nRow1 = nTmp;
2084 bHiddenEdge = true;
2086 nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab);
2087 if (!ValidRow(nTmp))
2088 nTmp = MAXROW;
2089 if (nTmp > nRow2)
2091 nRow2 = nTmp;
2092 bHiddenEdge = true;
2095 if ( nCol2 - nCol1 > 1 && nRow2 - nRow1 > 1 && !bHiddenEdge )
2097 // nur an den Raendern entlang
2098 PaintArea( nCol1, nRow1, nCol2, nRow1, SC_UPDATE_MARKS );
2099 PaintArea( nCol1, nRow1+1, nCol1, nRow2-1, SC_UPDATE_MARKS );
2100 PaintArea( nCol2, nRow1+1, nCol2, nRow2-1, SC_UPDATE_MARKS );
2101 PaintArea( nCol1, nRow2, nCol2, nRow2, SC_UPDATE_MARKS );
2103 else // alles am Stueck
2104 PaintArea( nCol1, nRow1, nCol2, nRow2, SC_UPDATE_MARKS );
2108 void ScTabView::PaintRangeFinder( long nNumber )
2110 ScInputHandler* pHdl = SC_MOD()->GetInputHdl( aViewData.GetViewShell() );
2111 if (pHdl)
2113 ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
2114 if ( pRangeFinder && pRangeFinder->GetDocName() == aViewData.GetDocShell()->GetTitle() )
2116 SCTAB nTab = aViewData.GetTabNo();
2117 sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count();
2119 if (nNumber < 0)
2121 for (sal_uInt16 i=0; i<nCount; i++)
2122 PaintRangeFinderEntry(pRangeFinder->GetObject(i),nTab);
2124 else
2126 sal_uInt16 idx = nNumber;
2127 if (idx < nCount)
2128 PaintRangeFinderEntry(pRangeFinder->GetObject(idx),nTab);
2134 // fuer Chart-Daten-Markierung
2136 void ScTabView::AddHighlightRange( const ScRange& rRange, const Color& rColor )
2138 maHighlightRanges.push_back( ScHighlightEntry( rRange, rColor ) );
2140 SCTAB nTab = aViewData.GetTabNo();
2141 if ( nTab >= rRange.aStart.Tab() && nTab <= rRange.aEnd.Tab() )
2142 PaintArea( rRange.aStart.Col(), rRange.aStart.Row(),
2143 rRange.aEnd.Col(), rRange.aEnd.Row(), SC_UPDATE_MARKS );
2146 void ScTabView::ClearHighlightRanges()
2148 SCTAB nTab = aViewData.GetTabNo();
2149 std::vector<ScHighlightEntry>::const_iterator pIter;
2150 for ( pIter = maHighlightRanges.begin(); pIter != maHighlightRanges.end(); ++pIter)
2152 ScRange aRange = pIter->aRef;
2153 if ( nTab >= aRange.aStart.Tab() && nTab <= aRange.aEnd.Tab() )
2154 PaintArea( aRange.aStart.Col(), aRange.aStart.Row(),
2155 aRange.aEnd.Col(), aRange.aEnd.Row(), SC_UPDATE_MARKS );
2158 maHighlightRanges.clear();
2161 void ScTabView::DoChartSelection(
2162 const uno::Sequence< chart2::data::HighlightedRange > & rHilightRanges )
2164 ClearHighlightRanges();
2165 const sal_Unicode sep = ::formula::FormulaCompiler::GetNativeSymbol(ocSep).GetChar(0);
2167 for( sal_Int32 i=0; i<rHilightRanges.getLength(); ++i )
2169 Color aSelColor( rHilightRanges[i].PreferredColor );
2170 ScRangeList aRangeList;
2171 ScDocument* pDoc = aViewData.GetDocShell()->GetDocument();
2172 if( ScRangeStringConverter::GetRangeListFromString(
2173 aRangeList, rHilightRanges[i].RangeRepresentation, pDoc, pDoc->GetAddressConvention(), sep ))
2175 size_t nListSize = aRangeList.size();
2176 for ( size_t j = 0; j < nListSize; ++j )
2178 ScRange* p = aRangeList[j];
2179 if( rHilightRanges[i].Index == - 1 )
2180 AddHighlightRange( *p, aSelColor );
2181 else
2182 AddHighlightRange( lcl_getSubRangeByIndex( *p, rHilightRanges[i].Index ), aSelColor );
2188 // PaintGrid - Datenbereiche neu zeichnen
2190 void ScTabView::PaintGrid()
2192 sal_uInt16 i;
2193 for (i=0; i<4; i++)
2194 if (pGridWin[i])
2195 if (pGridWin[i]->IsVisible())
2196 pGridWin[i]->Invalidate();
2199 // PaintTop - obere Kontrollelemente neu zeichnen
2201 void ScTabView::PaintTop()
2203 sal_uInt16 i;
2204 for (i=0; i<2; i++)
2206 if (pColBar[i])
2207 pColBar[i]->Invalidate();
2208 if (pColOutline[i])
2209 pColOutline[i]->Invalidate();
2213 void ScTabView::CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress)
2215 sal_uInt16 i;
2217 for(i=0; i<4; i++)
2219 if(pGridWin[i])
2221 if(pGridWin[i]->IsVisible())
2223 pGridWin[i]->CreateAnchorHandle(rHdl, rAddress);
2229 void ScTabView::PaintTopArea( SCCOL nStartCol, SCCOL nEndCol )
2231 // Pixel-Position der linken Kante
2233 if ( nStartCol < aViewData.GetPosX(SC_SPLIT_LEFT) ||
2234 nStartCol < aViewData.GetPosX(SC_SPLIT_RIGHT) )
2235 aViewData.RecalcPixPos();
2237 // Fixierung anpassen (UpdateFixX setzt HSplitPos neu)
2239 if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX && nStartCol < aViewData.GetFixPosX() )
2240 if (aViewData.UpdateFixX())
2241 RepeatResize();
2243 // zeichnen
2245 if (nStartCol>0)
2246 --nStartCol; //! allgemeiner ?
2248 bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
2249 long nLayoutSign = bLayoutRTL ? -1 : 1;
2251 for (sal_uInt16 i=0; i<2; i++)
2253 ScHSplitPos eWhich = (ScHSplitPos) i;
2254 if (pColBar[eWhich])
2256 Size aWinSize = pColBar[eWhich]->GetSizePixel();
2257 long nStartX = aViewData.GetScrPos( nStartCol, 0, eWhich ).X();
2258 long nEndX;
2259 if (nEndCol >= MAXCOL)
2260 nEndX = bLayoutRTL ? 0 : ( aWinSize.Width()-1 );
2261 else
2262 nEndX = aViewData.GetScrPos( nEndCol+1, 0, eWhich ).X() - nLayoutSign;
2263 pColBar[eWhich]->Invalidate(
2264 Rectangle( nStartX, 0, nEndX, aWinSize.Height()-1 ) );
2266 if (pColOutline[eWhich])
2267 pColOutline[eWhich]->Invalidate();
2272 // PaintLeft - linke Kontrollelemente neu zeichnen
2274 void ScTabView::PaintLeft()
2276 sal_uInt16 i;
2277 for (i=0; i<2; i++)
2279 if (pRowBar[i])
2280 pRowBar[i]->Invalidate();
2281 if (pRowOutline[i])
2282 pRowOutline[i]->Invalidate();
2286 void ScTabView::PaintLeftArea( SCROW nStartRow, SCROW nEndRow )
2288 // Pixel-Position der oberen Kante
2290 if ( nStartRow < aViewData.GetPosY(SC_SPLIT_TOP) ||
2291 nStartRow < aViewData.GetPosY(SC_SPLIT_BOTTOM) )
2292 aViewData.RecalcPixPos();
2294 // Fixierung anpassen (UpdateFixY setzt VSplitPos neu)
2296 if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX && nStartRow < aViewData.GetFixPosY() )
2297 if (aViewData.UpdateFixY())
2298 RepeatResize();
2300 // zeichnen
2302 if (nStartRow>0)
2303 --nStartRow;
2305 for (sal_uInt16 i=0; i<2; i++)
2307 ScVSplitPos eWhich = (ScVSplitPos) i;
2308 if (pRowBar[eWhich])
2310 Size aWinSize = pRowBar[eWhich]->GetSizePixel();
2311 long nStartY = aViewData.GetScrPos( 0, nStartRow, eWhich ).Y();
2312 long nEndY;
2313 if (nEndRow >= MAXROW)
2314 nEndY = aWinSize.Height()-1;
2315 else
2316 nEndY = aViewData.GetScrPos( 0, nEndRow+1, eWhich ).Y() - 1;
2317 pRowBar[eWhich]->Invalidate(
2318 Rectangle( 0, nStartY, aWinSize.Width()-1, nEndY ) );
2320 if (pRowOutline[eWhich])
2321 pRowOutline[eWhich]->Invalidate();
2325 bool ScTabView::PaintExtras()
2327 bool bRet = false;
2328 ScDocument* pDoc = aViewData.GetDocument();
2329 SCTAB nTab = aViewData.GetTabNo();
2330 if (!pDoc->HasTable(nTab)) // Tabelle geloescht ?
2332 SCTAB nCount = pDoc->GetTableCount();
2333 aViewData.SetTabNo(nCount-1);
2334 bRet = true;
2336 pTabControl->UpdateStatus(); // true = active
2337 return bRet;
2340 void ScTabView::RecalcPPT()
2342 // called after changes that require the PPT values to be recalculated
2343 // (currently from detective operations)
2345 double nOldX = aViewData.GetPPTX();
2346 double nOldY = aViewData.GetPPTY();
2348 aViewData.RefreshZoom(); // pre-calculate new PPT values
2350 bool bChangedX = ( aViewData.GetPPTX() != nOldX );
2351 bool bChangedY = ( aViewData.GetPPTY() != nOldY );
2352 if ( bChangedX || bChangedY )
2354 // call view SetZoom (including draw scale, split update etc)
2355 // and paint only if values changed
2357 Fraction aZoomX = aViewData.GetZoomX();
2358 Fraction aZoomY = aViewData.GetZoomY();
2359 SetZoom( aZoomX, aZoomY, false );
2361 PaintGrid();
2362 if (bChangedX)
2363 PaintTop();
2364 if (bChangedY)
2365 PaintLeft();
2369 void ScTabView::ActivateView( bool bActivate, bool bFirst )
2371 if ( bActivate == aViewData.IsActive() && !bFirst )
2373 // keine Assertion mehr - kommt vor, wenn vorher im Drag&Drop
2374 // auf ein anderes Dokument umgeschaltet wurde
2375 return;
2378 // wird nur bei MDI-(De)Activate gerufen
2379 // aViewData.Activate hinten wegen Cursor-Show bei KillEditView
2380 // Markierung nicht mehr loeschen - wenn an der ViewData Activate(false) gesetzt ist,
2381 // wird die Markierung nicht ausgegeben
2383 if (!bActivate)
2385 ScModule* pScMod = SC_MOD();
2386 bool bRefMode = pScMod->IsFormulaMode();
2388 // Referenzeingabe nicht abbrechen, um Referenzen auf
2389 // andere Dokumente zuzulassen
2391 if (!bRefMode)
2393 // pass view to GetInputHdl, this view may not be current anymore
2394 ScInputHandler* pHdl = SC_MOD()->GetInputHdl(aViewData.GetViewShell());
2395 if (pHdl)
2396 pHdl->EnterHandler();
2400 PaintExtras();
2402 aViewData.Activate(bActivate);
2404 PaintBlock(false); // Repaint, Markierung je nach Active-Status
2406 if (!bActivate)
2407 HideAllCursors(); // Cursor
2408 else if (!bFirst)
2409 ShowAllCursors();
2411 if (bActivate)
2413 if ( bFirst )
2415 ScSplitPos eWin = aViewData.GetActivePart();
2416 OSL_ENSURE( pGridWin[eWin], "rottes Dokument, nicht alle SplitPos in GridWin" );
2417 if ( !pGridWin[eWin] )
2419 eWin = SC_SPLIT_BOTTOMLEFT;
2420 if ( !pGridWin[eWin] )
2422 short i;
2423 for ( i=0; i<4; i++ )
2425 if ( pGridWin[i] )
2427 eWin = (ScSplitPos) i;
2428 break; // for
2431 OSL_ENSURE( i<4, "und BUMM" );
2433 aViewData.SetActivePart( eWin );
2436 // hier nicht mehr selber GrabFocus rufen!
2437 // Wenn das Doc bearbeitet wird, ruft der Sfx selber GrabFocus am Fenster der Shell.
2438 // Wenn es z.B. ein Mailbody ist, darf es den Focus nicht bekommen (Bug #43638#)
2440 UpdateInputContext();
2442 else
2443 pGridWin[aViewData.GetActivePart()]->ClickExtern();
2446 void ScTabView::ActivatePart( ScSplitPos eWhich )
2448 ScSplitPos eOld = aViewData.GetActivePart();
2449 if ( eOld != eWhich )
2451 bInActivatePart = true;
2453 bool bRefMode = SC_MOD()->IsFormulaMode();
2455 // the HasEditView call during SetCursor would fail otherwise
2456 if ( aViewData.HasEditView(eOld) && !bRefMode )
2457 UpdateInputLine();
2459 ScHSplitPos eOldH = WhichH(eOld);
2460 ScVSplitPos eOldV = WhichV(eOld);
2461 ScHSplitPos eNewH = WhichH(eWhich);
2462 ScVSplitPos eNewV = WhichV(eWhich);
2463 bool bTopCap = pColBar[eOldH] && pColBar[eOldH]->IsMouseCaptured();
2464 bool bLeftCap = pRowBar[eOldV] && pRowBar[eOldV]->IsMouseCaptured();
2466 bool bFocus = pGridWin[eOld]->HasFocus();
2467 bool bCapture = pGridWin[eOld]->IsMouseCaptured();
2468 if (bCapture)
2469 pGridWin[eOld]->ReleaseMouse();
2470 pGridWin[eOld]->ClickExtern();
2471 pGridWin[eOld]->HideCursor();
2472 pGridWin[eWhich]->HideCursor();
2473 aViewData.SetActivePart( eWhich );
2475 ScTabViewShell* pShell = aViewData.GetViewShell();
2476 pShell->WindowChanged();
2478 pSelEngine->SetWindow(pGridWin[eWhich]);
2479 pSelEngine->SetWhich(eWhich);
2480 pSelEngine->SetVisibleArea( Rectangle(Point(), pGridWin[eWhich]->GetOutputSizePixel()) );
2482 pGridWin[eOld]->MoveMouseStatus(*pGridWin[eWhich]);
2484 if ( bCapture || pGridWin[eWhich]->IsMouseCaptured() )
2486 // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann
2487 // (SelectionEngine ruft CaptureMouse beim SetWindow)
2488 //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?!
2489 pGridWin[eWhich]->ReleaseMouse();
2490 pGridWin[eWhich]->StartTracking();
2493 if ( bTopCap && pColBar[eNewH] )
2495 pColBar[eOldH]->SetIgnoreMove(true);
2496 pColBar[eNewH]->SetIgnoreMove(false);
2497 pHdrSelEng->SetWindow( pColBar[eNewH] );
2498 long nWidth = pColBar[eNewH]->GetOutputSizePixel().Width();
2499 pHdrSelEng->SetVisibleArea( Rectangle( 0, LONG_MIN, nWidth-1, LONG_MAX ) );
2500 pColBar[eNewH]->CaptureMouse();
2502 if ( bLeftCap && pRowBar[eNewV] )
2504 pRowBar[eOldV]->SetIgnoreMove(true);
2505 pRowBar[eNewV]->SetIgnoreMove(false);
2506 pHdrSelEng->SetWindow( pRowBar[eNewV] );
2507 long nHeight = pRowBar[eNewV]->GetOutputSizePixel().Height();
2508 pHdrSelEng->SetVisibleArea( Rectangle( LONG_MIN, 0, LONG_MAX, nHeight-1 ) );
2509 pRowBar[eNewV]->CaptureMouse();
2511 aHdrFunc.SetWhich(eWhich);
2513 pGridWin[eOld]->ShowCursor();
2514 pGridWin[eWhich]->ShowCursor();
2516 SfxInPlaceClient* pClient = aViewData.GetViewShell()->GetIPClient();
2517 bool bOleActive = ( pClient && pClient->IsObjectInPlaceActive() );
2519 // don't switch ViewShell's active window during RefInput, because the focus
2520 // might change, and subsequent SetReference calls wouldn't find the right EditView
2521 if ( !bRefMode && !bOleActive )
2522 aViewData.GetViewShell()->SetWindow( pGridWin[eWhich] );
2524 if ( bFocus && !aViewData.IsAnyFillMode() && !bRefMode )
2526 // GrabFocus nur, wenn vorher das andere GridWindow den Focus hatte
2527 // (z.B. wegen Suchen & Ersetzen)
2528 pGridWin[eWhich]->GrabFocus();
2531 bInActivatePart = false;
2535 void ScTabView::HideListBox()
2537 for (sal_uInt16 i=0; i<4; i++)
2538 if (pGridWin[i])
2539 pGridWin[i]->ClickExtern();
2542 void ScTabView::UpdateInputContext()
2544 ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
2545 if (pWin)
2546 pWin->UpdateInputContext();
2548 if (pTabControl)
2549 pTabControl->UpdateInputContext();
2552 // GetGridWidth - Breite eines Ausgabebereichs (fuer ViewData)
2554 long ScTabView::GetGridWidth( ScHSplitPos eWhich )
2556 ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
2557 if (pGridWin[eGridWhich])
2558 return pGridWin[eGridWhich]->GetSizePixel().Width();
2559 else
2560 return 0;
2563 // GetGridHeight - Hoehe eines Ausgabebereichs (fuer ViewData)
2565 long ScTabView::GetGridHeight( ScVSplitPos eWhich )
2567 ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
2568 if (pGridWin[eGridWhich])
2569 return pGridWin[eGridWhich]->GetSizePixel().Height();
2570 else
2571 return 0;
2574 void ScTabView::UpdateInputLine()
2576 SC_MOD()->InputEnterHandler();
2579 void ScTabView::ZoomChanged()
2581 ScInputHandler* pHdl = SC_MOD()->GetInputHdl(aViewData.GetViewShell());
2582 if (pHdl)
2583 pHdl->SetRefScale( aViewData.GetZoomX(), aViewData.GetZoomY() );
2585 UpdateFixPos();
2587 UpdateScrollBars();
2589 // VisArea...
2590 // AW: Discussed with NN if there is a reason that new map mode was only set for one window,
2591 // but is not. Setting only on one window causes the first repaint to have the old mapMode
2592 // in three of four views, so the overlay will save the wrong content e.g. when zooming out.
2593 // Changing to setting map mode at all windows.
2594 sal_uInt32 a;
2596 for(a = 0L; a < 4L; a++)
2598 if(pGridWin[a])
2600 pGridWin[a]->SetMapMode(pGridWin[a]->GetDrawMapMode());
2604 SetNewVisArea();
2606 InterpretVisible(); // have everything calculated before painting
2608 SfxBindings& rBindings = aViewData.GetBindings();
2609 rBindings.Invalidate( SID_ATTR_ZOOM );
2610 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
2612 HideNoteMarker();
2614 // AW: To not change too much, use pWin here
2615 ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
2617 if ( pWin && aViewData.HasEditView( aViewData.GetActivePart() ) )
2619 // flush OverlayManager before changing the MapMode
2620 pWin->flushOverlayManager();
2622 // make sure the EditView's position and size are updated
2623 // with the right (logic, not drawing) MapMode
2624 pWin->SetMapMode( aViewData.GetLogicMode() );
2625 UpdateEditView();
2629 void ScTabView::CheckNeedsRepaint()
2631 sal_uInt16 i;
2632 for (i=0; i<4; i++)
2633 if ( pGridWin[i] && pGridWin[i]->IsVisible() )
2634 pGridWin[i]->CheckNeedsRepaint();
2641 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */