LCOV - code coverage report
Current view: top level - sc/source/ui/view - tabview3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 626 1382 45.3 %
Date: 2012-08-25 Functions: 35 66 53.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 401 1555 25.8 %

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

Generated by: LCOV version 1.10