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

Generated by: LCOV version 1.10