LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/view - tabview3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 486 1382 35.2 %
Date: 2012-12-17 Functions: 30 68 44.1 %
Legend: Lines: hit not hit

          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             : 
      20             : #include <rangelst.hxx>
      21             : #include "scitems.hxx"
      22             : #include <editeng/eeitem.hxx>
      23             : 
      24             : 
      25             : #include <editeng/brshitem.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>
      32             : 
      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"
      66             : 
      67             : #include <com/sun/star/chart2/data/HighlightedRange.hpp>
      68             : 
      69             : namespace
      70             : {
      71             : 
      72           0 : ScRange lcl_getSubRangeByIndex( const ScRange& rRange, sal_Int32 nIndex )
      73             : {
      74           0 :     ScAddress aResult( rRange.aStart );
      75             : 
      76           0 :     SCCOL nWidth = rRange.aEnd.Col() - rRange.aStart.Col() + 1;
      77           0 :     SCROW nHeight = rRange.aEnd.Row() - rRange.aStart.Row() + 1;
      78           0 :     SCTAB nDepth = rRange.aEnd.Tab() - rRange.aStart.Tab() + 1;
      79           0 :     if( (nWidth > 0) && (nHeight > 0) && (nDepth > 0) )
      80             :     {
      81             :         // row by row from first to last sheet
      82           0 :         sal_Int32 nArea = nWidth * nHeight;
      83           0 :         aResult.IncCol( static_cast< SCsCOL >( nIndex % nWidth ) );
      84           0 :         aResult.IncRow( static_cast< SCsROW >( (nIndex % nArea) / nWidth ) );
      85           0 :         aResult.IncTab( static_cast< SCsTAB >( nIndex / nArea ) );
      86           0 :         if( !rRange.In( aResult ) )
      87           0 :             aResult = rRange.aStart;
      88             :     }
      89             : 
      90           0 :     return ScRange( aResult );
      91             : }
      92             : 
      93             : } // anonymous namespace
      94             : 
      95             : using namespace com::sun::star;
      96             : 
      97             : // -----------------------------------------------------------------------
      98             : 
      99             : //
     100             : // ---  Public-Funktionen
     101             : //
     102             : 
     103           0 : void ScTabView::ClickCursor( SCCOL nPosX, SCROW nPosY, bool bControl )
     104             : {
     105           0 :     ScDocument* pDoc = aViewData.GetDocument();
     106           0 :     SCTAB nTab = aViewData.GetTabNo();
     107           0 :     pDoc->SkipOverlapped(nPosX, nPosY, nTab);
     108             : 
     109           0 :     bool bRefMode = SC_MOD()->IsFormulaMode();
     110             : 
     111           0 :     if ( bRefMode )
     112             :     {
     113           0 :         DoneRefMode( false );
     114             : 
     115           0 :         if (bControl)
     116           0 :             SC_MOD()->AddRefEntry();
     117             : 
     118           0 :         InitRefMode( nPosX, nPosY, nTab, SC_REFTYPE_REF );
     119             :     }
     120             :     else
     121             :     {
     122           0 :         DoneBlockMode( bControl );
     123           0 :         aViewData.ResetOldCursor();
     124           0 :         SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
     125             :     }
     126           0 : }
     127             : 
     128         188 : void ScTabView::UpdateAutoFillMark()
     129             : {
     130             :     // single selection or cursor
     131         188 :     ScRange aMarkRange;
     132         188 :     bool bMarked = (aViewData.GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE);
     133             : 
     134             :     sal_uInt16 i;
     135         940 :     for (i=0; i<4; i++)
     136         752 :         if (pGridWin[i] && pGridWin[i]->IsVisible())
     137         158 :             pGridWin[i]->UpdateAutoFillMark( bMarked, aMarkRange );
     138             : 
     139         564 :     for (i=0; i<2; i++)
     140             :     {
     141         376 :         if (pColBar[i] && pColBar[i]->IsVisible())
     142         188 :             pColBar[i]->SetMark( bMarked, aMarkRange.aStart.Col(), aMarkRange.aEnd.Col() );
     143         376 :         if (pRowBar[i] && pRowBar[i]->IsVisible())
     144         188 :             pRowBar[i]->SetMark( bMarked, aMarkRange.aStart.Row(), aMarkRange.aEnd.Row() );
     145             :     }
     146             : 
     147             :     //  selection transfer object is checked together with AutoFill marks,
     148             :     //  because it has the same requirement of a single continuous block.
     149         188 :     CheckSelectionTransfer();   // update selection transfer object
     150         188 : }
     151             : 
     152           0 : void ScTabView::FakeButtonUp( ScSplitPos eWhich )
     153             : {
     154           0 :     if (pGridWin[eWhich])
     155           0 :         pGridWin[eWhich]->FakeButtonUp();
     156           0 : }
     157             : 
     158          64 : void ScTabView::HideAllCursors()
     159             : {
     160         320 :     for (sal_uInt16 i=0; i<4; i++)
     161         256 :         if (pGridWin[i])
     162          64 :             if (pGridWin[i]->IsVisible())
     163             :             {
     164          64 :                 Cursor* pCur = pGridWin[i]->GetCursor();
     165          64 :                 if (pCur)
     166           0 :                     if (pCur->IsVisible())
     167           0 :                         pCur->Hide();
     168          64 :                 pGridWin[i]->HideCursor();
     169             :             }
     170          64 : }
     171             : 
     172          38 : void ScTabView::ShowAllCursors()
     173             : {
     174         190 :     for (sal_uInt16 i=0; i<4; i++)
     175         152 :         if (pGridWin[i])
     176          38 :             if (pGridWin[i]->IsVisible())
     177             :             {
     178          38 :                 pGridWin[i]->ShowCursor();
     179             : 
     180             :                 // #114409#
     181          38 :                 pGridWin[i]->CursorChanged();
     182             :             }
     183          38 : }
     184             : 
     185           0 : void ScTabView::ShowCursor()
     186             : {
     187           0 :     pGridWin[aViewData.GetActivePart()]->ShowCursor();
     188             : 
     189             :     // #114409#
     190           0 :     pGridWin[aViewData.GetActivePart()]->CursorChanged();
     191           0 : }
     192             : 
     193          38 : void ScTabView::InvalidateAttribs()
     194             : {
     195          38 :     SfxBindings& rBindings = aViewData.GetBindings();
     196             : 
     197          38 :     rBindings.Invalidate( SID_STYLE_APPLY );
     198          38 :     rBindings.Invalidate( SID_STYLE_FAMILY2 );
     199             :     // StarCalc kennt nur Absatz- bzw. Zellformat-Vorlagen
     200             : 
     201          38 :     rBindings.Invalidate( SID_ATTR_CHAR_FONT );
     202          38 :     rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
     203          38 :     rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
     204             : 
     205          38 :     rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
     206          38 :     rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
     207          38 :     rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
     208          38 :     rBindings.Invalidate( SID_ULINE_VAL_NONE );
     209          38 :     rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
     210          38 :     rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
     211          38 :     rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
     212             : 
     213          38 :     rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
     214             : 
     215          38 :     rBindings.Invalidate( SID_ALIGNLEFT );
     216          38 :     rBindings.Invalidate( SID_ALIGNRIGHT );
     217          38 :     rBindings.Invalidate( SID_ALIGNBLOCK );
     218          38 :     rBindings.Invalidate( SID_ALIGNCENTERHOR );
     219             : 
     220          38 :     rBindings.Invalidate( SID_ALIGNTOP );
     221          38 :     rBindings.Invalidate( SID_ALIGNBOTTOM );
     222          38 :     rBindings.Invalidate( SID_ALIGNCENTERVER );
     223             : 
     224          38 :     rBindings.Invalidate( SID_BACKGROUND_COLOR );
     225             : 
     226          38 :     rBindings.Invalidate( SID_ATTR_ALIGN_LINEBREAK );
     227          38 :     rBindings.Invalidate( SID_NUMBER_FORMAT );
     228             : 
     229          38 :     rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
     230          38 :     rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
     231          38 :     rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
     232          38 :     rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
     233             : 
     234             :     // pseudo slots for Format menu
     235          38 :     rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
     236          38 :     rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
     237          38 :     rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
     238          38 :     rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
     239          38 :     rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
     240          38 :     rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
     241          38 :     rBindings.Invalidate( SID_ALIGN_ANY_TOP );
     242          38 :     rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
     243          38 :     rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
     244             : 
     245          38 :     rBindings.Invalidate( SID_NUMBER_CURRENCY );
     246          38 :     rBindings.Invalidate( SID_NUMBER_SCIENTIFIC );
     247          38 :     rBindings.Invalidate( SID_NUMBER_DATE );
     248          38 :     rBindings.Invalidate( SID_NUMBER_CURRENCY );
     249          38 :     rBindings.Invalidate( SID_NUMBER_PERCENT );
     250          38 :     rBindings.Invalidate( SID_NUMBER_TIME );
     251          38 : }
     252             : 
     253             : //      SetCursor - Cursor setzen, zeichnen, InputWin updaten
     254             : //                  oder Referenz verschicken
     255             : //      ohne Optimierung wegen BugId 29307
     256             : 
     257             : #ifdef _MSC_VER
     258             : #pragma optimize ( "", off )
     259             : #endif
     260             : 
     261          38 : void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
     262             : {
     263          38 :     SCCOL nOldX = aViewData.GetCurX();
     264          38 :     SCROW nOldY = aViewData.GetCurY();
     265             : 
     266             :     //  DeactivateIP nur noch bei MarkListHasChanged
     267             : 
     268          38 :     if ( nPosX != nOldX || nPosY != nOldY || bNew )
     269             :     {
     270          38 :         ScTabViewShell* pViewShell = aViewData.GetViewShell();
     271          38 :         bool bRefMode = ( pViewShell ? pViewShell->IsRefInputMode() : false );
     272          38 :         if ( aViewData.HasEditView( aViewData.GetActivePart() ) && !bRefMode ) // 23259 oder so
     273             :         {
     274           0 :             UpdateInputLine();
     275             :         }
     276             : 
     277          38 :         HideAllCursors();
     278             : 
     279          38 :         aViewData.SetCurX( nPosX );
     280          38 :         aViewData.SetCurY( nPosY );
     281             : 
     282          38 :         ShowAllCursors();
     283             : 
     284          38 :         CursorPosChanged();
     285             :     }
     286          38 : }
     287             : 
     288             : #ifdef _MSC_VER
     289             : #pragma optimize ( "", on )
     290             : #endif
     291             : 
     292         218 : void ScTabView::CheckSelectionTransfer()
     293             : {
     294         218 :     if ( aViewData.IsActive() )     // only for active view
     295             :     {
     296         216 :         ScModule* pScMod = SC_MOD();
     297         216 :         ScSelectionTransferObj* pOld = pScMod->GetSelectionTransfer();
     298         216 :         if ( pOld && pOld->GetView() == this && pOld->StillValid() )
     299             :         {
     300             :             // selection not changed - nothing to do
     301             :         }
     302             :         else
     303             :         {
     304         216 :             ScSelectionTransferObj* pNew = ScSelectionTransferObj::CreateFromView( this );
     305         216 :             if ( pNew )
     306             :             {
     307             :                 //  create new selection
     308             : 
     309           0 :                 if (pOld)
     310           0 :                     pOld->ForgetView();
     311             : 
     312           0 :                 uno::Reference<datatransfer::XTransferable> xRef( pNew );
     313           0 :                 pScMod->SetSelectionTransfer( pNew );
     314           0 :                 pNew->CopyToSelection( GetActiveWin() );                    // may delete pOld
     315             :             }
     316         216 :             else if ( pOld && pOld->GetView() == this )
     317             :             {
     318             :                 //  remove own selection
     319             : 
     320           0 :                 pOld->ForgetView();
     321           0 :                 pScMod->SetSelectionTransfer( NULL );
     322           0 :                 TransferableHelper::ClearSelection( GetActiveWin() );       // may delete pOld
     323             :             }
     324             :             // else: selection from outside: leave unchanged
     325             :         }
     326             :     }
     327         218 : }
     328             : 
     329             : // Eingabezeile / Menues updaten
     330             : //  CursorPosChanged ruft SelectionChanged
     331             : //  SelectionChanged ruft CellContentChanged
     332             : 
     333          38 : void ScTabView::CellContentChanged()
     334             : {
     335          38 :     SfxBindings& rBindings = aViewData.GetBindings();
     336             : 
     337          38 :     rBindings.Invalidate( SID_ATTR_SIZE );      // -> Fehlermeldungen anzeigen
     338          38 :     rBindings.Invalidate( SID_THESAURUS );
     339          38 :     rBindings.Invalidate( SID_HYPERLINK_GETLINK );
     340             : 
     341          38 :     InvalidateAttribs();                    // Attribut-Updates
     342             : 
     343          38 :     aViewData.GetViewShell()->UpdateInputHandler();
     344          38 : }
     345             : 
     346          38 : void ScTabView::SelectionChanged()
     347             : {
     348          38 :     SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
     349          38 :     if (pViewFrame)
     350             :     {
     351          38 :         uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
     352          38 :         if (xController.is())
     353             :         {
     354          38 :             ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
     355          38 :             if (pImp)
     356          38 :                 pImp->SelectionChanged();
     357          38 :         }
     358             :     }
     359             : 
     360          38 :     UpdateAutoFillMark();   // also calls CheckSelectionTransfer
     361             : 
     362          38 :     SfxBindings& rBindings = aViewData.GetBindings();
     363             : 
     364          38 :     rBindings.Invalidate( SID_CURRENTCELL );    // -> Navigator
     365          38 :     rBindings.Invalidate( SID_AUTO_FILTER );    // -> Menue
     366          38 :     rBindings.Invalidate( FID_NOTE_VISIBLE );
     367          38 :     rBindings.Invalidate( SID_DELETE_NOTE );
     368             : 
     369             :         //  Funktionen, die evtl disabled werden muessen
     370             : 
     371          38 :     rBindings.Invalidate( FID_INS_ROWBRK );
     372          38 :     rBindings.Invalidate( FID_INS_COLBRK );
     373          38 :     rBindings.Invalidate( FID_DEL_ROWBRK );
     374          38 :     rBindings.Invalidate( FID_DEL_COLBRK );
     375          38 :     rBindings.Invalidate( FID_MERGE_ON );
     376          38 :     rBindings.Invalidate( FID_MERGE_OFF );
     377          38 :     rBindings.Invalidate( FID_MERGE_TOGGLE );
     378          38 :     rBindings.Invalidate( SID_AUTOFILTER_HIDE );
     379          38 :     rBindings.Invalidate( SID_UNFILTER );
     380          38 :     rBindings.Invalidate( SID_REIMPORT_DATA );
     381          38 :     rBindings.Invalidate( SID_REFRESH_DBAREA );
     382          38 :     rBindings.Invalidate( SID_OUTLINE_SHOW );
     383          38 :     rBindings.Invalidate( SID_OUTLINE_HIDE );
     384          38 :     rBindings.Invalidate( SID_OUTLINE_REMOVE );
     385          38 :     rBindings.Invalidate( FID_FILL_TO_BOTTOM );
     386          38 :     rBindings.Invalidate( FID_FILL_TO_RIGHT );
     387          38 :     rBindings.Invalidate( FID_FILL_TO_TOP );
     388          38 :     rBindings.Invalidate( FID_FILL_TO_LEFT );
     389          38 :     rBindings.Invalidate( FID_FILL_SERIES );
     390          38 :     rBindings.Invalidate( SID_SCENARIOS );
     391          38 :     rBindings.Invalidate( SID_AUTOFORMAT );
     392          38 :     rBindings.Invalidate( SID_OPENDLG_TABOP );
     393          38 :     rBindings.Invalidate( SID_DATA_SELECT );
     394             : 
     395          38 :     rBindings.Invalidate( SID_CUT );
     396          38 :     rBindings.Invalidate( SID_COPY );
     397          38 :     rBindings.Invalidate( SID_PASTE );
     398          38 :     rBindings.Invalidate( SID_PASTE_SPECIAL );
     399             : 
     400          38 :     rBindings.Invalidate( FID_INS_ROW );
     401          38 :     rBindings.Invalidate( FID_INS_COLUMN );
     402          38 :     rBindings.Invalidate( FID_INS_CELL );
     403          38 :     rBindings.Invalidate( FID_INS_CELLSDOWN );
     404          38 :     rBindings.Invalidate( FID_INS_CELLSRIGHT );
     405             : 
     406          38 :     rBindings.Invalidate( FID_CHG_COMMENT );
     407             : 
     408             :         //  nur wegen Zellschutz:
     409             : 
     410          38 :     rBindings.Invalidate( SID_CELL_FORMAT_RESET );
     411          38 :     rBindings.Invalidate( SID_DELETE );
     412          38 :     rBindings.Invalidate( SID_DELETE_CONTENTS );
     413          38 :     rBindings.Invalidate( FID_DELETE_CELL );
     414          38 :     rBindings.Invalidate( FID_CELL_FORMAT );
     415          38 :     rBindings.Invalidate( SID_ENABLE_HYPHENATION );
     416          38 :     rBindings.Invalidate( SID_INSERT_POSTIT );
     417          38 :     rBindings.Invalidate( SID_CHARMAP );
     418          38 :     rBindings.Invalidate( SID_OPENDLG_FUNCTION );
     419          38 :     rBindings.Invalidate( FID_VALIDATION );
     420          38 :     rBindings.Invalidate( SID_EXTERNAL_SOURCE );
     421          38 :     rBindings.Invalidate( SID_TEXT_TO_COLUMNS );
     422          38 :     rBindings.Invalidate( SID_SORT_ASCENDING );
     423          38 :     rBindings.Invalidate( SID_SORT_DESCENDING );
     424             : 
     425          38 :     if (aViewData.GetViewShell()->HasAccessibilityObjects())
     426           0 :         aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_CURSORCHANGED));
     427             : 
     428          38 :     CellContentChanged();
     429          38 : }
     430             : 
     431          38 : void ScTabView::CursorPosChanged()
     432             : {
     433          38 :     bool bRefMode = SC_MOD()->IsFormulaMode();
     434          38 :     if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert
     435          38 :         aViewData.GetDocShell()->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
     436             : 
     437             :     //  Broadcast, damit andere Views des Dokuments auch umschalten
     438             : 
     439          38 :     ScDocument* pDoc = aViewData.GetDocument();
     440             :     bool bDP = NULL != pDoc->GetDPAtCursor(
     441          38 :         aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
     442          38 :     aViewData.GetViewShell()->SetPivotShell(bDP);
     443             : 
     444             :     //  UpdateInputHandler jetzt in CellContentChanged
     445             : 
     446          38 :     SelectionChanged();
     447             : 
     448          38 :     aViewData.SetTabStartCol( SC_TABSTART_NONE );
     449          38 : }
     450             : 
     451             : namespace {
     452             : 
     453           0 : Point calcHintWindowPosition(
     454             :     const Point& rCellPos, const Size& rCellSize, const Size& rFrameWndSize, const Size& rHintWndSize)
     455             : {
     456           0 :     const long nMargin = 20;
     457             : 
     458           0 :     long nMLeft = rCellPos.X();
     459           0 :     long nMRight = rFrameWndSize.Width() - rCellPos.X() - rCellSize.Width();
     460           0 :     long nMTop = rCellPos.Y();
     461           0 :     long nMBottom = rFrameWndSize.Height() - rCellPos.Y() - rCellSize.Height();
     462             : 
     463             :     // First, see if we can fit the entire hint window in the visible region.
     464             : 
     465           0 :     if (nMRight - nMargin >= rHintWndSize.Width())
     466             :     {
     467             :         // Right margin is wide enough.
     468           0 :         if (rFrameWndSize.Height() >= rHintWndSize.Height())
     469             :         {
     470             :             // The frame has enough height.  Take it.
     471           0 :             Point aPos = rCellPos;
     472           0 :             aPos.X() += rCellSize.Width() + nMargin;
     473           0 :             if (aPos.Y() + rHintWndSize.Height() > rFrameWndSize.Height())
     474             :             {
     475             :                 // Push the hint window up a bit to make it fit.
     476           0 :                 aPos.Y() = rFrameWndSize.Height() - rHintWndSize.Height();
     477             :             }
     478           0 :             return aPos;
     479             :         }
     480             :     }
     481             : 
     482           0 :     if (nMBottom - nMargin >= rHintWndSize.Height())
     483             :     {
     484             :         // Bottom margin is high enough.
     485           0 :         if (rFrameWndSize.Width() >= rHintWndSize.Width())
     486             :         {
     487             :             // The frame has enough width.  Take it.
     488           0 :             Point aPos = rCellPos;
     489           0 :             aPos.Y() += rCellSize.Height() + nMargin;
     490           0 :             if (aPos.X() + rHintWndSize.Width() > rFrameWndSize.Width())
     491             :             {
     492             :                 // Move the hint window to the left to make it fit.
     493           0 :                 aPos.X() = rFrameWndSize.Width() - rHintWndSize.Width();
     494             :             }
     495           0 :             return aPos;
     496             :         }
     497             :     }
     498             : 
     499           0 :     if (nMLeft - nMargin >= rHintWndSize.Width())
     500             :     {
     501             :         // Left margin is wide enough.
     502           0 :         if (rFrameWndSize.Height() >= rHintWndSize.Height())
     503             :         {
     504             :             // The frame is high enough.  Take it.
     505           0 :             Point aPos = rCellPos;
     506           0 :             aPos.X() -= rHintWndSize.Width() + nMargin;
     507           0 :             if (aPos.Y() + rHintWndSize.Height() > rFrameWndSize.Height())
     508             :             {
     509             :                 // Push the hint window up a bit to make it fit.
     510           0 :                 aPos.Y() = rFrameWndSize.Height() - rHintWndSize.Height();
     511             :             }
     512           0 :             return aPos;
     513             :         }
     514             :     }
     515             : 
     516           0 :     if (nMTop - nMargin >= rHintWndSize.Height())
     517             :     {
     518             :         // Top margin is high enough.
     519           0 :         if (rFrameWndSize.Width() >= rHintWndSize.Width())
     520             :         {
     521             :             // The frame is wide enough.  Take it.
     522           0 :             Point aPos = rCellPos;
     523           0 :             aPos.Y() -= rHintWndSize.Height() + nMargin;
     524           0 :             if (aPos.X() + rHintWndSize.Width() > rFrameWndSize.Width())
     525             :             {
     526             :                 // Move the hint window to the left to make it fit.
     527           0 :                 aPos.X() = rFrameWndSize.Width() - rHintWndSize.Width();
     528             :             }
     529           0 :             return aPos;
     530             :         }
     531             :     }
     532             : 
     533             :     // The popup doesn't fit in any direction in its entirety.  Do our best.
     534             : 
     535           0 :     if (nMRight - nMargin >= rHintWndSize.Width())
     536             :     {
     537             :         // Right margin is good enough.
     538           0 :         Point aPos = rCellPos;
     539           0 :         aPos.X() += nMargin + rCellSize.Width();
     540           0 :         aPos.Y() = 0;
     541           0 :         return aPos;
     542             :     }
     543             : 
     544           0 :     if (nMBottom - nMargin >= rHintWndSize.Height())
     545             :     {
     546             :         // Bottom margin is good enough.
     547           0 :         Point aPos = rCellPos;
     548           0 :         aPos.Y() += nMargin + rCellSize.Height();
     549           0 :         aPos.X() = 0;
     550           0 :         return aPos;
     551             :     }
     552             : 
     553           0 :     if (nMLeft - nMargin >= rHintWndSize.Width())
     554             :     {
     555             :         // Left margin is good enough.
     556           0 :         Point aPos = rCellPos;
     557           0 :         aPos.X() -= rHintWndSize.Width() + nMargin;
     558           0 :         aPos.Y() = 0;
     559           0 :         return aPos;
     560             :     }
     561             : 
     562           0 :     if (nMTop - nMargin >= rHintWndSize.Height())
     563             :     {
     564             :         // Top margin is good enough.
     565           0 :         Point aPos = rCellPos;
     566           0 :         aPos.Y() -= rHintWndSize.Height() + nMargin;
     567           0 :         aPos.X() = 0;
     568           0 :         return aPos;
     569             :     }
     570             : 
     571             :     // None of the above.  Hopeless.  At least try not to cover the current
     572             :     // cell.
     573           0 :     Point aPos = rCellPos;
     574           0 :     aPos.X() += rCellSize.Width();
     575           0 :     return aPos;
     576             : }
     577             : 
     578             : }
     579             : 
     580          60 : void ScTabView::TestHintWindow()
     581             : {
     582             :     //  show input help window and list drop-down button for validity
     583             : 
     584          60 :     bool bListValButton = false;
     585          60 :     ScAddress aListValPos;
     586             : 
     587          60 :     ScDocument* pDoc = aViewData.GetDocument();
     588             :     const SfxUInt32Item* pItem = (const SfxUInt32Item*)
     589          60 :                                         pDoc->GetAttr( aViewData.GetCurX(),
     590             :                                                        aViewData.GetCurY(),
     591          60 :                                                        aViewData.GetTabNo(),
     592         120 :                                                        ATTR_VALIDDATA );
     593          60 :     if ( pItem->GetValue() )
     594             :     {
     595           0 :         const ScValidationData* pData = pDoc->GetValidationEntry( pItem->GetValue() );
     596             :         OSL_ENSURE(pData,"ValidationData nicht gefunden");
     597           0 :         String aTitle, aMessage;
     598           0 :         if ( pData && pData->GetInput( aTitle, aMessage ) && aMessage.Len() > 0 )
     599             :         {
     600             :             //! Abfrage, ob an gleicher Stelle !!!!
     601             : 
     602           0 :             mpInputHintWindow.reset();
     603             : 
     604           0 :             ScSplitPos eWhich = aViewData.GetActivePart();
     605           0 :             ScGridWindow* pWin = pGridWin[eWhich];
     606           0 :             SCCOL nCol = aViewData.GetCurX();
     607           0 :             SCROW nRow = aViewData.GetCurY();
     608           0 :             Point aPos = aViewData.GetScrPos( nCol, nRow, eWhich );
     609           0 :             Size aWinSize = pWin->GetOutputSizePixel();
     610             :             //  Cursor sichtbar?
     611           0 :             if ( nCol >= aViewData.GetPosX(WhichH(eWhich)) &&
     612           0 :                  nRow >= aViewData.GetPosY(WhichV(eWhich)) &&
     613           0 :                  aPos.X() < aWinSize.Width() && aPos.Y() < aWinSize.Height() )
     614             :             {
     615             :                 // HintWindow anlegen, bestimmt seine Groesse selbst
     616           0 :                 mpInputHintWindow.reset(new ScHintWindow(pWin, aTitle, aMessage));
     617           0 :                 Size aHintWndSize = mpInputHintWindow->GetSizePixel();
     618           0 :                 long nCellSizeX = 0;
     619           0 :                 long nCellSizeY = 0;
     620           0 :                 aViewData.GetMergeSizePixel(nCol, nRow, nCellSizeX, nCellSizeY);
     621             : 
     622             :                 Point aHintPos = calcHintWindowPosition(
     623           0 :                     aPos, Size(nCellSizeX,nCellSizeY), aWinSize, aHintWndSize);
     624             : 
     625           0 :                 mpInputHintWindow->SetPosPixel( aHintPos );
     626           0 :                 mpInputHintWindow->ToTop();
     627           0 :                 mpInputHintWindow->Show();
     628             :             }
     629             :         }
     630             :         else
     631           0 :             mpInputHintWindow.reset();
     632             : 
     633             :         // list drop-down button
     634           0 :         if ( pData && pData->HasSelectionList() )
     635             :         {
     636           0 :             aListValPos.Set( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
     637           0 :             bListValButton = true;
     638           0 :         }
     639             :     }
     640             :     else
     641          60 :         mpInputHintWindow.reset();
     642             : 
     643         300 :     for ( sal_uInt16 i=0; i<4; i++ )
     644         240 :         if ( pGridWin[i] && pGridWin[i]->IsVisible() )
     645          30 :             pGridWin[i]->UpdateListValPos( bListValButton, aListValPos );
     646          60 : }
     647             : 
     648         182 : bool ScTabView::HasHintWindow() const
     649             : {
     650         182 :     return mpInputHintWindow.get() != NULL;
     651             : }
     652             : 
     653           0 : void ScTabView::RemoveHintWindow()
     654             : {
     655           0 :     mpInputHintWindow.reset();
     656           0 : }
     657             : 
     658             : 
     659             : // find window that should not be over the cursor
     660           0 : static Window* lcl_GetCareWin(SfxViewFrame* pViewFrm)
     661             : {
     662             :     //! auch Spelling ??? (dann beim Aufruf Membervariable setzen)
     663             : 
     664             :     //  Suchen & Ersetzen
     665           0 :     if ( pViewFrm->HasChildWindow(SID_SEARCH_DLG) )
     666             :     {
     667           0 :         SfxChildWindow* pChild = pViewFrm->GetChildWindow(SID_SEARCH_DLG);
     668           0 :         if (pChild)
     669             :         {
     670           0 :             Window* pWin = pChild->GetWindow();
     671           0 :             if (pWin && pWin->IsVisible())
     672           0 :                 return pWin;
     673             :         }
     674             :     }
     675             : 
     676             :     //  Aenderungen uebernehmen
     677           0 :     if ( pViewFrm->HasChildWindow(FID_CHG_ACCEPT) )
     678             :     {
     679           0 :         SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_CHG_ACCEPT);
     680           0 :         if (pChild)
     681             :         {
     682           0 :             Window* pWin = pChild->GetWindow();
     683           0 :             if (pWin && pWin->IsVisible())
     684           0 :                 return pWin;
     685             :         }
     686             :     }
     687             : 
     688           0 :     return NULL;
     689             : }
     690             : 
     691             :     //
     692             :     //  Bildschirm an Cursorposition anpassen
     693             :     //
     694             : 
     695           0 : void ScTabView::AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
     696             :                                 const ScSplitPos* pWhich )
     697             : {
     698             :     //
     699             :     //  aktiven Teil umschalten jetzt hier
     700             :     //
     701             : 
     702           0 :     ScSplitPos eActive = aViewData.GetActivePart();
     703           0 :     ScHSplitPos eActiveX = WhichH(eActive);
     704           0 :     ScVSplitPos eActiveY = WhichV(eActive);
     705           0 :     bool bHFix = (aViewData.GetHSplitMode() == SC_SPLIT_FIX);
     706           0 :     bool bVFix = (aViewData.GetVSplitMode() == SC_SPLIT_FIX);
     707           0 :     if (bHFix)
     708           0 :         if (eActiveX == SC_SPLIT_LEFT && nCurX >= (SCsCOL)aViewData.GetFixPosX())
     709             :         {
     710           0 :             ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT );
     711           0 :             eActiveX = SC_SPLIT_RIGHT;
     712             :         }
     713           0 :     if (bVFix)
     714           0 :         if (eActiveY == SC_SPLIT_TOP && nCurY >= (SCsROW)aViewData.GetFixPosY())
     715             :         {
     716           0 :             ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
     717           0 :             eActiveY = SC_SPLIT_BOTTOM;
     718             :         }
     719             : 
     720             :     //
     721             :     //  eigentliches Align
     722             :     //
     723             : 
     724           0 :     if ( eMode != SC_FOLLOW_NONE )
     725             :     {
     726             :         ScSplitPos eAlign;
     727           0 :         if (pWhich)
     728           0 :             eAlign = *pWhich;
     729             :         else
     730           0 :             eAlign = aViewData.GetActivePart();
     731           0 :         ScHSplitPos eAlignX = WhichH(eAlign);
     732           0 :         ScVSplitPos eAlignY = WhichV(eAlign);
     733             : 
     734           0 :         SCsCOL nDeltaX = (SCsCOL) aViewData.GetPosX(eAlignX);
     735           0 :         SCsROW nDeltaY = (SCsROW) aViewData.GetPosY(eAlignY);
     736           0 :         SCsCOL nSizeX = (SCsCOL) aViewData.VisibleCellsX(eAlignX);
     737           0 :         SCsROW nSizeY = (SCsROW) aViewData.VisibleCellsY(eAlignY);
     738             : 
     739             :         long nCellSizeX;
     740             :         long nCellSizeY;
     741           0 :         if ( nCurX >= 0 && nCurY >= 0 )
     742           0 :             aViewData.GetMergeSizePixel( (SCCOL)nCurX, (SCROW)nCurY, nCellSizeX, nCellSizeY );
     743             :         else
     744           0 :             nCellSizeX = nCellSizeY = 0;
     745           0 :         Size aScrSize = aViewData.GetScrSize();
     746           0 :         long nSpaceX = ( aScrSize.Width()  - nCellSizeX ) / 2;
     747           0 :         long nSpaceY = ( aScrSize.Height() - nCellSizeY ) / 2;
     748             :         //  nSpaceY: desired start position of cell for FOLLOW_JUMP, modified if dialog interferes
     749             : 
     750           0 :         bool bForceNew = false;     // force new calculation of JUMP position (vertical only)
     751             : 
     752             :         // VisibleCellsY == CellsAtY( GetPosY( eWhichY ), 1, eWhichY )
     753             : 
     754             :         //-------------------------------------------------------------------------------
     755             :         //  falls z.B. Suchen-Dialog offen ist, Cursor nicht hinter den Dialog stellen
     756             :         //  wenn moeglich, die Zeile mit dem Cursor oberhalb oder unterhalb des Dialogs
     757             : 
     758             :         //! nicht, wenn schon komplett sichtbar
     759             : 
     760           0 :         if ( eMode == SC_FOLLOW_JUMP )
     761             :         {
     762           0 :             Window* pCare = lcl_GetCareWin( aViewData.GetViewShell()->GetViewFrame() );
     763           0 :             if (pCare)
     764             :             {
     765           0 :                 bool bLimit = false;
     766           0 :                 Rectangle aDlgPixel;
     767           0 :                 Size aWinSize;
     768           0 :                 Window* pWin = GetActiveWin();
     769           0 :                 if (pWin)
     770             :                 {
     771           0 :                     aDlgPixel = pCare->GetWindowExtentsRelative( pWin );
     772           0 :                     aWinSize = pWin->GetOutputSizePixel();
     773             :                     //  ueberdeckt der Dialog das GridWin?
     774           0 :                     if ( aDlgPixel.Right() >= 0 && aDlgPixel.Left() < aWinSize.Width() )
     775             :                     {
     776           0 :                         if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX ||
     777             :                              nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY )
     778           0 :                             bLimit = true;          // es wird sowieso gescrollt
     779             :                         else
     780             :                         {
     781             :                             //  Cursor ist auf dem Bildschirm
     782           0 :                             Point aStart = aViewData.GetScrPos( nCurX, nCurY, eAlign );
     783             :                             long nCSX, nCSY;
     784           0 :                             aViewData.GetMergeSizePixel( nCurX, nCurY, nCSX, nCSY );
     785           0 :                             Rectangle aCursor( aStart, Size( nCSX, nCSY ) );
     786           0 :                             if ( aCursor.IsOver( aDlgPixel ) )
     787           0 :                                 bLimit = true;      // Zelle vom Dialog ueberdeckt
     788             :                         }
     789             :                     }
     790             :                 }
     791             : 
     792           0 :                 if (bLimit)
     793             :                 {
     794           0 :                     bool bBottom = false;
     795           0 :                     long nTopSpace = aDlgPixel.Top();
     796           0 :                     long nBotSpace = aWinSize.Height() - aDlgPixel.Bottom();
     797           0 :                     if ( nBotSpace > 0 && nBotSpace > nTopSpace )
     798             :                     {
     799           0 :                         long nDlgBot = aDlgPixel.Bottom();
     800             :                         SCsCOL nWPosX;
     801             :                         SCsROW nWPosY;
     802           0 :                         aViewData.GetPosFromPixel( 0,nDlgBot, eAlign, nWPosX, nWPosY );
     803           0 :                         ++nWPosY;   // unter der letzten betroffenen Zelle
     804             : 
     805           0 :                         SCsROW nDiff = nWPosY - nDeltaY;
     806           0 :                         if ( nCurY >= nDiff )           // Pos. kann nicht negativ werden
     807             :                         {
     808           0 :                             nSpaceY = nDlgBot + ( nBotSpace - nCellSizeY ) / 2;
     809           0 :                             bBottom = true;
     810           0 :                             bForceNew = true;
     811             :                         }
     812             :                     }
     813           0 :                     if ( !bBottom && nTopSpace > 0 )
     814             :                     {
     815           0 :                         nSpaceY = ( nTopSpace - nCellSizeY ) / 2;
     816           0 :                         bForceNew = true;
     817             :                     }
     818             :                 }
     819             :             }
     820             :         }
     821             :         //-------------------------------------------------------------------------------
     822             : 
     823           0 :         SCsCOL nNewDeltaX = nDeltaX;
     824           0 :         SCsROW nNewDeltaY = nDeltaY;
     825           0 :         bool bDoLine = false;
     826             : 
     827           0 :         switch (eMode)
     828             :         {
     829             :             case SC_FOLLOW_JUMP:
     830           0 :                 if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX )
     831             :                 {
     832           0 :                     nNewDeltaX = nCurX - static_cast<SCsCOL>(aViewData.CellsAtX( nCurX, -1, eAlignX, static_cast<sal_uInt16>(nSpaceX) ));
     833           0 :                     if (nNewDeltaX < 0) nNewDeltaX = 0;
     834           0 :                     nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
     835             :                 }
     836           0 :                 if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY || bForceNew )
     837             :                 {
     838           0 :                     nNewDeltaY = nCurY - static_cast<SCsROW>(aViewData.CellsAtY( nCurY, -1, eAlignY, static_cast<sal_uInt16>(nSpaceY) ));
     839           0 :                     if (nNewDeltaY < 0) nNewDeltaY = 0;
     840           0 :                     nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
     841             :                 }
     842           0 :                 bDoLine = true;
     843           0 :                 break;
     844             : 
     845             :             case SC_FOLLOW_LINE:
     846           0 :                 bDoLine = true;
     847           0 :                 break;
     848             : 
     849             :             case SC_FOLLOW_FIX:
     850           0 :                 if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX )
     851             :                 {
     852           0 :                     nNewDeltaX = nDeltaX + nCurX - aViewData.GetCurX();
     853           0 :                     if (nNewDeltaX < 0) nNewDeltaX = 0;
     854           0 :                     nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
     855             :                 }
     856           0 :                 if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY )
     857             :                 {
     858           0 :                     nNewDeltaY = nDeltaY + nCurY - aViewData.GetCurY();
     859           0 :                     if (nNewDeltaY < 0) nNewDeltaY = 0;
     860           0 :                     nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
     861             :                 }
     862             : 
     863             :                 //  like old version of SC_FOLLOW_JUMP:
     864             : 
     865           0 :                 if ( nCurX < nNewDeltaX || nCurX >= nNewDeltaX+nSizeX )
     866             :                 {
     867           0 :                     nNewDeltaX = nCurX - (nSizeX / 2);
     868           0 :                     if (nNewDeltaX < 0) nNewDeltaX = 0;
     869           0 :                     nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
     870             :                 }
     871           0 :                 if ( nCurY < nNewDeltaY || nCurY >= nNewDeltaY+nSizeY )
     872             :                 {
     873           0 :                     nNewDeltaY = nCurY - (nSizeY / 2);
     874           0 :                     if (nNewDeltaY < 0) nNewDeltaY = 0;
     875           0 :                     nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
     876             :                 }
     877             : 
     878           0 :                 bDoLine = true;
     879           0 :                 break;
     880             : 
     881             :             case SC_FOLLOW_NONE:
     882           0 :                 break;
     883             :             default:
     884             :                 OSL_FAIL("Falscher Cursormodus");
     885           0 :                 break;
     886             :         }
     887             : 
     888           0 :         if (bDoLine)
     889             :         {
     890           0 :             while ( nCurX >= nNewDeltaX+nSizeX )
     891             :             {
     892           0 :                 nNewDeltaX = nCurX-nSizeX+1;
     893           0 :                 ScDocument* pDoc = aViewData.GetDocument();
     894           0 :                 SCTAB nTab = aViewData.GetTabNo();
     895           0 :                 while ( nNewDeltaX < MAXCOL && !pDoc->GetColWidth( nNewDeltaX, nTab ) )
     896           0 :                     ++nNewDeltaX;
     897           0 :                 nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
     898             :             }
     899           0 :             while ( nCurY >= nNewDeltaY+nSizeY )
     900             :             {
     901           0 :                 nNewDeltaY = nCurY-nSizeY+1;
     902           0 :                 ScDocument* pDoc = aViewData.GetDocument();
     903           0 :                 SCTAB nTab = aViewData.GetTabNo();
     904           0 :                 while ( nNewDeltaY < MAXROW && !pDoc->GetRowHeight( nNewDeltaY, nTab ) )
     905           0 :                     ++nNewDeltaY;
     906           0 :                 nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
     907             :             }
     908           0 :             if ( nCurX < nNewDeltaX ) nNewDeltaX = nCurX;
     909           0 :             if ( nCurY < nNewDeltaY ) nNewDeltaY = nCurY;
     910             :         }
     911             : 
     912           0 :         if ( nNewDeltaX != nDeltaX )
     913           0 :             nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
     914           0 :         if (nNewDeltaX+nSizeX-1 > MAXCOL) nNewDeltaX = MAXCOL-nSizeX+1;
     915           0 :         if (nNewDeltaX < 0) nNewDeltaX = 0;
     916             : 
     917           0 :         if ( nNewDeltaY != nDeltaY )
     918           0 :             nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
     919           0 :         if (nNewDeltaY+nSizeY-1 > MAXROW) nNewDeltaY = MAXROW-nSizeY+1;
     920           0 :         if (nNewDeltaY < 0) nNewDeltaY = 0;
     921             : 
     922           0 :         if ( nNewDeltaX != nDeltaX ) ScrollX( nNewDeltaX - nDeltaX, eAlignX );
     923           0 :         if ( nNewDeltaY != nDeltaY ) ScrollY( nNewDeltaY - nDeltaY, eAlignY );
     924             :     }
     925             : 
     926             :     //
     927             :     //  nochmal aktiven Teil umschalten
     928             :     //
     929             : 
     930           0 :     if (bHFix)
     931           0 :         if (eActiveX == SC_SPLIT_RIGHT && nCurX < (SCsCOL)aViewData.GetFixPosX())
     932             :         {
     933           0 :             ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT );
     934           0 :             eActiveX = SC_SPLIT_LEFT;
     935             :         }
     936           0 :     if (bVFix)
     937           0 :         if (eActiveY == SC_SPLIT_BOTTOM && nCurY < (SCsROW)aViewData.GetFixPosY())
     938             :         {
     939           0 :             ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT );
     940           0 :             eActiveY = SC_SPLIT_TOP;
     941             :         }
     942           0 : }
     943             : 
     944           0 : bool ScTabView::SelMouseButtonDown( const MouseEvent& rMEvt )
     945             : {
     946           0 :     bool bRet = false;
     947             : 
     948             :     // #i3875# *Hack*
     949           0 :     bool bMod1Locked = aViewData.GetViewShell()->GetLockedModifiers() & KEY_MOD1 ? true : false;
     950           0 :     aViewData.SetSelCtrlMouseClick( rMEvt.IsMod1() || bMod1Locked );
     951             : 
     952           0 :     if ( pSelEngine )
     953             :     {
     954           0 :         bMoveIsShift = rMEvt.IsShift();
     955           0 :         bRet = pSelEngine->SelMouseButtonDown( rMEvt );
     956           0 :         bMoveIsShift = false;
     957             :     }
     958             : 
     959           0 :     aViewData.SetSelCtrlMouseClick( false ); // #i3875# *Hack*
     960             : 
     961           0 :     return bRet;
     962             : }
     963             : 
     964             :     //
     965             :     //  MoveCursor - mit Anpassung des Bildausschnitts
     966             :     //
     967             : 
     968           0 : void ScTabView::MoveCursorAbs( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
     969             :                                bool bShift, bool bControl, bool bKeepOld, bool bKeepSel )
     970             : {
     971           0 :     if (!bKeepOld)
     972           0 :         aViewData.ResetOldCursor();
     973             : 
     974           0 :     if (nCurX < 0) nCurX = 0;
     975           0 :     if (nCurY < 0) nCurY = 0;
     976           0 :     if (nCurX > MAXCOL) nCurX = MAXCOL;
     977           0 :     if (nCurY > MAXROW) nCurY = MAXROW;
     978             : 
     979           0 :     HideAllCursors();
     980             : 
     981             :         //  aktiven Teil umschalten jetzt in AlignToCursor
     982             : 
     983           0 :     AlignToCursor( nCurX, nCurY, eMode );
     984             :     //!     auf OS/2: SC_FOLLOW_JUMP statt SC_FOLLOW_LINE, um Nachlaufen zu verhindern ???
     985             : 
     986           0 :     if (bKeepSel)
     987             :     {
     988           0 :         SetCursor( nCurX, nCurY );      // Markierung stehenlassen
     989             : 
     990             :         // If the cursor is in existing selection, it's a cursor movement by
     991             :         // ENTER or TAB.  If not, then it's a new selection during ADD
     992             :         // selection mode.
     993             : 
     994           0 :         const ScMarkData& rMark = aViewData.GetMarkData();
     995           0 :         ScRangeList aSelList;
     996           0 :         rMark.FillRangeListWithMarks(&aSelList, false);
     997           0 :         if (!aSelList.In(ScRange(nCurX, nCurY, aViewData.GetTabNo())))
     998             :             // Cursor not in existing selection.  Start a new selection.
     999           0 :             DoneBlockMode(true);
    1000             :     }
    1001             :     else
    1002             :     {
    1003           0 :         if (!bShift)
    1004             :         {
    1005             :             // Remove all marked data on cursor movement unless the Shift is locked.
    1006           0 :             ScMarkData aData(aViewData.GetMarkData());
    1007           0 :             aData.ResetMark();
    1008           0 :             SetMarkData(aData);
    1009             :         }
    1010             : 
    1011           0 :         bool bSame = ( nCurX == aViewData.GetCurX() && nCurY == aViewData.GetCurY() );
    1012           0 :         bMoveIsShift = bShift;
    1013           0 :         pSelEngine->CursorPosChanging( bShift, bControl );
    1014           0 :         bMoveIsShift = false;
    1015           0 :         aFunctionSet.SetCursorAtCell( nCurX, nCurY, false );
    1016             : 
    1017             :         //  Wenn der Cursor nicht bewegt wurde, muss das SelectionChanged fuer das
    1018             :         //  Aufheben der Selektion hier einzeln passieren:
    1019           0 :         if (bSame)
    1020           0 :             SelectionChanged();
    1021             :     }
    1022             : 
    1023           0 :     ShowAllCursors();
    1024           0 :     TestHintWindow();
    1025           0 : }
    1026             : 
    1027           0 : void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
    1028             :                                bool bShift, bool bKeepSel )
    1029             : {
    1030           0 :     ScDocument* pDoc = aViewData.GetDocument();
    1031           0 :     SCTAB nTab = aViewData.GetTabNo();
    1032             : 
    1033           0 :     bool bSkipProtected = false, bSkipUnprotected = false;
    1034           0 :     ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
    1035           0 :     if ( pProtect && pProtect->isProtected() )
    1036             :     {
    1037           0 :         bSkipProtected   = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
    1038           0 :         bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
    1039             :     }
    1040             : 
    1041           0 :     if ( bSkipProtected && bSkipUnprotected )
    1042           0 :         return;
    1043             : 
    1044             :     SCsCOL nOldX;
    1045             :     SCsROW nOldY;
    1046             :     SCsCOL nCurX;
    1047             :     SCsROW nCurY;
    1048           0 :     if ( aViewData.IsRefMode() )
    1049             :     {
    1050           0 :         nOldX = (SCsCOL) aViewData.GetRefEndX();
    1051           0 :         nOldY = (SCsROW) aViewData.GetRefEndY();
    1052           0 :         nCurX = nOldX + nMovX;
    1053           0 :         nCurY = nOldY + nMovY;
    1054             :     }
    1055             :     else
    1056             :     {
    1057           0 :         nOldX = (SCsCOL) aViewData.GetCurX();
    1058           0 :         nOldY = (SCsROW) aViewData.GetCurY();
    1059           0 :         nCurX = (nMovX != 0) ? nOldX+nMovX : (SCsCOL) aViewData.GetOldCurX();
    1060           0 :         nCurY = (nMovY != 0) ? nOldY+nMovY : (SCsROW) aViewData.GetOldCurY();
    1061             :     }
    1062             : 
    1063           0 :     aViewData.ResetOldCursor();
    1064             : 
    1065           0 :     if (nMovX != 0 && VALIDCOLROW(nCurX,nCurY))
    1066           0 :         SkipCursorHorizontal(nCurX, nCurY, nOldX, nMovX);
    1067             : 
    1068           0 :     if (nMovY != 0 && VALIDCOLROW(nCurX,nCurY))
    1069           0 :         SkipCursorVertical(nCurX, nCurY, nOldY, nMovY);
    1070             : 
    1071           0 :     MoveCursorAbs( nCurX, nCurY, eMode, bShift, false, true, bKeepSel );
    1072             : }
    1073             : 
    1074           0 : void ScTabView::MoveCursorPage( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel )
    1075             : {
    1076             :     SCsCOL nPageX;
    1077             :     SCsROW nPageY;
    1078           0 :     GetPageMoveEndPosition(nMovX, nMovY, nPageX, nPageY);
    1079           0 :     MoveCursorRel( nPageX, nPageY, eMode, bShift, bKeepSel );
    1080           0 : }
    1081             : 
    1082           0 : void ScTabView::MoveCursorArea( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel )
    1083             : {
    1084             :     SCsCOL nNewX;
    1085             :     SCsROW nNewY;
    1086           0 :     GetAreaMoveEndPosition(nMovX, nMovY, eMode, nNewX, nNewY, eMode);
    1087           0 :     MoveCursorRel(nNewX, nNewY, eMode, bShift, bKeepSel);
    1088           0 : }
    1089             : 
    1090           0 : void ScTabView::MoveCursorEnd( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift, bool bKeepSel )
    1091             : {
    1092           0 :     ScDocument* pDoc = aViewData.GetDocument();
    1093           0 :     SCTAB nTab = aViewData.GetTabNo();
    1094             : 
    1095             :     SCCOL nCurX;
    1096             :     SCROW nCurY;
    1097           0 :     aViewData.GetMoveCursor( nCurX,nCurY );
    1098           0 :     SCCOL nNewX = nCurX;
    1099           0 :     SCROW nNewY = nCurY;
    1100             : 
    1101           0 :     SCCOL nUsedX = 0;
    1102           0 :     SCROW nUsedY = 0;
    1103           0 :     if ( nMovX > 0 || nMovY > 0 )
    1104           0 :         pDoc->GetPrintArea( nTab, nUsedX, nUsedY );     // Ende holen
    1105             : 
    1106           0 :     if (nMovX<0)
    1107           0 :         nNewX=0;
    1108           0 :     else if (nMovX>0)
    1109           0 :         nNewX=nUsedX;                                   // letzter benutzter Bereich
    1110             : 
    1111           0 :     if (nMovY<0)
    1112           0 :         nNewY=0;
    1113           0 :     else if (nMovY>0)
    1114           0 :         nNewY=nUsedY;
    1115             : 
    1116           0 :     aViewData.ResetOldCursor();
    1117           0 :     MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY, eMode, bShift, bKeepSel );
    1118           0 : }
    1119             : 
    1120           0 : void ScTabView::MoveCursorScreen( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, bool bShift )
    1121             : {
    1122           0 :     ScDocument* pDoc = aViewData.GetDocument();
    1123           0 :     SCTAB nTab = aViewData.GetTabNo();
    1124             : 
    1125             :     SCCOL nCurX;
    1126             :     SCROW nCurY;
    1127           0 :     aViewData.GetMoveCursor( nCurX,nCurY );
    1128           0 :     SCCOL nNewX = nCurX;
    1129           0 :     SCROW nNewY = nCurY;
    1130             : 
    1131           0 :     ScSplitPos eWhich = aViewData.GetActivePart();
    1132           0 :     SCCOL nPosX = aViewData.GetPosX( WhichH(eWhich) );
    1133           0 :     SCROW nPosY = aViewData.GetPosY( WhichV(eWhich) );
    1134             : 
    1135           0 :     SCCOL nAddX = aViewData.VisibleCellsX( WhichH(eWhich) );
    1136           0 :     if (nAddX != 0)
    1137           0 :         --nAddX;
    1138           0 :     SCROW nAddY = aViewData.VisibleCellsY( WhichV(eWhich) );
    1139           0 :     if (nAddY != 0)
    1140           0 :         --nAddY;
    1141             : 
    1142           0 :     if (nMovX<0)
    1143           0 :         nNewX=nPosX;
    1144           0 :     else if (nMovX>0)
    1145           0 :         nNewX=nPosX+nAddX;
    1146             : 
    1147           0 :     if (nMovY<0)
    1148           0 :         nNewY=nPosY;
    1149           0 :     else if (nMovY>0)
    1150           0 :         nNewY=nPosY+nAddY;
    1151             : 
    1152           0 :     aViewData.SetOldCursor( nNewX,nNewY );
    1153           0 :     pDoc->SkipOverlapped(nNewX, nNewY, nTab);
    1154           0 :     MoveCursorAbs( nNewX, nNewY, eMode, bShift, false, true );
    1155           0 : }
    1156             : 
    1157           0 : void ScTabView::MoveCursorEnter( bool bShift )          // bShift -> hoch/runter
    1158             : {
    1159           0 :     const ScInputOptions& rOpt = SC_MOD()->GetInputOptions();
    1160           0 :     if (!rOpt.GetMoveSelection())
    1161             :     {
    1162           0 :         aViewData.UpdateInputHandler(true);
    1163           0 :         return;
    1164             :     }
    1165             : 
    1166           0 :     SCsCOL nMoveX = 0;
    1167           0 :     SCsROW nMoveY = 0;
    1168           0 :     switch ((ScDirection)rOpt.GetMoveDir())
    1169             :     {
    1170             :         case DIR_BOTTOM:
    1171           0 :             nMoveY = bShift ? -1 : 1;
    1172           0 :             break;
    1173             :         case DIR_RIGHT:
    1174           0 :             nMoveX = bShift ? -1 : 1;
    1175           0 :             break;
    1176             :         case DIR_TOP:
    1177           0 :             nMoveY = bShift ? 1 : -1;
    1178           0 :             break;
    1179             :         case DIR_LEFT:
    1180           0 :             nMoveX = bShift ? 1 : -1;
    1181           0 :             break;
    1182             :     }
    1183             : 
    1184           0 :     ScMarkData& rMark = aViewData.GetMarkData();
    1185           0 :     if (rMark.IsMarked() || rMark.IsMultiMarked())
    1186             :     {
    1187             :         SCCOL nCurX;
    1188             :         SCROW nCurY;
    1189           0 :         aViewData.GetMoveCursor( nCurX,nCurY );
    1190           0 :         SCCOL nNewX = nCurX;
    1191           0 :         SCROW nNewY = nCurY;
    1192           0 :         SCTAB nTab = aViewData.GetTabNo();
    1193             : 
    1194           0 :         ScDocument* pDoc = aViewData.GetDocument();
    1195           0 :         pDoc->GetNextPos( nNewX,nNewY, nTab, nMoveX,nMoveY, true, false, rMark );
    1196             : 
    1197             :         MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY,
    1198           0 :                             SC_FOLLOW_LINE, false, true );
    1199             : 
    1200             :         //  update input line even if cursor was not moved
    1201           0 :         if ( nNewX == nCurX && nNewY == nCurY )
    1202           0 :             aViewData.UpdateInputHandler(true);
    1203             :     }
    1204             :     else
    1205             :     {
    1206           0 :         if ( nMoveY != 0 && !nMoveX )
    1207             :         {
    1208             :             //  nach Tab und Enter wieder zur Ausgangsspalte
    1209           0 :             SCCOL nTabCol = aViewData.GetTabStartCol();
    1210           0 :             if (nTabCol != SC_TABSTART_NONE)
    1211             :             {
    1212             :                 SCCOL nCurX;
    1213             :                 SCROW nCurY;
    1214           0 :                 aViewData.GetMoveCursor( nCurX,nCurY );
    1215           0 :                 nMoveX = ((SCsCOL)nTabCol)-(SCsCOL)nCurX;
    1216             :             }
    1217             :         }
    1218             : 
    1219           0 :         MoveCursorRel( nMoveX,nMoveY, SC_FOLLOW_LINE, false );
    1220             :     }
    1221             : }
    1222             : 
    1223             : 
    1224           0 : bool ScTabView::MoveCursorKeyInput( const KeyEvent& rKeyEvent )
    1225             : {
    1226           0 :     const KeyCode& rKCode = rKeyEvent.GetKeyCode();
    1227             : 
    1228             :     enum { MOD_NONE, MOD_CTRL, MOD_ALT, MOD_BOTH } eModifier =
    1229           0 :         rKCode.IsMod1() ?
    1230           0 :             (rKCode.IsMod2() ? MOD_BOTH : MOD_CTRL) :
    1231           0 :             (rKCode.IsMod2() ? MOD_ALT : MOD_NONE);
    1232             : 
    1233           0 :     bool bSel = rKCode.IsShift();
    1234           0 :     sal_uInt16 nCode = rKCode.GetCode();
    1235             : 
    1236             :     // CURSOR keys
    1237           0 :     SCsCOL nDX = 0;
    1238           0 :     SCsROW nDY = 0;
    1239           0 :     switch( nCode )
    1240             :     {
    1241           0 :         case KEY_LEFT:  nDX = -1;   break;
    1242           0 :         case KEY_RIGHT: nDX = 1;    break;
    1243           0 :         case KEY_UP:    nDY = -1;   break;
    1244           0 :         case KEY_DOWN:  nDY = 1;    break;
    1245             :     }
    1246           0 :     if( nDX != 0 || nDY != 0 )
    1247             :     {
    1248           0 :         switch( eModifier )
    1249             :         {
    1250           0 :             case MOD_NONE:  MoveCursorRel( nDX, nDY, SC_FOLLOW_LINE, bSel );    break;
    1251           0 :             case MOD_CTRL:  MoveCursorArea( nDX, nDY, SC_FOLLOW_JUMP, bSel );   break;
    1252             :             default:
    1253             :             {
    1254             :                 // added to avoid warnings
    1255             :             }
    1256             :         }
    1257             :         // always true to suppress changes of col/row size (ALT+CURSOR)
    1258           0 :         return true;
    1259             :     }
    1260             : 
    1261             :     // PAGEUP/PAGEDOWN
    1262           0 :     if( (nCode == KEY_PAGEUP) || (nCode == KEY_PAGEDOWN) )
    1263             :     {
    1264           0 :         nDX = (nCode == KEY_PAGEUP) ? -1 : 1;
    1265           0 :         switch( eModifier )
    1266             :         {
    1267           0 :             case MOD_NONE:  MoveCursorPage( 0, static_cast<SCsCOLROW>(nDX), SC_FOLLOW_FIX, bSel );  break;
    1268           0 :             case MOD_ALT:   MoveCursorPage( nDX, 0, SC_FOLLOW_FIX, bSel );  break;
    1269           0 :             case MOD_CTRL:  SelectNextTab( nDX );                           break;
    1270             :             default:
    1271             :             {
    1272             :                 // added to avoid warnings
    1273             :             }
    1274             :         }
    1275           0 :         return true;
    1276             :     }
    1277             : 
    1278             :     // HOME/END
    1279           0 :     if( (nCode == KEY_HOME) || (nCode == KEY_END) )
    1280             :     {
    1281           0 :         nDX = (nCode == KEY_HOME) ? -1 : 1;
    1282           0 :         ScFollowMode eMode = (nCode == KEY_HOME) ? SC_FOLLOW_LINE : SC_FOLLOW_JUMP;
    1283           0 :         switch( eModifier )
    1284             :         {
    1285           0 :             case MOD_NONE:  MoveCursorEnd( nDX, 0, eMode, bSel );   break;
    1286           0 :             case MOD_CTRL:  MoveCursorEnd( nDX, static_cast<SCsCOLROW>(nDX), eMode, bSel ); break;
    1287             :             default:
    1288             :             {
    1289             :                 // added to avoid warnings
    1290             :             }
    1291             :         }
    1292           0 :         return true;
    1293             :     }
    1294             : 
    1295           0 :     return false;
    1296             : }
    1297             : 
    1298             : 
    1299             :         // naechste/vorherige nicht geschuetzte Zelle
    1300           0 : void ScTabView::FindNextUnprot( bool bShift, bool bInSelection )
    1301             : {
    1302           0 :     short nMove = bShift ? -1 : 1;
    1303             : 
    1304           0 :     ScMarkData& rMark = aViewData.GetMarkData();
    1305           0 :     bool bMarked = bInSelection && (rMark.IsMarked() || rMark.IsMultiMarked());
    1306             : 
    1307             :     SCCOL nCurX;
    1308             :     SCROW nCurY;
    1309           0 :     aViewData.GetMoveCursor( nCurX,nCurY );
    1310           0 :     SCCOL nNewX = nCurX;
    1311           0 :     SCROW nNewY = nCurY;
    1312           0 :     SCTAB nTab = aViewData.GetTabNo();
    1313             : 
    1314           0 :     ScDocument* pDoc = aViewData.GetDocument();
    1315           0 :     pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, bMarked, true, rMark );
    1316             : 
    1317           0 :     SCCOL nTabCol = aViewData.GetTabStartCol();
    1318           0 :     if ( nTabCol == SC_TABSTART_NONE )
    1319           0 :         nTabCol = nCurX;                    // auf diese Spalte zurueck bei Enter
    1320             : 
    1321             :     MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY,
    1322           0 :                    SC_FOLLOW_LINE, false, true );
    1323             : 
    1324             :     //  in MoveCursorRel wird die TabCol zurueckgesetzt...
    1325           0 :     aViewData.SetTabStartCol( nTabCol );
    1326           0 : }
    1327             : 
    1328           0 : void ScTabView::MarkColumns()
    1329             : {
    1330             :     SCCOL nStartCol;
    1331             :     SCCOL nEndCol;
    1332             : 
    1333           0 :     ScMarkData& rMark = aViewData.GetMarkData();
    1334           0 :     if (rMark.IsMarked())
    1335             :     {
    1336           0 :         ScRange aMarkRange;
    1337           0 :         rMark.GetMarkArea( aMarkRange );
    1338           0 :         nStartCol = aMarkRange.aStart.Col();
    1339           0 :         nEndCol = aMarkRange.aEnd.Col();
    1340             :     }
    1341             :     else
    1342             :     {
    1343             :         SCROW nDummy;
    1344           0 :         aViewData.GetMoveCursor( nStartCol, nDummy );
    1345           0 :         nEndCol=nStartCol;
    1346             :     }
    1347             : 
    1348           0 :     SCTAB nTab = aViewData.GetTabNo();
    1349           0 :     DoneBlockMode();
    1350           0 :     InitBlockMode( nStartCol,0, nTab );
    1351           0 :     MarkCursor( nEndCol,MAXROW, nTab );
    1352           0 :     SelectionChanged();
    1353           0 : }
    1354             : 
    1355           0 : void ScTabView::MarkRows()
    1356             : {
    1357             :     SCROW nStartRow;
    1358             :     SCROW nEndRow;
    1359             : 
    1360           0 :     ScMarkData& rMark = aViewData.GetMarkData();
    1361           0 :     if (rMark.IsMarked())
    1362             :     {
    1363           0 :         ScRange aMarkRange;
    1364           0 :         rMark.GetMarkArea( aMarkRange );
    1365           0 :         nStartRow = aMarkRange.aStart.Row();
    1366           0 :         nEndRow = aMarkRange.aEnd.Row();
    1367             :     }
    1368             :     else
    1369             :     {
    1370             :         SCCOL nDummy;
    1371           0 :         aViewData.GetMoveCursor( nDummy, nStartRow );
    1372           0 :         nEndRow=nStartRow;
    1373             :     }
    1374             : 
    1375           0 :     SCTAB nTab = aViewData.GetTabNo();
    1376           0 :     DoneBlockMode();
    1377           0 :     InitBlockMode( 0,nStartRow, nTab );
    1378           0 :     MarkCursor( MAXCOL,nEndRow, nTab );
    1379           0 :     SelectionChanged();
    1380           0 : }
    1381             : 
    1382           0 : void ScTabView::MarkDataArea( bool bIncludeCursor )
    1383             : {
    1384           0 :     ScDocument* pDoc = aViewData.GetDocument();
    1385           0 :     SCTAB nTab = aViewData.GetTabNo();
    1386           0 :     SCCOL nStartCol = aViewData.GetCurX();
    1387           0 :     SCROW nStartRow = aViewData.GetCurY();
    1388           0 :     SCCOL nEndCol = nStartCol;
    1389           0 :     SCROW nEndRow = nStartRow;
    1390             : 
    1391           0 :     pDoc->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, bIncludeCursor, false );
    1392             : 
    1393           0 :     HideAllCursors();
    1394           0 :     DoneBlockMode();
    1395           0 :     InitBlockMode( nStartCol, nStartRow, nTab );
    1396           0 :     MarkCursor( nEndCol, nEndRow, nTab );
    1397           0 :     ShowAllCursors();
    1398             : 
    1399           0 :     SelectionChanged();
    1400           0 : }
    1401             : 
    1402           0 : void ScTabView::MarkMatrixFormula()
    1403             : {
    1404           0 :     ScDocument* pDoc = aViewData.GetDocument();
    1405           0 :     ScAddress aCursor( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
    1406           0 :     ScRange aMatrix;
    1407           0 :     if ( pDoc->GetMatrixFormulaRange( aCursor, aMatrix ) )
    1408             :     {
    1409           0 :         MarkRange( aMatrix, false );        // cursor is already within the range
    1410             :     }
    1411           0 : }
    1412             : 
    1413           0 : void ScTabView::MarkRange( const ScRange& rRange, bool bSetCursor, bool bContinue )
    1414             : {
    1415           0 :     SCTAB nTab = rRange.aStart.Tab();
    1416           0 :     SetTabNo( nTab );
    1417             : 
    1418           0 :     HideAllCursors();
    1419           0 :     DoneBlockMode( bContinue ); // bContinue==true -> clear old mark
    1420           0 :     if (bSetCursor)             // Wenn Cursor gesetzt wird, immer auch alignen
    1421             :     {
    1422           0 :         SCCOL nAlignX = rRange.aStart.Col();
    1423           0 :         SCROW nAlignY = rRange.aStart.Row();
    1424           0 :         bool bCol = ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) && !aViewData.GetDocument()->IsInVBAMode();
    1425           0 :         bool bRow = ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW );
    1426           0 :         if ( bCol )
    1427           0 :             nAlignX = aViewData.GetPosX(WhichH(aViewData.GetActivePart()));
    1428           0 :         if ( bRow )
    1429           0 :             nAlignY = aViewData.GetPosY(WhichV(aViewData.GetActivePart()));
    1430           0 :         AlignToCursor( nAlignX, nAlignY, SC_FOLLOW_JUMP );
    1431             :     }
    1432           0 :     InitBlockMode( rRange.aStart.Col(), rRange.aStart.Row(), nTab );
    1433           0 :     MarkCursor( rRange.aEnd.Col(), rRange.aEnd.Row(), nTab );
    1434           0 :     if (bSetCursor)
    1435             :     {
    1436           0 :         SCCOL nPosX = rRange.aStart.Col();
    1437           0 :         SCROW nPosY = rRange.aStart.Row();
    1438           0 :         ScDocument* pDoc = aViewData.GetDocument();
    1439           0 :         pDoc->SkipOverlapped(nPosX, nPosY, nTab);
    1440             : 
    1441           0 :         aViewData.ResetOldCursor();
    1442           0 :         SetCursor( nPosX, nPosY );
    1443             :     }
    1444           0 :     ShowAllCursors();
    1445             : 
    1446           0 :     SelectionChanged();
    1447           0 : }
    1448             : 
    1449           0 : void ScTabView::Unmark()
    1450             : {
    1451           0 :     ScMarkData& rMark = aViewData.GetMarkData();
    1452           0 :     if ( rMark.IsMarked() || rMark.IsMultiMarked() )
    1453             :     {
    1454             :         SCCOL nCurX;
    1455             :         SCROW nCurY;
    1456           0 :         aViewData.GetMoveCursor( nCurX,nCurY );
    1457           0 :         MoveCursorAbs( nCurX, nCurY, SC_FOLLOW_NONE, false, false );
    1458             : 
    1459           0 :         SelectionChanged();
    1460             :     }
    1461           0 : }
    1462             : 
    1463           0 : void ScTabView::SetMarkData( const ScMarkData& rNew )
    1464             : {
    1465           0 :     DoneBlockMode();
    1466           0 :     InitOwnBlockMode();
    1467           0 :     aViewData.GetMarkData() = rNew;
    1468             : 
    1469           0 :     MarkDataChanged();
    1470           0 : }
    1471             : 
    1472           0 : void ScTabView::MarkDataChanged()
    1473             : {
    1474             :     // has to be called after making direct changes to mark data (not via MarkCursor etc)
    1475             : 
    1476           0 :     UpdateSelectionOverlay();
    1477           0 : }
    1478             : 
    1479           0 : void ScTabView::SelectNextTab( short nDir, bool bExtendSelection )
    1480             : {
    1481           0 :     if (!nDir) return;
    1482             :     OSL_ENSURE( nDir==-1 || nDir==1, "SelectNextTab: falscher Wert");
    1483             : 
    1484           0 :     ScDocument* pDoc = aViewData.GetDocument();
    1485           0 :     SCTAB nTab = aViewData.GetTabNo();
    1486           0 :     if (nDir<0)
    1487             :     {
    1488           0 :         if (!nTab) return;
    1489           0 :         --nTab;
    1490           0 :         while (!pDoc->IsVisible(nTab))
    1491             :         {
    1492           0 :             if (!nTab) return;
    1493           0 :             --nTab;
    1494             :         }
    1495             :     }
    1496             :     else
    1497             :     {
    1498           0 :         SCTAB nCount = pDoc->GetTableCount();
    1499           0 :         ++nTab;
    1500           0 :         if (nTab >= nCount) return;
    1501           0 :         while (!pDoc->IsVisible(nTab))
    1502             :         {
    1503           0 :             ++nTab;
    1504           0 :             if (nTab >= nCount) return;
    1505             :         }
    1506             :     }
    1507             : 
    1508           0 :     SetTabNo( nTab, false, bExtendSelection );
    1509           0 :     PaintExtras();
    1510             : }
    1511             : 
    1512             : 
    1513             : //  SetTabNo    - angezeigte Tabelle
    1514             : 
    1515          38 : void ScTabView::SetTabNo( SCTAB nTab, bool bNew, bool bExtendSelection, bool bSameTabButMoved )
    1516             : {
    1517          38 :     if ( !ValidTab(nTab) )
    1518             :     {
    1519             :         OSL_FAIL("SetTabNo: falsche Tabelle");
    1520           0 :         return;
    1521             :     }
    1522             : 
    1523          38 :     if ( nTab != aViewData.GetTabNo() || bNew )
    1524             :     {
    1525             :         //  Die FormShell moechte vor dem Umschalten benachrichtigt werden
    1526          38 :         FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell();
    1527          38 :         if (pFormSh)
    1528             :         {
    1529          38 :             bool bAllowed = static_cast<bool>(pFormSh->PrepareClose(true));
    1530          38 :             if (!bAllowed)
    1531             :             {
    1532             :                 //! Fehlermeldung? oder macht das die FormShell selber?
    1533             :                 //! Fehler-Flag zurueckgeben und Aktionen abbrechen
    1534             : 
    1535           0 :                 return;     // Die FormShell sagt, es kann nicht umgeschaltet werden
    1536             :             }
    1537             :         }
    1538             : 
    1539             :                                         //  nicht InputEnterHandler wegen Referenzeingabe !
    1540             : 
    1541          38 :         ScDocument* pDoc = aViewData.GetDocument();
    1542             : 
    1543          38 :         pDoc->MakeTable( nTab );
    1544             : 
    1545             :         // Update pending row heights before switching the sheet, so Reschedule from the progress bar
    1546             :         // doesn't paint the new sheet with old heights
    1547          38 :         aViewData.GetDocShell()->UpdatePendingRowHeights( nTab );
    1548             : 
    1549          38 :         SCTAB nTabCount = pDoc->GetTableCount();
    1550          38 :         SCTAB nOldPos = nTab;
    1551          76 :         while (!pDoc->IsVisible(nTab))              // naechste sichtbare suchen
    1552             :         {
    1553           0 :             bool bUp = (nTab>=nOldPos);
    1554           0 :             if (bUp)
    1555             :             {
    1556           0 :                 ++nTab;
    1557           0 :                 if (nTab>=nTabCount)
    1558             :                 {
    1559           0 :                     nTab = nOldPos;
    1560           0 :                     bUp = false;
    1561             :                 }
    1562             :             }
    1563             : 
    1564           0 :             if (!bUp)
    1565             :             {
    1566           0 :                 if (nTab != 0)
    1567           0 :                     --nTab;
    1568             :                 else
    1569             :                 {
    1570             :                     OSL_FAIL("keine sichtbare Tabelle");
    1571           0 :                     pDoc->SetVisible( 0, true );
    1572             :                 }
    1573             :             }
    1574             :         }
    1575             : 
    1576             :         // #i71490# Deselect drawing objects before changing the sheet number in view data,
    1577             :         // so the handling of notes still has the sheet selected on which the notes are.
    1578          38 :         DrawDeselectAll();
    1579             : 
    1580          38 :         ScModule* pScMod = SC_MOD();
    1581          38 :         bool bRefMode = pScMod->IsFormulaMode();
    1582          38 :         if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert
    1583             :         {
    1584          38 :             DoneBlockMode();
    1585          38 :             pSelEngine->Reset();                // reset all flags, including locked modifiers
    1586          38 :             aViewData.SetRefTabNo( nTab );
    1587             :         }
    1588             : 
    1589          38 :         ScSplitPos eOldActive = aViewData.GetActivePart();      // before switching
    1590          38 :         bool bFocus = pGridWin[eOldActive]->HasFocus();
    1591             : 
    1592          38 :         aViewData.SetTabNo( nTab );
    1593             :         //  UpdateShow noch vor SetCursor, damit UpdateAutoFillMark die richtigen
    1594             :         //  Fenster findet (wird aus SetCursor gerufen)
    1595          38 :         UpdateShow();
    1596          38 :         aViewData.ResetOldCursor();
    1597             : 
    1598          38 :         SfxBindings& rBindings = aViewData.GetBindings();
    1599          38 :         ScMarkData& rMark = aViewData.GetMarkData();
    1600             : 
    1601          38 :         bool bAllSelected = true;
    1602          92 :         for (SCTAB nSelTab = 0; nSelTab < nTabCount; ++nSelTab)
    1603             :         {
    1604          78 :             if (!pDoc->IsVisible(nSelTab) || rMark.GetTableSelect(nSelTab))
    1605             :             {
    1606          36 :                 if (nTab == nSelTab)
    1607             :                     // This tab is already in selection.  Keep the current
    1608             :                     // selection.
    1609          28 :                     bExtendSelection = true;
    1610             :             }
    1611             :             else
    1612             :             {
    1613          42 :                 bAllSelected = false;
    1614          42 :                 if (bExtendSelection)
    1615             :                     // We got what we need.  No need to stay in the loop.
    1616          24 :                     break;
    1617             :             }
    1618             :         }
    1619          38 :         if (bAllSelected && !bNew)
    1620             :             // #i6327# if all tables are selected, a selection event (#i6330#) will deselect all
    1621             :             // (not if called with bNew to update settings)
    1622           0 :             bExtendSelection = false;
    1623             : 
    1624          38 :         if (bExtendSelection)
    1625          28 :             rMark.SelectTable( nTab, true );
    1626             :         else
    1627             :         {
    1628          10 :             rMark.SelectOneTable( nTab );
    1629          10 :             rBindings.Invalidate( FID_FILL_TAB );
    1630          10 :             rBindings.Invalidate( FID_TAB_DESELECTALL );
    1631             :         }
    1632             : 
    1633          38 :         SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), true );
    1634          38 :         bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
    1635             : 
    1636             :         // recalc zoom-dependent values (before TabChanged, before UpdateEditViewPos)
    1637          38 :         RefreshZoom();
    1638          38 :         UpdateVarZoom();
    1639             : 
    1640          38 :         if ( bRefMode )     // hide EditView if necessary (after aViewData.SetTabNo !)
    1641             :         {
    1642           0 :             for (sal_uInt16 i = 0; i < 4; ++i)
    1643           0 :                 if (pGridWin[i] && pGridWin[i]->IsVisible())
    1644           0 :                     pGridWin[i]->UpdateEditViewPos();
    1645             :         }
    1646             : 
    1647          38 :         TabChanged(bSameTabButMoved);                                       // DrawView
    1648          38 :         UpdateVisibleRange();
    1649             : 
    1650          38 :         aViewData.GetViewShell()->WindowChanged();          // falls das aktive Fenster anders ist
    1651          38 :         if ( !bUnoRefDialog )
    1652          38 :             aViewData.GetViewShell()->DisconnectAllClients();   // important for floating frames
    1653             :         else
    1654             :         {
    1655             :             // hide / show inplace client
    1656             : 
    1657           0 :             ScClient* pClient = static_cast<ScClient*>(aViewData.GetViewShell()->GetIPClient());
    1658           0 :             if ( pClient && pClient->IsObjectInPlaceActive() )
    1659             :             {
    1660           0 :                 Rectangle aObjArea = pClient->GetObjArea();
    1661           0 :                 if ( nTab == aViewData.GetRefTabNo() )
    1662             :                 {
    1663             :                     // move to its original position
    1664             : 
    1665           0 :                     SdrOle2Obj* pDrawObj = pClient->GetDrawObj();
    1666           0 :                     if ( pDrawObj )
    1667             :                     {
    1668           0 :                         Rectangle aRect = pDrawObj->GetLogicRect();
    1669           0 :                         MapMode aMapMode( MAP_100TH_MM );
    1670           0 :                         Size aOleSize = pDrawObj->GetOrigObjSize( &aMapMode );
    1671           0 :                         aRect.SetSize( aOleSize );
    1672           0 :                         aObjArea = aRect;
    1673             :                     }
    1674             :                 }
    1675             :                 else
    1676             :                 {
    1677             :                     // move to an invisible position
    1678             : 
    1679           0 :                     aObjArea.SetPos( Point( 0, -2*aObjArea.GetHeight() ) );
    1680             :                 }
    1681           0 :                 pClient->SetObjArea( aObjArea );
    1682             :             }
    1683             :         }
    1684             : 
    1685          38 :         if ( bFocus && aViewData.GetActivePart() != eOldActive && !bRefMode )
    1686           0 :             ActiveGrabFocus();      // grab focus to the pane that's active now
    1687             : 
    1688             :             //  Fixierungen
    1689             : 
    1690          38 :         bool bResize = false;
    1691          38 :         if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
    1692           0 :             if (aViewData.UpdateFixX())
    1693           0 :                 bResize = true;
    1694          38 :         if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
    1695           0 :             if (aViewData.UpdateFixY())
    1696           0 :                 bResize = true;
    1697          38 :         if (bResize)
    1698           0 :             RepeatResize();
    1699          38 :         InvalidateSplit();
    1700             : 
    1701          38 :         if ( aViewData.IsPagebreakMode() )
    1702           0 :             UpdatePageBreakData();              //! asynchron ??
    1703             : 
    1704             :         //  Form-Layer muss den sichtbaren Ausschnitt der neuen Tabelle kennen
    1705             :         //  dafuer muss hier schon der MapMode stimmen
    1706         190 :         for (sal_uInt16 i=0; i<4; i++)
    1707         152 :             if (pGridWin[i])
    1708          38 :                 pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
    1709          38 :         SetNewVisArea();
    1710             : 
    1711          38 :         PaintGrid();
    1712          38 :         PaintTop();
    1713          38 :         PaintLeft();
    1714          38 :         PaintExtras();
    1715             : 
    1716          38 :         DoResize( aBorderPos, aFrameSize );
    1717          38 :         rBindings.Invalidate( SID_DELETE_PRINTAREA );   // Menue
    1718          38 :         rBindings.Invalidate( FID_DEL_MANUALBREAKS );
    1719          38 :         rBindings.Invalidate( FID_RESET_PRINTZOOM );
    1720          38 :         rBindings.Invalidate( SID_STATUS_DOCPOS );      // Statusbar
    1721          38 :         rBindings.Invalidate( SID_STATUS_PAGESTYLE );   // Statusbar
    1722          38 :         rBindings.Invalidate( SID_CURRENTTAB );         // Navigator
    1723          38 :         rBindings.Invalidate( SID_STYLE_FAMILY2 );  // Gestalter
    1724          38 :         rBindings.Invalidate( SID_STYLE_FAMILY4 );  // Gestalter
    1725          38 :         rBindings.Invalidate( SID_TABLES_COUNT );
    1726             : 
    1727          38 :         if(pScMod->IsRefDialogOpen())
    1728             :         {
    1729           0 :             sal_uInt16 nCurRefDlgId=pScMod->GetCurRefDlgId();
    1730           0 :             SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame();
    1731           0 :             SfxChildWindow* pChildWnd = pViewFrm->GetChildWindow( nCurRefDlgId );
    1732           0 :             if ( pChildWnd )
    1733             :             {
    1734           0 :                 IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
    1735           0 :                 pRefDlg->ViewShellChanged();
    1736             :             }
    1737             :         }
    1738             :     }
    1739             : }
    1740             : 
    1741             : //
    1742             : //  Paint-Funktionen - nur fuer diese View
    1743             : //
    1744             : 
    1745           0 : void ScTabView::MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow )
    1746             : {
    1747           0 :     DrawDeselectAll();
    1748             : 
    1749           0 :     if (pDrawView)
    1750           0 :         DrawEnableAnim( false );
    1751             : 
    1752           0 :     EditView* pSpellingView = aViewData.GetSpellingView();
    1753             : 
    1754           0 :     for (sal_uInt16 i=0; i<4; i++)
    1755           0 :         if (pGridWin[i])
    1756           0 :             if ( pGridWin[i]->IsVisible() && !aViewData.HasEditView((ScSplitPos)i) )
    1757             :             {
    1758           0 :                 ScHSplitPos eHWhich = WhichH( (ScSplitPos) i );
    1759           0 :                 ScVSplitPos eVWhich = WhichV( (ScSplitPos) i );
    1760           0 :                 SCCOL nScrX = aViewData.GetPosX( eHWhich );
    1761           0 :                 SCROW nScrY = aViewData.GetPosY( eVWhich );
    1762             : 
    1763             :                 bool bPosVisible =
    1764           0 :                      ( nCol >= nScrX && nCol <= nScrX + aViewData.VisibleCellsX(eHWhich) + 1 &&
    1765           0 :                        nRow >= nScrY && nRow <= nScrY + aViewData.VisibleCellsY(eVWhich) + 1 );
    1766             : 
    1767             :                 //  for the active part, create edit view even if outside the visible area,
    1768             :                 //  so input isn't lost (and the edit view may be scrolled into the visible area)
    1769             : 
    1770             :                 //  #i26433# during spelling, the spelling view must be active
    1771           0 :                 if ( bPosVisible || aViewData.GetActivePart() == (ScSplitPos) i ||
    1772           0 :                      ( pSpellingView && aViewData.GetEditView((ScSplitPos) i) == pSpellingView ) )
    1773             :                 {
    1774           0 :                     pGridWin[i]->HideCursor();
    1775             : 
    1776           0 :                     pGridWin[i]->DeleteCursorOverlay();
    1777           0 :                     pGridWin[i]->DeleteAutoFillOverlay();
    1778           0 :                     pGridWin[i]->DeleteCopySourceOverlay();
    1779             : 
    1780             :                     // flush OverlayManager before changing MapMode to text edit
    1781           0 :                     pGridWin[i]->flushOverlayManager();
    1782             : 
    1783             :                     // MapMode must be set after HideCursor
    1784           0 :                     pGridWin[i]->SetMapMode(aViewData.GetLogicMode());
    1785             : 
    1786           0 :                     aViewData.SetEditEngine( (ScSplitPos) i, pEngine, pGridWin[i], nCol, nRow );
    1787             : 
    1788           0 :                     if ( !bPosVisible )
    1789             :                     {
    1790             :                         //  move the edit view area to the real (possibly negative) position,
    1791             :                         //  or hide if completely above or left of the window
    1792           0 :                         pGridWin[i]->UpdateEditViewPos();
    1793             :                     }
    1794             :                 }
    1795             :             }
    1796             : 
    1797           0 :     if (aViewData.GetViewShell()->HasAccessibilityObjects())
    1798           0 :         aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_ENTEREDITMODE));
    1799           0 : }
    1800             : 
    1801           0 : void ScTabView::UpdateEditView()
    1802             : {
    1803           0 :     ScSplitPos eActive = aViewData.GetActivePart();
    1804           0 :     for (sal_uInt16 i=0; i<4; i++)
    1805           0 :         if (aViewData.HasEditView( (ScSplitPos) i ))
    1806             :         {
    1807           0 :             EditView* pEditView = aViewData.GetEditView( (ScSplitPos) i );
    1808             :             aViewData.SetEditEngine( (ScSplitPos) i,
    1809           0 :                 static_cast<ScEditEngineDefaulter*>(pEditView->GetEditEngine()),
    1810           0 :                 pGridWin[i], GetViewData()->GetCurX(), GetViewData()->GetCurY() );
    1811           0 :             if ( (ScSplitPos)i == eActive )
    1812           0 :                 pEditView->ShowCursor( false );
    1813             :         }
    1814           0 : }
    1815             : 
    1816         190 : void ScTabView::KillEditView( bool bNoPaint )
    1817             : {
    1818             :     sal_uInt16 i;
    1819         190 :     SCCOL nCol1 = aViewData.GetEditStartCol();
    1820         190 :     SCROW nRow1 = aViewData.GetEditStartRow();
    1821         190 :     SCCOL nCol2 = aViewData.GetEditEndCol();
    1822         190 :     SCROW nRow2 = aViewData.GetEditEndRow();
    1823             :     bool bPaint[4];
    1824         190 :     bool bNotifyAcc = false;
    1825             : 
    1826         190 :     bool bExtended = nRow1 != nRow2;                    // Col wird sowieso bis zum Ende gezeichnet
    1827         190 :     bool bAtCursor = nCol1 <= aViewData.GetCurX() &&
    1828         190 :                      nCol2 >= aViewData.GetCurX() &&
    1829         380 :                      nRow1 == aViewData.GetCurY();
    1830         950 :     for (i=0; i<4; i++)
    1831             :     {
    1832         760 :         bPaint[i] = aViewData.HasEditView( (ScSplitPos) i );
    1833         760 :         if (bPaint[i])
    1834           0 :             bNotifyAcc = true;
    1835             :     }
    1836             : 
    1837             :     // #108931#; notify accessibility before all things happen
    1838         190 :     if ((bNotifyAcc) && (aViewData.GetViewShell()->HasAccessibilityObjects()))
    1839           0 :         aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_LEAVEEDITMODE));
    1840             : 
    1841         190 :     aViewData.ResetEditView();
    1842         950 :     for (i=0; i<4; i++)
    1843         760 :         if (pGridWin[i] && bPaint[i])
    1844           0 :             if (pGridWin[i]->IsVisible())
    1845             :             {
    1846           0 :                 pGridWin[i]->ShowCursor();
    1847             : 
    1848           0 :                 pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode());
    1849             : 
    1850             :                 // #i73567# the cell still has to be repainted
    1851           0 :                 if (bExtended || ( bAtCursor && !bNoPaint ))
    1852             :                 {
    1853           0 :                     pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2 );
    1854           0 :                     pGridWin[i]->UpdateSelectionOverlay();
    1855             :                 }
    1856             :             }
    1857             : 
    1858         190 :     if (pDrawView)
    1859         190 :         DrawEnableAnim( true );
    1860             : 
    1861             :         //  GrabFocus immer dann, wenn diese View aktiv ist und
    1862             :         //  die Eingabezeile den Focus hat
    1863             : 
    1864         190 :     bool bGrabFocus = false;
    1865         190 :     if (aViewData.IsActive())
    1866             :     {
    1867         180 :         ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
    1868         180 :         if ( pInputHdl )
    1869             :         {
    1870         152 :             ScInputWindow* pInputWin = pInputHdl->GetInputWindow();
    1871         152 :             if (pInputWin && pInputWin->IsInputActive())
    1872           0 :                 bGrabFocus = true;
    1873             :         }
    1874             :     }
    1875             : 
    1876         190 :     if (bGrabFocus)
    1877             :     {
    1878             : //      So soll es gemacht werden, damit der Sfx es mitbekommt, klappt aber nicht:
    1879             : //!     aViewData.GetViewShell()->GetViewFrame()->GetWindow().GrabFocus();
    1880             : //      deshalb erstmal so:
    1881           0 :         GetActiveWin()->GrabFocus();
    1882             :     }
    1883             : 
    1884             :     //  Cursor-Abfrage erst nach GrabFocus
    1885             : 
    1886         950 :     for (i=0; i<4; i++)
    1887         760 :         if (pGridWin[i] && pGridWin[i]->IsVisible())
    1888             :         {
    1889         190 :             Cursor* pCur = pGridWin[i]->GetCursor();
    1890         190 :             if (pCur && pCur->IsVisible())
    1891           0 :                 pCur->Hide();
    1892             : 
    1893         190 :             if(bPaint[i])
    1894             :             {
    1895           0 :                 pGridWin[i]->UpdateCursorOverlay();
    1896           0 :                 pGridWin[i]->UpdateAutoFillOverlay();
    1897             :             }
    1898             :         }
    1899         190 : }
    1900             : 
    1901         160 : void ScTabView::UpdateFormulas()
    1902             : {
    1903         160 :     if ( aViewData.GetDocument()->IsAutoCalcShellDisabled() )
    1904         160 :         return ;
    1905             : 
    1906             :     sal_uInt16 i;
    1907         800 :     for (i=0; i<4; i++)
    1908         640 :         if (pGridWin[i])
    1909         160 :             if (pGridWin[i]->IsVisible())
    1910         160 :                 pGridWin[i]->UpdateFormulas();
    1911             : 
    1912         160 :     if ( aViewData.IsPagebreakMode() )
    1913           0 :         UpdatePageBreakData();              //! asynchron
    1914             : 
    1915         160 :     UpdateHeaderWidth();
    1916             : 
    1917             :     //  if in edit mode, adjust edit view area because widths/heights may have changed
    1918         160 :     if ( aViewData.HasEditView( aViewData.GetActivePart() ) )
    1919           0 :         UpdateEditView();
    1920             : }
    1921             : 
    1922             : //  PaintArea -Block neu zeichnen
    1923             : 
    1924         122 : void ScTabView::PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
    1925             :                             ScUpdateMode eMode )
    1926             : {
    1927             :     SCCOL nCol1;
    1928             :     SCROW nRow1;
    1929             :     SCCOL nCol2;
    1930             :     SCROW nRow2;
    1931             : 
    1932         122 :     PutInOrder( nStartCol, nEndCol );
    1933         122 :     PutInOrder( nStartRow, nEndRow );
    1934             : 
    1935         610 :     for (size_t i = 0; i < 4; ++i)
    1936             :     {
    1937         488 :         if (!pGridWin[i] || !pGridWin[i]->IsVisible())
    1938         366 :             continue;
    1939             : 
    1940         122 :         ScHSplitPos eHWhich = WhichH( (ScSplitPos) i );
    1941         122 :         ScVSplitPos eVWhich = WhichV( (ScSplitPos) i );
    1942         122 :         bool bOut = false;
    1943             : 
    1944         122 :         nCol1 = nStartCol;
    1945         122 :         nRow1 = nStartRow;
    1946         122 :         nCol2 = nEndCol;
    1947         122 :         nRow2 = nEndRow;
    1948             : 
    1949         122 :         SCCOL nScrX = aViewData.GetPosX( eHWhich );
    1950         122 :         SCROW nScrY = aViewData.GetPosY( eVWhich );
    1951         122 :         if (nCol1 < nScrX) nCol1 = nScrX;
    1952         122 :         if (nCol2 < nScrX)
    1953             :         {
    1954           0 :             if ( eMode == SC_UPDATE_ALL )   // for UPDATE_ALL, paint anyway
    1955           0 :                 nCol2 = nScrX;              // (because of extending strings to the right)
    1956             :             else
    1957           0 :                 bOut = true;                // completely outside the window
    1958             :         }
    1959         122 :         if (nRow1 < nScrY) nRow1 = nScrY;
    1960         122 :         if (nRow2 < nScrY) bOut = true;
    1961             : 
    1962         122 :         SCCOL nLastX = nScrX + aViewData.VisibleCellsX( eHWhich ) + 1;
    1963         122 :         SCROW nLastY = nScrY + aViewData.VisibleCellsY( eVWhich ) + 1;
    1964         122 :         if (nCol1 > nLastX) bOut = true;
    1965         122 :         if (nCol2 > nLastX) nCol2 = nLastX;
    1966         122 :         if (nRow1 > nLastY) bOut = true;
    1967         122 :         if (nRow2 > nLastY) nRow2 = nLastY;
    1968             : 
    1969         122 :         if (bOut)
    1970           8 :             continue;
    1971             : 
    1972         114 :         if ( eMode == SC_UPDATE_CHANGED )
    1973           0 :             pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2, eMode );
    1974             :         else    // ALL oder MARKS
    1975             :         {
    1976         114 :             bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
    1977         114 :             long nLayoutSign = bLayoutRTL ? -1 : 1;
    1978             : 
    1979         114 :             Point aStart = aViewData.GetScrPos( nCol1, nRow1, (ScSplitPos) i );
    1980         114 :             Point aEnd   = aViewData.GetScrPos( nCol2+1, nRow2+1, (ScSplitPos) i );
    1981         114 :             if ( eMode == SC_UPDATE_ALL )
    1982         114 :                 aEnd.X() = bLayoutRTL ? 0 : (pGridWin[i]->GetOutputSizePixel().Width());
    1983         114 :             aEnd.X() -= nLayoutSign;
    1984         114 :             aEnd.Y() -= 1;
    1985             : 
    1986             :             // #i85232# include area below cells (could be done in GetScrPos?)
    1987         114 :             if ( eMode == SC_UPDATE_ALL && nRow2 >= MAXROW )
    1988           0 :                 aEnd.Y() = pGridWin[i]->GetOutputSizePixel().Height();
    1989             : 
    1990         114 :             bool bShowChanges = true;           //! ...
    1991         114 :             if (bShowChanges)
    1992             :             {
    1993         114 :                 aStart.X() -= nLayoutSign;      // include change marks
    1994         114 :                 aStart.Y() -= 1;
    1995             :             }
    1996             : 
    1997         114 :             bool bMarkClipped = aViewData.GetOptions().GetOption( VOPT_CLIPMARKS );
    1998         114 :             if (bMarkClipped)
    1999             :             {
    2000             :                 //  dazu muesste ScColumn::IsEmptyBlock optimiert werden
    2001             :                 //  (auf Search() umstellen)
    2002             :                 //!if ( nCol1 > 0 && !aViewData.GetDocument()->IsBlockEmpty(
    2003             :                 //!                     aViewData.GetTabNo(),
    2004             :                 //!                     0, nRow1, nCol1-1, nRow2 ) )
    2005             :                 {
    2006         114 :                     long nMarkPixel = (long)( SC_CLIPMARK_SIZE * aViewData.GetPPTX() );
    2007         114 :                     aStart.X() -= nMarkPixel * nLayoutSign;
    2008         114 :                     if (!bShowChanges)
    2009           0 :                         aStart.X() -= nLayoutSign;      // cell grid
    2010             :                 }
    2011             :             }
    2012             : 
    2013         114 :             pGridWin[i]->Invalidate( pGridWin[i]->PixelToLogic( Rectangle( aStart,aEnd ) ) );
    2014             :         }
    2015             :     }
    2016             : 
    2017             :     // #i79909# Calling UpdateAllOverlays here isn't necessary and would lead to overlay calls from a timer,
    2018             :     // with a wrong MapMode if editing in a cell (reference input).
    2019             :     // #i80499# Overlays need updates in a lot of cases, e.g. changing row/column size,
    2020             :     // or showing/hiding outlines. TODO: selections in inactive windows are vanishing.
    2021             :     // #i84689# With relative conditional formats, PaintArea may be called often (for each changed cell),
    2022             :     // so UpdateAllOverlays was moved to ScTabViewShell::Notify and is called only if PAINT_LEFT/PAINT_TOP
    2023             :     // is set (width or height changed).
    2024         122 : }
    2025             : 
    2026           0 : void ScTabView::PaintRangeFinderEntry (ScRangeFindData* pData, const SCTAB nTab)
    2027             : {
    2028           0 :     ScRange aRef = pData->aRef;
    2029           0 :     aRef.Justify();                 // Justify fuer die Abfragen unten
    2030             : 
    2031           0 :     if ( aRef.aStart == aRef.aEnd )     //! Tab ignorieren?
    2032           0 :         aViewData.GetDocument()->ExtendMerge(aRef);
    2033             : 
    2034           0 :     if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
    2035             :     {
    2036           0 :         SCCOL nCol1 = aRef.aStart.Col();
    2037           0 :         SCROW nRow1 = aRef.aStart.Row();
    2038           0 :         SCCOL nCol2 = aRef.aEnd.Col();
    2039           0 :         SCROW nRow2 = aRef.aEnd.Row();
    2040             : 
    2041             :         //  wegnehmen -> Repaint
    2042             :         //  SC_UPDATE_MARKS: Invalidate, nicht bis zum Zeilenende
    2043             : 
    2044           0 :         bool bHiddenEdge = false;
    2045             :         SCROW nTmp;
    2046           0 :         ScDocument* pDoc = aViewData.GetDocument();
    2047           0 :         while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab) )
    2048             :         {
    2049           0 :             --nCol1;
    2050           0 :             bHiddenEdge = true;
    2051             :         }
    2052           0 :         while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab) )
    2053             :         {
    2054           0 :             ++nCol2;
    2055           0 :             bHiddenEdge = true;
    2056             :         }
    2057           0 :         nTmp = pDoc->LastVisibleRow(0, nRow1, nTab);
    2058           0 :         if (!ValidRow(nTmp))
    2059           0 :             nTmp = 0;
    2060           0 :         if (nTmp < nRow1)
    2061             :         {
    2062           0 :             nRow1 = nTmp;
    2063           0 :             bHiddenEdge = true;
    2064             :         }
    2065           0 :         nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab);
    2066           0 :         if (!ValidRow(nTmp))
    2067           0 :             nTmp = MAXROW;
    2068           0 :         if (nTmp > nRow2)
    2069             :         {
    2070           0 :             nRow2 = nTmp;
    2071           0 :             bHiddenEdge = true;
    2072             :         }
    2073             : 
    2074           0 :         if ( nCol2 - nCol1 > 1 && nRow2 - nRow1 > 1 && !bHiddenEdge )
    2075             :         {
    2076             :             //  nur an den Raendern entlang
    2077           0 :             PaintArea( nCol1, nRow1, nCol2, nRow1, SC_UPDATE_MARKS );
    2078           0 :             PaintArea( nCol1, nRow1+1, nCol1, nRow2-1, SC_UPDATE_MARKS );
    2079           0 :             PaintArea( nCol2, nRow1+1, nCol2, nRow2-1, SC_UPDATE_MARKS );
    2080           0 :             PaintArea( nCol1, nRow2, nCol2, nRow2, SC_UPDATE_MARKS );
    2081             :         }
    2082             :         else    // alles am Stueck
    2083           0 :             PaintArea( nCol1, nRow1, nCol2, nRow2, SC_UPDATE_MARKS );
    2084             :     }
    2085           0 : }
    2086             : 
    2087           0 : void ScTabView::PaintRangeFinder( long nNumber )
    2088             : {
    2089           0 :     ScInputHandler* pHdl = SC_MOD()->GetInputHdl( aViewData.GetViewShell() );
    2090           0 :     if (pHdl)
    2091             :     {
    2092           0 :         ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
    2093           0 :         if ( pRangeFinder && pRangeFinder->GetDocName() == aViewData.GetDocShell()->GetTitle() )
    2094             :         {
    2095           0 :             SCTAB nTab = aViewData.GetTabNo();
    2096           0 :             sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count();
    2097             : 
    2098           0 :             if (nNumber < 0)
    2099             :             {
    2100           0 :                 for (sal_uInt16 i=0; i<nCount; i++)
    2101           0 :                     PaintRangeFinderEntry(pRangeFinder->GetObject(i),nTab);
    2102             :             }
    2103             :             else
    2104             :             {
    2105           0 :                 sal_uInt16 idx = nNumber;
    2106           0 :                 if (idx < nCount)
    2107           0 :                     PaintRangeFinderEntry(pRangeFinder->GetObject(idx),nTab);
    2108             :             }
    2109             :         }
    2110             :     }
    2111           0 : }
    2112             : 
    2113             : //  fuer Chart-Daten-Markierung
    2114             : 
    2115           0 : void ScTabView::AddHighlightRange( const ScRange& rRange, const Color& rColor )
    2116             : {
    2117           0 :     maHighlightRanges.push_back( ScHighlightEntry( rRange, rColor ) );
    2118             : 
    2119           0 :     SCTAB nTab = aViewData.GetTabNo();
    2120           0 :     if ( nTab >= rRange.aStart.Tab() && nTab <= rRange.aEnd.Tab() )
    2121           0 :         PaintArea( rRange.aStart.Col(), rRange.aStart.Row(),
    2122           0 :                     rRange.aEnd.Col(), rRange.aEnd.Row(), SC_UPDATE_MARKS );
    2123           0 : }
    2124             : 
    2125           0 : void ScTabView::ClearHighlightRanges()
    2126             : {
    2127           0 :     SCTAB nTab = aViewData.GetTabNo();
    2128           0 :     std::vector<ScHighlightEntry>::const_iterator pIter;
    2129           0 :     for ( pIter = maHighlightRanges.begin(); pIter != maHighlightRanges.end(); ++pIter)
    2130             :     {
    2131           0 :         ScRange aRange = pIter->aRef;
    2132           0 :         if ( nTab >= aRange.aStart.Tab() && nTab <= aRange.aEnd.Tab() )
    2133           0 :             PaintArea( aRange.aStart.Col(), aRange.aStart.Row(),
    2134           0 :                        aRange.aEnd.Col(), aRange.aEnd.Row(), SC_UPDATE_MARKS );
    2135             :     }
    2136             : 
    2137           0 :     maHighlightRanges.clear();
    2138           0 : }
    2139             : 
    2140           0 : void ScTabView::DoChartSelection(
    2141             :     const uno::Sequence< chart2::data::HighlightedRange > & rHilightRanges )
    2142             : {
    2143           0 :     ClearHighlightRanges();
    2144           0 :     const sal_Unicode sep = ::formula::FormulaCompiler::GetNativeSymbol(ocSep).GetChar(0);
    2145             : 
    2146           0 :     for( sal_Int32 i=0; i<rHilightRanges.getLength(); ++i )
    2147             :     {
    2148           0 :         Color aSelColor( rHilightRanges[i].PreferredColor );
    2149           0 :         ScRangeList aRangeList;
    2150           0 :         ScDocument* pDoc = aViewData.GetDocShell()->GetDocument();
    2151           0 :         if( ScRangeStringConverter::GetRangeListFromString(
    2152           0 :                 aRangeList, rHilightRanges[i].RangeRepresentation, pDoc, pDoc->GetAddressConvention(), sep ))
    2153             :         {
    2154           0 :             size_t nListSize = aRangeList.size();
    2155           0 :             for ( size_t j = 0; j < nListSize; ++j )
    2156             :             {
    2157           0 :                 ScRange* p = aRangeList[j];
    2158           0 :                 if( rHilightRanges[i].Index == - 1 )
    2159           0 :                     AddHighlightRange( *p, aSelColor );
    2160             :                 else
    2161           0 :                     AddHighlightRange( lcl_getSubRangeByIndex( *p, rHilightRanges[i].Index ), aSelColor );
    2162             :             }
    2163             :         }
    2164           0 :     }
    2165           0 : }
    2166             : 
    2167             : //  PaintGrid - Datenbereiche neu zeichnen
    2168             : 
    2169          38 : void ScTabView::PaintGrid()
    2170             : {
    2171             :     sal_uInt16 i;
    2172         190 :     for (i=0; i<4; i++)
    2173         152 :         if (pGridWin[i])
    2174          38 :             if (pGridWin[i]->IsVisible())
    2175          38 :                 pGridWin[i]->Invalidate();
    2176          38 : }
    2177             : 
    2178             : //  PaintTop - obere Kontrollelemente neu zeichnen
    2179             : 
    2180          38 : void ScTabView::PaintTop()
    2181             : {
    2182             :     sal_uInt16 i;
    2183         114 :     for (i=0; i<2; i++)
    2184             :     {
    2185          76 :         if (pColBar[i])
    2186          38 :             pColBar[i]->Invalidate();
    2187          76 :         if (pColOutline[i])
    2188           0 :             pColOutline[i]->Invalidate();
    2189             :     }
    2190          38 : }
    2191             : 
    2192           0 : void ScTabView::CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress)
    2193             : {
    2194             :     sal_uInt16 i;
    2195             : 
    2196           0 :     for(i=0; i<4; i++)
    2197             :     {
    2198           0 :         if(pGridWin[i])
    2199             :         {
    2200           0 :             if(pGridWin[i]->IsVisible())
    2201             :             {
    2202           0 :                 pGridWin[i]->CreateAnchorHandle(rHdl, rAddress);
    2203             :             }
    2204             :         }
    2205             :     }
    2206           0 : }
    2207             : 
    2208           2 : void ScTabView::PaintTopArea( SCCOL nStartCol, SCCOL nEndCol )
    2209             : {
    2210             :         //  Pixel-Position der linken Kante
    2211             : 
    2212           4 :     if ( nStartCol < aViewData.GetPosX(SC_SPLIT_LEFT) ||
    2213           2 :          nStartCol < aViewData.GetPosX(SC_SPLIT_RIGHT) )
    2214           0 :         aViewData.RecalcPixPos();
    2215             : 
    2216             :         //  Fixierung anpassen (UpdateFixX setzt HSplitPos neu)
    2217             : 
    2218           2 :     if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX && nStartCol < aViewData.GetFixPosX() )
    2219           0 :         if (aViewData.UpdateFixX())
    2220           0 :             RepeatResize();
    2221             : 
    2222             :         //  zeichnen
    2223             : 
    2224           2 :     if (nStartCol>0)
    2225           0 :         --nStartCol;                //! allgemeiner ?
    2226             : 
    2227           2 :     bool bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
    2228           2 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
    2229             : 
    2230           6 :     for (sal_uInt16 i=0; i<2; i++)
    2231             :     {
    2232           4 :         ScHSplitPos eWhich = (ScHSplitPos) i;
    2233           4 :         if (pColBar[eWhich])
    2234             :         {
    2235           2 :             Size aWinSize = pColBar[eWhich]->GetSizePixel();
    2236           2 :             long nStartX = aViewData.GetScrPos( nStartCol, 0, eWhich ).X();
    2237             :             long nEndX;
    2238           2 :             if (nEndCol >= MAXCOL)
    2239           2 :                 nEndX = bLayoutRTL ? 0 : ( aWinSize.Width()-1 );
    2240             :             else
    2241           0 :                 nEndX = aViewData.GetScrPos( nEndCol+1, 0, eWhich ).X() - nLayoutSign;
    2242           6 :             pColBar[eWhich]->Invalidate(
    2243           8 :                     Rectangle( nStartX, 0, nEndX, aWinSize.Height()-1 ) );
    2244             :         }
    2245           4 :         if (pColOutline[eWhich])
    2246           0 :             pColOutline[eWhich]->Invalidate();
    2247             :     }
    2248           2 : }
    2249             : 
    2250             : 
    2251             : //  PaintLeft - linke Kontrollelemente neu zeichnen
    2252             : 
    2253          38 : void ScTabView::PaintLeft()
    2254             : {
    2255             :     sal_uInt16 i;
    2256         114 :     for (i=0; i<2; i++)
    2257             :     {
    2258          76 :         if (pRowBar[i])
    2259          38 :             pRowBar[i]->Invalidate();
    2260          76 :         if (pRowOutline[i])
    2261           0 :             pRowOutline[i]->Invalidate();
    2262             :     }
    2263          38 : }
    2264             : 
    2265          12 : void ScTabView::PaintLeftArea( SCROW nStartRow, SCROW nEndRow )
    2266             : {
    2267             :         //  Pixel-Position der oberen Kante
    2268             : 
    2269          24 :     if ( nStartRow < aViewData.GetPosY(SC_SPLIT_TOP) ||
    2270          12 :          nStartRow < aViewData.GetPosY(SC_SPLIT_BOTTOM) )
    2271           2 :         aViewData.RecalcPixPos();
    2272             : 
    2273             :         //  Fixierung anpassen (UpdateFixY setzt VSplitPos neu)
    2274             : 
    2275          12 :     if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX && nStartRow < aViewData.GetFixPosY() )
    2276           0 :         if (aViewData.UpdateFixY())
    2277           0 :             RepeatResize();
    2278             : 
    2279             :         //  zeichnen
    2280             : 
    2281          12 :     if (nStartRow>0)
    2282           8 :         --nStartRow;
    2283             : 
    2284          36 :     for (sal_uInt16 i=0; i<2; i++)
    2285             :     {
    2286          24 :         ScVSplitPos eWhich = (ScVSplitPos) i;
    2287          24 :         if (pRowBar[eWhich])
    2288             :         {
    2289          12 :             Size aWinSize = pRowBar[eWhich]->GetSizePixel();
    2290          12 :             long nStartY = aViewData.GetScrPos( 0, nStartRow, eWhich ).Y();
    2291             :             long nEndY;
    2292          12 :             if (nEndRow >= MAXROW)
    2293          12 :                 nEndY = aWinSize.Height()-1;
    2294             :             else
    2295           0 :                 nEndY = aViewData.GetScrPos( 0, nEndRow+1, eWhich ).Y() - 1;
    2296          36 :             pRowBar[eWhich]->Invalidate(
    2297          48 :                     Rectangle( 0, nStartY, aWinSize.Width()-1, nEndY ) );
    2298             :         }
    2299          24 :         if (pRowOutline[eWhich])
    2300           0 :             pRowOutline[eWhich]->Invalidate();
    2301             :     }
    2302          12 : }
    2303             : 
    2304          98 : bool ScTabView::PaintExtras()
    2305             : {
    2306          98 :     bool bRet = false;
    2307          98 :     ScDocument* pDoc = aViewData.GetDocument();
    2308          98 :     SCTAB nTab = aViewData.GetTabNo();
    2309          98 :     if (!pDoc->HasTable(nTab))                  // Tabelle geloescht ?
    2310             :     {
    2311           0 :         SCTAB nCount = pDoc->GetTableCount();
    2312           0 :         aViewData.SetTabNo(nCount-1);
    2313           0 :         bRet = true;
    2314             :     }
    2315          98 :     pTabControl->UpdateStatus();                        // true = active
    2316          98 :     return bRet;
    2317             : }
    2318             : 
    2319           0 : void ScTabView::RecalcPPT()
    2320             : {
    2321             :     //  called after changes that require the PPT values to be recalculated
    2322             :     //  (currently from detective operations)
    2323             : 
    2324           0 :     double nOldX = aViewData.GetPPTX();
    2325           0 :     double nOldY = aViewData.GetPPTY();
    2326             : 
    2327           0 :     aViewData.RefreshZoom();                            // pre-calculate new PPT values
    2328             : 
    2329           0 :     bool bChangedX = ( aViewData.GetPPTX() != nOldX );
    2330           0 :     bool bChangedY = ( aViewData.GetPPTY() != nOldY );
    2331           0 :     if ( bChangedX || bChangedY )
    2332             :     {
    2333             :         //  call view SetZoom (including draw scale, split update etc)
    2334             :         //  and paint only if values changed
    2335             : 
    2336           0 :         Fraction aZoomX = aViewData.GetZoomX();
    2337           0 :         Fraction aZoomY = aViewData.GetZoomY();
    2338           0 :         SetZoom( aZoomX, aZoomY, false );
    2339             : 
    2340           0 :         PaintGrid();
    2341           0 :         if (bChangedX)
    2342           0 :             PaintTop();
    2343           0 :         if (bChangedY)
    2344           0 :             PaintLeft();
    2345             :     }
    2346           0 : }
    2347             : 
    2348          56 : void ScTabView::ActivateView( bool bActivate, bool bFirst )
    2349             : {
    2350          56 :     if ( bActivate == aViewData.IsActive() && !bFirst )
    2351             :     {
    2352             :         //  keine Assertion mehr - kommt vor, wenn vorher im Drag&Drop
    2353             :         //  auf ein anderes Dokument umgeschaltet wurde
    2354          56 :         return;
    2355             :     }
    2356             : 
    2357             :     // wird nur bei MDI-(De)Activate gerufen
    2358             :     // aViewData.Activate hinten wegen Cursor-Show bei KillEditView
    2359             :     //  Markierung nicht mehr loeschen - wenn an der ViewData Activate(false) gesetzt ist,
    2360             :     //  wird die Markierung nicht ausgegeben
    2361             : 
    2362          56 :     if (!bActivate)
    2363             :     {
    2364          26 :         ScModule* pScMod = SC_MOD();
    2365          26 :         bool bRefMode = pScMod->IsFormulaMode();
    2366             : 
    2367             :             //  Referenzeingabe nicht abbrechen, um Referenzen auf
    2368             :             //  andere Dokumente zuzulassen
    2369             : 
    2370          26 :         if (!bRefMode)
    2371             :         {
    2372             :             //  pass view to GetInputHdl, this view may not be current anymore
    2373          26 :             ScInputHandler* pHdl = SC_MOD()->GetInputHdl(aViewData.GetViewShell());
    2374          26 :             if (pHdl)
    2375          26 :                 pHdl->EnterHandler();
    2376             :         }
    2377             :     }
    2378             : 
    2379          56 :     PaintExtras();
    2380             : 
    2381          56 :     aViewData.Activate(bActivate);
    2382             : 
    2383          56 :     PaintBlock(false);                  // Repaint, Markierung je nach Active-Status
    2384             : 
    2385          56 :     if (!bActivate)
    2386          26 :         HideAllCursors();               // Cursor
    2387          30 :     else if (!bFirst)
    2388           0 :         ShowAllCursors();
    2389             : 
    2390          56 :     if (bActivate)
    2391             :     {
    2392          30 :         if ( bFirst )
    2393             :         {
    2394          30 :             ScSplitPos eWin = aViewData.GetActivePart();
    2395             :             OSL_ENSURE( pGridWin[eWin], "rottes Dokument, nicht alle SplitPos in GridWin" );
    2396          30 :             if ( !pGridWin[eWin] )
    2397             :             {
    2398           0 :                 eWin = SC_SPLIT_BOTTOMLEFT;
    2399           0 :                 if ( !pGridWin[eWin] )
    2400             :                 {
    2401             :                     short i;
    2402           0 :                     for ( i=0; i<4; i++ )
    2403             :                     {
    2404           0 :                         if ( pGridWin[i] )
    2405             :                         {
    2406           0 :                             eWin = (ScSplitPos) i;
    2407           0 :                             break;  // for
    2408             :                         }
    2409             :                     }
    2410             :                     OSL_ENSURE( i<4, "und BUMM" );
    2411             :                 }
    2412           0 :                 aViewData.SetActivePart( eWin );
    2413             :             }
    2414             :         }
    2415             :         //  hier nicht mehr selber GrabFocus rufen!
    2416             :         //  Wenn das Doc bearbeitet wird, ruft der Sfx selber GrabFocus am Fenster der Shell.
    2417             :         //  Wenn es z.B. ein Mailbody ist, darf es den Focus nicht bekommen (Bug #43638#)
    2418             : 
    2419          30 :         UpdateInputContext();
    2420             :     }
    2421             :     else
    2422          26 :         pGridWin[aViewData.GetActivePart()]->ClickExtern();
    2423             : }
    2424             : 
    2425           0 : void ScTabView::ActivatePart( ScSplitPos eWhich )
    2426             : {
    2427           0 :     ScSplitPos eOld = aViewData.GetActivePart();
    2428           0 :     if ( eOld != eWhich )
    2429             :     {
    2430           0 :         bInActivatePart = true;
    2431             : 
    2432           0 :         bool bRefMode = SC_MOD()->IsFormulaMode();
    2433             : 
    2434             :         //  the HasEditView call during SetCursor would fail otherwise
    2435           0 :         if ( aViewData.HasEditView(eOld) && !bRefMode )
    2436           0 :             UpdateInputLine();
    2437             : 
    2438           0 :         ScHSplitPos eOldH = WhichH(eOld);
    2439           0 :         ScVSplitPos eOldV = WhichV(eOld);
    2440           0 :         ScHSplitPos eNewH = WhichH(eWhich);
    2441           0 :         ScVSplitPos eNewV = WhichV(eWhich);
    2442           0 :         bool bTopCap  = pColBar[eOldH] && pColBar[eOldH]->IsMouseCaptured();
    2443           0 :         bool bLeftCap = pRowBar[eOldV] && pRowBar[eOldV]->IsMouseCaptured();
    2444             : 
    2445           0 :         bool bFocus = pGridWin[eOld]->HasFocus();
    2446           0 :         bool bCapture = pGridWin[eOld]->IsMouseCaptured();
    2447           0 :         if (bCapture)
    2448           0 :             pGridWin[eOld]->ReleaseMouse();
    2449           0 :         pGridWin[eOld]->ClickExtern();
    2450           0 :         pGridWin[eOld]->HideCursor();
    2451           0 :         pGridWin[eWhich]->HideCursor();
    2452           0 :         aViewData.SetActivePart( eWhich );
    2453             : 
    2454           0 :         ScTabViewShell* pShell = aViewData.GetViewShell();
    2455           0 :         pShell->WindowChanged();
    2456             : 
    2457           0 :         pSelEngine->SetWindow(pGridWin[eWhich]);
    2458           0 :         pSelEngine->SetWhich(eWhich);
    2459           0 :         pSelEngine->SetVisibleArea( Rectangle(Point(), pGridWin[eWhich]->GetOutputSizePixel()) );
    2460             : 
    2461           0 :         pGridWin[eOld]->MoveMouseStatus(*pGridWin[eWhich]);
    2462             : 
    2463           0 :         if ( bCapture || pGridWin[eWhich]->IsMouseCaptured() )
    2464             :         {
    2465             :             //  Tracking statt CaptureMouse, damit sauber abgebrochen werden kann
    2466             :             //  (SelectionEngine ruft CaptureMouse beim SetWindow)
    2467             :             //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?!
    2468           0 :             pGridWin[eWhich]->ReleaseMouse();
    2469           0 :             pGridWin[eWhich]->StartTracking();
    2470             :         }
    2471             : 
    2472           0 :         if ( bTopCap && pColBar[eNewH] )
    2473             :         {
    2474           0 :             pColBar[eOldH]->SetIgnoreMove(true);
    2475           0 :             pColBar[eNewH]->SetIgnoreMove(false);
    2476           0 :             pHdrSelEng->SetWindow( pColBar[eNewH] );
    2477           0 :             long nWidth = pColBar[eNewH]->GetOutputSizePixel().Width();
    2478           0 :             pHdrSelEng->SetVisibleArea( Rectangle( 0, LONG_MIN, nWidth-1, LONG_MAX ) );
    2479           0 :             pColBar[eNewH]->CaptureMouse();
    2480             :         }
    2481           0 :         if ( bLeftCap && pRowBar[eNewV] )
    2482             :         {
    2483           0 :             pRowBar[eOldV]->SetIgnoreMove(true);
    2484           0 :             pRowBar[eNewV]->SetIgnoreMove(false);
    2485           0 :             pHdrSelEng->SetWindow( pRowBar[eNewV] );
    2486           0 :             long nHeight = pRowBar[eNewV]->GetOutputSizePixel().Height();
    2487           0 :             pHdrSelEng->SetVisibleArea( Rectangle( LONG_MIN, 0, LONG_MAX, nHeight-1 ) );
    2488           0 :             pRowBar[eNewV]->CaptureMouse();
    2489             :         }
    2490           0 :         aHdrFunc.SetWhich(eWhich);
    2491             : 
    2492           0 :         pGridWin[eOld]->ShowCursor();
    2493           0 :         pGridWin[eWhich]->ShowCursor();
    2494             : 
    2495           0 :         SfxInPlaceClient* pClient = aViewData.GetViewShell()->GetIPClient();
    2496           0 :         bool bOleActive = ( pClient && pClient->IsObjectInPlaceActive() );
    2497             : 
    2498             :         //  don't switch ViewShell's active window during RefInput, because the focus
    2499             :         //  might change, and subsequent SetReference calls wouldn't find the right EditView
    2500           0 :         if ( !bRefMode && !bOleActive )
    2501           0 :             aViewData.GetViewShell()->SetWindow( pGridWin[eWhich] );
    2502             : 
    2503           0 :         if ( bFocus && !aViewData.IsAnyFillMode() && !bRefMode )
    2504             :         {
    2505             :             //  GrabFocus nur, wenn vorher das andere GridWindow den Focus hatte
    2506             :             //  (z.B. wegen Suchen & Ersetzen)
    2507           0 :             pGridWin[eWhich]->GrabFocus();
    2508             :         }
    2509             : 
    2510           0 :         bInActivatePart = false;
    2511             :     }
    2512           0 : }
    2513             : 
    2514         182 : void ScTabView::HideListBox()
    2515             : {
    2516         910 :     for (sal_uInt16 i=0; i<4; i++)
    2517         728 :         if (pGridWin[i])
    2518         182 :             pGridWin[i]->ClickExtern();
    2519         182 : }
    2520             : 
    2521          68 : void ScTabView::UpdateInputContext()
    2522             : {
    2523          68 :     ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
    2524          68 :     if (pWin)
    2525          68 :         pWin->UpdateInputContext();
    2526             : 
    2527          68 :     if (pTabControl)
    2528          68 :         pTabControl->UpdateInputContext();
    2529          68 : }
    2530             : 
    2531             : //  GetGridWidth - Breite eines Ausgabebereichs (fuer ViewData)
    2532             : 
    2533        1564 : long ScTabView::GetGridWidth( ScHSplitPos eWhich )
    2534             : {
    2535        1564 :     ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
    2536        1564 :     if (pGridWin[eGridWhich])
    2537        1564 :         return pGridWin[eGridWhich]->GetSizePixel().Width();
    2538             :     else
    2539           0 :         return 0;
    2540             : }
    2541             : 
    2542             : //  GetGridHeight - Hoehe eines Ausgabebereichs (fuer ViewData)
    2543             : 
    2544        1868 : long ScTabView::GetGridHeight( ScVSplitPos eWhich )
    2545             : {
    2546        1868 :     ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
    2547        1868 :     if (pGridWin[eGridWhich])
    2548        1868 :         return pGridWin[eGridWhich]->GetSizePixel().Height();
    2549             :     else
    2550           0 :         return 0;
    2551             : }
    2552             : 
    2553           0 : void ScTabView::UpdateInputLine()
    2554             : {
    2555           0 :     SC_MOD()->InputEnterHandler();
    2556           0 : }
    2557             : 
    2558          98 : void ScTabView::ZoomChanged()
    2559             : {
    2560          98 :     ScInputHandler* pHdl = SC_MOD()->GetInputHdl(aViewData.GetViewShell());
    2561          98 :     if (pHdl)
    2562          98 :         pHdl->SetRefScale( aViewData.GetZoomX(), aViewData.GetZoomY() );
    2563             : 
    2564          98 :     UpdateFixPos();
    2565             : 
    2566          98 :     UpdateScrollBars();
    2567             : 
    2568             :     //  VisArea...
    2569             :     // AW: Discussed with NN if there is a reason that new map mode was only set for one window,
    2570             :     // but is not. Setting only on one window causes the first repaint to have the old mapMode
    2571             :     // in three of four views, so the overlay will save the wrong content e.g. when zooming out.
    2572             :     // Changing to setting map mode at all windows.
    2573             :     sal_uInt32 a;
    2574             : 
    2575         490 :     for(a = 0L; a < 4L; a++)
    2576             :     {
    2577         392 :         if(pGridWin[a])
    2578             :         {
    2579          98 :             pGridWin[a]->SetMapMode(pGridWin[a]->GetDrawMapMode());
    2580             :         }
    2581             :     }
    2582             : 
    2583          98 :     SetNewVisArea();
    2584             : 
    2585          98 :     InterpretVisible();     // have everything calculated before painting
    2586             : 
    2587          98 :     SfxBindings& rBindings = aViewData.GetBindings();
    2588          98 :     rBindings.Invalidate( SID_ATTR_ZOOM );
    2589          98 :     rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
    2590             : 
    2591          98 :     HideNoteMarker();
    2592             : 
    2593             :     // AW: To not change too much, use pWin here
    2594          98 :     ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
    2595             : 
    2596          98 :     if ( pWin && aViewData.HasEditView( aViewData.GetActivePart() ) )
    2597             :     {
    2598             :         // flush OverlayManager before changing the MapMode
    2599           0 :         pWin->flushOverlayManager();
    2600             : 
    2601             :         //  make sure the EditView's position and size are updated
    2602             :         //  with the right (logic, not drawing) MapMode
    2603           0 :         pWin->SetMapMode( aViewData.GetLogicMode() );
    2604           0 :         UpdateEditView();
    2605             :     }
    2606          98 : }
    2607             : 
    2608         244 : void ScTabView::CheckNeedsRepaint()
    2609             : {
    2610             :     sal_uInt16 i;
    2611        1220 :     for (i=0; i<4; i++)
    2612         976 :         if ( pGridWin[i] && pGridWin[i]->IsVisible() )
    2613         214 :             pGridWin[i]->CheckNeedsRepaint();
    2614         346 : }
    2615             : 
    2616             : 
    2617             : 
    2618             : 
    2619             : 
    2620             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10