LCOV - code coverage report
Current view: top level - sc/source/ui/view - tabview2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 255 760 33.6 %
Date: 2012-08-25 Functions: 17 34 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 173 860 20.1 %

           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                 :            : 
      30                 :            : #include "scitems.hxx"
      31                 :            : #include <editeng/eeitem.hxx>
      32                 :            : #include <vcl/timer.hxx>
      33                 :            : #include <vcl/msgbox.hxx>
      34                 :            : #include <sfx2/app.hxx>
      35                 :            : #include <sfx2/viewfrm.hxx>
      36                 :            : #include <sfx2/bindings.hxx>
      37                 :            : #include <sfx2/childwin.hxx>
      38                 :            : 
      39                 :            : #include "attrib.hxx"
      40                 :            : #include "pagedata.hxx"
      41                 :            : #include "tabview.hxx"
      42                 :            : #include "tabvwsh.hxx"
      43                 :            : #include "printfun.hxx"
      44                 :            : #include "stlpool.hxx"
      45                 :            : #include "docsh.hxx"
      46                 :            : #include "gridwin.hxx"
      47                 :            : #include "olinewin.hxx"
      48                 :            : #include "uiitems.hxx"
      49                 :            : #include "sc.hrc"
      50                 :            : #include "viewutil.hxx"
      51                 :            : #include "colrowba.hxx"
      52                 :            : #include "waitoff.hxx"
      53                 :            : #include "globstr.hrc"
      54                 :            : #include "scmod.hxx"
      55                 :            : #include "tabprotection.hxx"
      56                 :            : #include "markdata.hxx"
      57                 :            : 
      58                 :            : namespace {
      59                 :            : 
      60                 :         20 : bool isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
      61                 :            : {
      62                 :            :     bool bCellProtected = pDoc->HasAttrib(
      63                 :         20 :         nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_PROTECTED);
      64                 :            : 
      65 [ -  + ][ +  - ]:         20 :     if (bCellProtected && !bSelectLocked)
      66                 :          0 :         return false;
      67                 :            : 
      68 [ -  + ][ #  # ]:         20 :     if (!bCellProtected && !bSelectUnlocked)
      69                 :          0 :         return false;
      70                 :            : 
      71                 :         20 :     return true;
      72                 :            : }
      73                 :            : 
      74                 :          4 : void moveCursorByProtRule(
      75                 :            :     SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab, ScDocument* pDoc)
      76                 :            : {
      77                 :          4 :     bool bSelectLocked = true;
      78                 :          4 :     bool bSelectUnlocked = true;
      79                 :          4 :     ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
      80 [ #  # ][ -  + ]:          4 :     if (pTabProtection && pTabProtection->isProtected())
                 [ -  + ]
      81                 :            :     {
      82                 :          0 :         bSelectLocked   = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
      83                 :          0 :         bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
      84                 :            :     }
      85                 :            : 
      86         [ +  + ]:          4 :     if (nMovX > 0)
      87                 :            :     {
      88 [ +  + ][ +  - ]:         12 :         for (SCCOL i = 0; i < nMovX && rCol < MAXCOL; ++i)
                 [ +  + ]
      89                 :            :         {
      90         [ -  + ]:         10 :             if (!isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
      91                 :          0 :                 break;
      92                 :         10 :             ++rCol;
      93                 :            :         }
      94                 :            :     }
      95         [ -  + ]:          2 :     else if (nMovX < 0)
      96                 :            :     {
      97 [ #  # ][ #  # ]:          0 :         for (SCCOL i = 0; i > nMovX && rCol > 0; --i)
                 [ #  # ]
      98                 :            :         {
      99         [ #  # ]:          0 :             if (!isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
     100                 :          0 :                 break;
     101                 :          0 :             --rCol;
     102                 :            :         }
     103                 :            :     }
     104                 :            : 
     105         [ +  + ]:          4 :     if (nMovY > 0)
     106                 :            :     {
     107 [ +  + ][ +  - ]:         12 :         for (SCROW i = 0; i < nMovY && rRow < MAXROW; ++i)
                 [ +  + ]
     108                 :            :         {
     109         [ -  + ]:         10 :             if (!isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
     110                 :          0 :                 break;
     111                 :         10 :             ++rRow;
     112                 :            :         }
     113                 :            :     }
     114         [ -  + ]:          2 :     else if (nMovY < 0)
     115                 :            :     {
     116 [ #  # ][ #  # ]:          0 :         for (SCROW i = 0; i > nMovY && rRow > 0; --i)
                 [ #  # ]
     117                 :            :         {
     118         [ #  # ]:          0 :             if (!isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
     119                 :          0 :                 break;
     120                 :          0 :             --rRow;
     121                 :            :         }
     122                 :            :     }
     123                 :          4 : }
     124                 :            : 
     125                 :          8 : bool checkBoundary(SCCOL& rCol, SCROW& rRow)
     126                 :            : {
     127                 :          8 :     bool bGood = true;
     128         [ -  + ]:          8 :     if (rCol < 0)
     129                 :            :     {
     130                 :          0 :         rCol = 0;
     131                 :          0 :         bGood = false;
     132                 :            :     }
     133         [ -  + ]:          8 :     else if (rCol > MAXCOL)
     134                 :            :     {
     135                 :          0 :         rCol = MAXCOL;
     136                 :          0 :         bGood = false;
     137                 :            :     }
     138                 :            : 
     139         [ -  + ]:          8 :     if (rRow < 0)
     140                 :            :     {
     141                 :          0 :         rRow = 0;
     142                 :          0 :         bGood = false;
     143                 :            :     }
     144         [ -  + ]:          8 :     else if (rRow > MAXROW)
     145                 :            :     {
     146                 :          0 :         rRow = MAXROW;
     147                 :          0 :         bGood = false;
     148                 :            :     }
     149                 :          8 :     return bGood;
     150                 :            : }
     151                 :            : 
     152                 :          4 : void moveCursorByMergedCell(
     153                 :            :     SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab,
     154                 :            :     ScDocument* pDoc, const ScViewData& rViewData)
     155                 :            : {
     156                 :          4 :     SCCOL nOrigX = rViewData.GetCurX();
     157                 :          4 :     SCROW nOrigY = rViewData.GetCurY();
     158                 :            : 
     159                 :          4 :     ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
     160                 :          4 :     bool bSelectLocked = true;
     161                 :          4 :     bool bSelectUnlocked = true;
     162 [ #  # ][ -  + ]:          4 :     if (pTabProtection && pTabProtection->isProtected())
                 [ -  + ]
     163                 :            :     {
     164                 :          0 :         bSelectLocked   = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
     165                 :          0 :         bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
     166                 :            :     }
     167                 :            : 
     168                 :            :     const ScMergeAttr* pMergeAttr = static_cast<const ScMergeAttr*>(
     169                 :          4 :         pDoc->GetAttr(nOrigX, nOrigY, nTab, ATTR_MERGE));
     170                 :            : 
     171                 :          4 :     bool bOriginMerged = false;
     172                 :          4 :     SCsCOL nColSpan = 1;
     173                 :          4 :     SCsROW nRowSpan = 1;
     174 [ -  + ][ -  + ]:          4 :     if (pMergeAttr && pMergeAttr->IsMerged())
                 [ +  - ]
     175                 :            :     {
     176                 :          0 :         nColSpan = pMergeAttr->GetColMerge();
     177                 :          0 :         nRowSpan = pMergeAttr->GetRowMerge();
     178                 :          0 :         bOriginMerged = true;
     179                 :            :     }
     180                 :            : 
     181         [ +  + ]:          4 :     if (nMovX > 0)
     182                 :            :     {
     183                 :          2 :         SCCOL nOld = rCol;
     184         [ -  + ]:          2 :         if (bOriginMerged)
     185                 :            :         {
     186                 :            :             // Original cell is merged.  Push the block end outside the merged region.
     187 [ #  # ][ #  # ]:          0 :             if (nOrigX < MAXCOL && nOrigX < rCol && rCol <= nOrigX + nColSpan - 1)
                 [ #  # ]
     188                 :          0 :                 rCol = nOrigX + nColSpan;
     189                 :            :         }
     190                 :            :         else
     191                 :            :         {
     192                 :          2 :             pDoc->SkipOverlapped(rCol, rRow, nTab);
     193                 :            :         }
     194                 :            : 
     195         [ -  + ]:          2 :         if (nOld < rCol)
     196                 :            :         {
     197                 :            :             // The block end has moved.  Check the protection setting and move back if needed.
     198                 :          0 :             checkBoundary(rCol, rRow);
     199         [ #  # ]:          0 :             if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
     200                 :          0 :                 --rCol;
     201                 :            :         }
     202                 :            :     }
     203         [ -  + ]:          4 :     if (nMovX < 0)
     204                 :            :     {
     205                 :          0 :         SCCOL nOld = rCol;
     206         [ #  # ]:          0 :         if (bOriginMerged)
     207                 :            :         {
     208 [ #  # ][ #  # ]:          0 :             if (nOrigX > 0 && nOrigX <= rCol && rCol < nOrigX + nColSpan - 1)
                 [ #  # ]
     209                 :            :                 // Block end is still within the merged region.  Push it outside.
     210                 :          0 :                 rCol = nOrigX - 1;
     211                 :            :         }
     212                 :            :         else
     213                 :            :         {
     214                 :          0 :             pDoc->SkipOverlapped(rCol, rRow, nTab);
     215                 :            :         }
     216                 :            : 
     217         [ #  # ]:          0 :         if (nOld > rCol)
     218                 :            :         {
     219                 :            :             // The block end has moved.  Check the protection setting and move back if needed.
     220                 :          0 :             checkBoundary(rCol, rRow);
     221         [ #  # ]:          0 :             if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
     222                 :          0 :                 ++rCol;
     223                 :            :         }
     224                 :            :     }
     225         [ +  + ]:          4 :     if (nMovY > 0)
     226                 :            :     {
     227                 :          2 :         SCROW nOld = rRow;
     228         [ -  + ]:          2 :         if (bOriginMerged)
     229                 :            :         {
     230                 :            :             // Original cell is merged.  Push the block end outside the merged region.
     231 [ #  # ][ #  # ]:          0 :             if (nOrigY < MAXROW && nOrigY < rRow && rRow <= nOrigY + nRowSpan - 1)
                 [ #  # ]
     232                 :          0 :                 rRow = nOrigY + nRowSpan;
     233                 :            :         }
     234                 :            :         else
     235                 :            :         {
     236                 :          2 :             pDoc->SkipOverlapped(rCol, rRow, nTab);
     237                 :            :         }
     238                 :            : 
     239         [ -  + ]:          2 :         if (nOld < rRow)
     240                 :            :         {
     241                 :            :             // The block end has moved.  Check the protection setting and move back if needed.
     242                 :          0 :             checkBoundary(rCol, rRow);
     243         [ #  # ]:          0 :             if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
     244                 :          0 :                 --rRow;
     245                 :            :         }
     246                 :            :     }
     247         [ -  + ]:          4 :     if (nMovY < 0)
     248                 :            :     {
     249                 :          0 :         SCROW nOld = rRow;
     250         [ #  # ]:          0 :         if (bOriginMerged)
     251                 :            :         {
     252 [ #  # ][ #  # ]:          0 :             if (nOrigY > 0 && nOrigY <= rRow && rRow < nOrigY + nRowSpan - 1)
                 [ #  # ]
     253                 :            :                 // Block end is still within the merged region.  Push it outside.
     254                 :          0 :                 rRow = nOrigY - 1;
     255                 :            :         }
     256                 :            :         else
     257                 :            :         {
     258                 :          0 :             pDoc->SkipOverlapped(rCol, rRow, nTab);
     259                 :            :         }
     260                 :            : 
     261         [ #  # ]:          0 :         if (nOld > rRow)
     262                 :            :         {
     263                 :            :             // The block end has moved.  Check the protection setting and move back if needed.
     264                 :          0 :             checkBoundary(rCol, rRow);
     265         [ #  # ]:          0 :             if (!isCellQualified(pDoc, rCol, rRow, nTab, bSelectLocked, bSelectUnlocked))
     266                 :          0 :                 ++rRow;
     267                 :            :         }
     268                 :            :     }
     269                 :          4 : }
     270                 :            : 
     271                 :            : }
     272                 :            : 
     273                 :          2 : void ScTabView::PaintMarks(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
     274                 :            : {
     275         [ -  + ]:          2 :     if (!ValidCol(nStartCol)) nStartCol = MAXCOL;
     276         [ -  + ]:          2 :     if (!ValidRow(nStartRow)) nStartRow = MAXROW;
     277         [ -  + ]:          2 :     if (!ValidCol(nEndCol)) nEndCol = MAXCOL;
     278         [ -  + ]:          2 :     if (!ValidRow(nEndRow)) nEndRow = MAXROW;
     279                 :            : 
     280 [ +  - ][ -  + ]:          2 :     bool bLeft = (nStartCol==0 && nEndCol==MAXCOL);
     281 [ +  - ][ -  + ]:          2 :     bool bTop = (nStartRow==0 && nEndRow==MAXROW);
     282                 :            : 
     283         [ -  + ]:          2 :     if (bLeft)
     284                 :          0 :         PaintLeftArea( nStartRow, nEndRow );
     285         [ -  + ]:          2 :     if (bTop)
     286                 :          0 :         PaintTopArea( nStartCol, nEndCol );
     287                 :            : 
     288                 :            :     aViewData.GetDocument()->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow,
     289                 :          2 :                                             aViewData.GetTabNo() );
     290                 :          2 :     PaintArea( nStartCol, nStartRow, nEndCol, nEndRow, SC_UPDATE_MARKS );
     291                 :          2 : }
     292                 :            : 
     293                 :          0 : bool ScTabView::IsMarking( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
     294                 :            : {
     295                 :          0 :     return IsBlockMode()
     296                 :            :         && nBlockStartX == nCol
     297                 :            :         && nBlockStartY == nRow
     298 [ #  # ][ #  # ]:          0 :         && nBlockStartZ == nTab;
         [ #  # ][ #  # ]
     299                 :            : }
     300                 :            : 
     301                 :         18 : void ScTabView::InitOwnBlockMode()
     302                 :            : {
     303         [ +  - ]:         18 :     if (!IsBlockMode())
     304                 :            :     {
     305                 :            :         //  Wenn keine (alte) Markierung mehr da ist, Anker in SelectionEngine loeschen:
     306                 :            : 
     307                 :         18 :         ScMarkData& rMark = aViewData.GetMarkData();
     308 [ +  - ][ +  - ]:         18 :         if (!rMark.IsMarked() && !rMark.IsMultiMarked())
                 [ +  - ]
     309                 :         18 :             GetSelEngine()->CursorPosChanging( false, false );
     310                 :            : 
     311                 :         18 :         meBlockMode = Own;
     312                 :         18 :         nBlockStartX = 0;
     313                 :         18 :         nBlockStartY = 0;
     314                 :         18 :         nBlockStartZ = 0;
     315                 :         18 :         nBlockEndX = 0;
     316                 :         18 :         nBlockEndY = 0;
     317                 :         18 :         nBlockEndZ = 0;
     318                 :            : 
     319                 :         18 :         SelectionChanged();     // Status wird mit gesetzer Markierung abgefragt
     320                 :            :     }
     321                 :         18 : }
     322                 :            : 
     323                 :          3 : void ScTabView::InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
     324                 :            :                                bool bTestNeg, bool bCols, bool bRows )
     325                 :            : {
     326         [ +  - ]:          3 :     if (!IsBlockMode())
     327                 :            :     {
     328         [ -  + ]:          3 :         if (!ValidCol(nCurX)) nCurX = MAXCOL;
     329         [ -  + ]:          3 :         if (!ValidRow(nCurY)) nCurY = MAXROW;
     330                 :            : 
     331                 :          3 :         ScMarkData& rMark = aViewData.GetMarkData();
     332                 :          3 :         SCTAB nTab = aViewData.GetTabNo();
     333                 :            : 
     334                 :            :         //  Teil von Markierung aufheben?
     335         [ +  + ]:          3 :         if (bTestNeg)
     336                 :            :         {
     337         [ -  + ]:          2 :             if ( bCols )
     338                 :          0 :                 bBlockNeg = rMark.IsColumnMarked( nCurX );
     339         [ -  + ]:          2 :             else if ( bRows )
     340                 :          0 :                 bBlockNeg = rMark.IsRowMarked( nCurY );
     341                 :            :             else
     342                 :          2 :                 bBlockNeg = rMark.IsCellMarked( nCurX, nCurY );
     343                 :            :         }
     344                 :            :         else
     345                 :          1 :             bBlockNeg = false;
     346                 :          3 :         rMark.SetMarkNegative(bBlockNeg);
     347                 :            : 
     348                 :          3 :         meBlockMode = Normal;
     349                 :          3 :         bBlockCols = bCols;
     350                 :          3 :         bBlockRows = bRows;
     351                 :          3 :         nBlockStartX = nBlockStartXOrig = nCurX;
     352                 :          3 :         nBlockStartY = nBlockStartYOrig = nCurY;
     353                 :          3 :         nBlockStartZ = nCurZ;
     354                 :          3 :         nBlockEndX = nOldCurX = nBlockStartX;
     355                 :          3 :         nBlockEndY = nOldCurY = nBlockStartY;
     356                 :          3 :         nBlockEndZ = nBlockStartZ;
     357                 :            : 
     358         [ -  + ]:          3 :         if (bBlockCols)
     359                 :            :         {
     360                 :          0 :             nBlockStartY = nBlockStartYOrig = 0;
     361                 :          0 :             nBlockEndY = MAXROW;
     362                 :            :         }
     363                 :            : 
     364         [ -  + ]:          3 :         if (bBlockRows)
     365                 :            :         {
     366                 :          0 :             nBlockStartX = nBlockStartXOrig = 0;
     367                 :          0 :             nBlockEndX = MAXCOL;
     368                 :            :         }
     369                 :            : 
     370         [ +  - ]:          3 :         rMark.SetMarkArea( ScRange( nBlockStartX,nBlockStartY, nTab, nBlockEndX,nBlockEndY, nTab ) );
     371                 :            : 
     372                 :          3 :         UpdateSelectionOverlay();
     373                 :            :     }
     374                 :          3 : }
     375                 :            : 
     376                 :        342 : void ScTabView::DoneBlockMode( bool bContinue )
     377                 :            : {
     378                 :            :     //  Wenn zwischen Tabellen- und Header SelectionEngine gewechselt wird,
     379                 :            :     //  wird evtl. DeselectAll gerufen, weil die andere Engine keinen Anker hat.
     380                 :            :     //  Mit bMoveIsShift wird verhindert, dass dann die Selektion aufgehoben wird.
     381                 :            : 
     382 [ +  + ][ +  - ]:        342 :     if (IsBlockMode() && !bMoveIsShift)
                 [ +  + ]
     383                 :            :     {
     384                 :         18 :         ScMarkData& rMark = aViewData.GetMarkData();
     385                 :         18 :         bool bFlag = rMark.GetMarkingFlag();
     386                 :         18 :         rMark.SetMarking(false);
     387                 :            : 
     388 [ #  # ][ -  + ]:         18 :         if (bBlockNeg && !bContinue)
     389                 :          0 :             rMark.MarkToMulti();
     390                 :            : 
     391         [ -  + ]:         18 :         if (bContinue)
     392                 :          0 :             rMark.MarkToMulti();
     393                 :            :         else
     394                 :            :         {
     395                 :            :             //  Die Tabelle kann an dieser Stelle ungueltig sein, weil DoneBlockMode
     396                 :            :             //  aus SetTabNo aufgerufen wird
     397                 :            :             //  (z.B. wenn die aktuelle Tabelle von einer anderen View aus geloescht wird)
     398                 :            : 
     399                 :         18 :             SCTAB nTab = aViewData.GetTabNo();
     400                 :         18 :             ScDocument* pDoc = aViewData.GetDocument();
     401         [ +  - ]:         18 :             if ( pDoc->HasTable(nTab) )
     402                 :         18 :                 PaintBlock( true );                             // true -> Block loeschen
     403                 :            :             else
     404                 :          0 :                 rMark.ResetMark();
     405                 :            :         }
     406                 :         18 :         meBlockMode = None;
     407                 :            : 
     408                 :         18 :         rMark.SetMarking(bFlag);
     409                 :         18 :         rMark.SetMarkNegative(false);
     410                 :            :     }
     411                 :        342 : }
     412                 :            : 
     413                 :        372 : bool ScTabView::IsBlockMode() const
     414                 :            : {
     415                 :        372 :     return meBlockMode != None;
     416                 :            : }
     417                 :            : 
     418                 :          5 : void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
     419                 :            :                             bool bCols, bool bRows, bool bCellSelection )
     420                 :            : {
     421         [ -  + ]:          5 :     if (!ValidCol(nCurX)) nCurX = MAXCOL;
     422         [ -  + ]:          5 :     if (!ValidRow(nCurY)) nCurY = MAXROW;
     423                 :            : 
     424         [ -  + ]:          5 :     if (!IsBlockMode())
     425                 :            :     {
     426                 :            :         OSL_FAIL( "MarkCursor nicht im BlockMode" );
     427         [ #  # ]:          0 :         InitBlockMode( nCurX, nCurY, nCurZ, false, bCols, bRows );
     428                 :            :     }
     429                 :            : 
     430         [ -  + ]:          5 :     if (bCols)
     431                 :          0 :         nCurY = MAXROW;
     432         [ -  + ]:          5 :     if (bRows)
     433                 :          0 :         nCurX = MAXCOL;
     434                 :            : 
     435         [ +  - ]:          5 :     ScMarkData& rMark = aViewData.GetMarkData();
     436                 :            :     OSL_ENSURE(rMark.IsMarked() || rMark.IsMultiMarked(), "MarkCursor, !IsMarked()");
     437                 :          5 :     ScRange aMarkRange;
     438         [ +  - ]:          5 :     rMark.GetMarkArea(aMarkRange);
     439 [ -  + ][ #  #  :         10 :     if (( aMarkRange.aStart.Col() != nBlockStartX && aMarkRange.aEnd.Col() != nBlockStartX ) ||
             -  +  #  # ]
         [ -  + ][ -  + ]
     440                 :          5 :         ( aMarkRange.aStart.Row() != nBlockStartY && aMarkRange.aEnd.Row() != nBlockStartY ) ||
     441                 :            :         ( meBlockMode == Own ))
     442                 :            :     {
     443                 :            :         //  Markierung ist veraendert worden
     444                 :            :         //  (z.B. MarkToSimple, wenn per negativ alles bis auf ein Rechteck geloescht wurde)
     445                 :            :         //  oder nach InitOwnBlockMode wird mit Shift-Klick weitermarkiert...
     446                 :            : 
     447                 :          0 :         bool bOldShift = bMoveIsShift;
     448                 :          0 :         bMoveIsShift = false;               //  wirklich umsetzen
     449         [ #  # ]:          0 :         DoneBlockMode(false);               //! direkt Variablen setzen? (-> kein Geflacker)
     450                 :          0 :         bMoveIsShift = bOldShift;
     451                 :            : 
     452                 :          0 :         InitBlockMode( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
     453         [ #  # ]:          0 :                         nBlockStartZ, rMark.IsMarkNegative(), bCols, bRows );
     454                 :            :     }
     455                 :            : 
     456 [ +  + ][ +  + ]:          5 :     if ( nCurX != nOldCurX || nCurY != nOldCurY )
     457                 :            :     {
     458                 :            :         // Current cursor has moved
     459                 :            : 
     460                 :          4 :         SCTAB nTab = nCurZ;
     461                 :            : 
     462         [ +  - ]:          4 :         if ( bCellSelection )
     463                 :            :         {
     464                 :            :             // Expand selection area accordingly when the current selection ends
     465                 :            :             // with a merged cell.
     466                 :          4 :             SCsCOL nCurXOffset = 0;
     467                 :          4 :             SCsCOL nBlockStartXOffset = 0;
     468                 :          4 :             SCsROW nCurYOffset = 0;
     469                 :          4 :             SCsROW nBlockStartYOffset = 0;
     470                 :          4 :             bool bBlockStartMerged = false;
     471                 :          4 :             const ScMergeAttr* pMergeAttr = NULL;
     472         [ +  - ]:          4 :             ScDocument* pDocument = aViewData.GetDocument();
     473                 :            : 
     474                 :            :             // The following block checks whether or not the "BlockStart" (anchor)
     475                 :            :             // cell is merged.  If it's merged, it'll then move the position of the
     476                 :            :             // anchor cell to the corner that's diagonally opposite of the
     477                 :            :             // direction of a current selection area.  For instance, if a current
     478                 :            :             // selection is moving in the upperleft direction, the anchor cell will
     479                 :            :             // move to the lower-right corner of the merged anchor cell, and so on.
     480                 :            : 
     481                 :            :             pMergeAttr = static_cast<const ScMergeAttr*>(
     482         [ +  - ]:          4 :                 pDocument->GetAttr( nBlockStartXOrig, nBlockStartYOrig, nTab, ATTR_MERGE ) );
     483         [ -  + ]:          4 :             if ( pMergeAttr->IsMerged() )
     484                 :            :             {
     485                 :          0 :                 SCsCOL nColSpan = pMergeAttr->GetColMerge();
     486                 :          0 :                 SCsROW nRowSpan = pMergeAttr->GetRowMerge();
     487                 :            : 
     488 [ #  # ][ #  # ]:          0 :                 if ( !( nCurX >= nBlockStartXOrig + nColSpan - 1 && nCurY >= nBlockStartYOrig + nRowSpan - 1 ) )
     489                 :            :                 {
     490         [ #  # ]:          0 :                     nBlockStartX = nCurX >= nBlockStartXOrig ? nBlockStartXOrig : nBlockStartXOrig + nColSpan - 1;
     491         [ #  # ]:          0 :                     nBlockStartY = nCurY >= nBlockStartYOrig ? nBlockStartYOrig : nBlockStartYOrig + nRowSpan - 1;
     492                 :            :                     nCurXOffset  = (nCurX >= nBlockStartXOrig && nCurX < nBlockStartXOrig + nColSpan - 1) ?
     493 [ #  # ][ #  # ]:          0 :                         nBlockStartXOrig - nCurX + nColSpan - 1 : 0;
     494                 :            :                     nCurYOffset  = (nCurY >= nBlockStartYOrig && nCurY < nBlockStartYOrig + nRowSpan - 1) ?
     495 [ #  # ][ #  # ]:          0 :                         nBlockStartYOrig - nCurY + nRowSpan - 1 : 0;
     496                 :          0 :                     bBlockStartMerged = sal_True;
     497                 :            :                 }
     498                 :            :             }
     499                 :            : 
     500                 :            :             // The following block checks whether or not the current cell is
     501                 :            :             // merged.  If it is, it'll then set the appropriate X & Y offset
     502                 :            :             // values (nCurXOffset & nCurYOffset) such that the selection area will
     503                 :            :             // grow by those specified offset amounts.  Note that the values of
     504                 :            :             // nCurXOffset/nCurYOffset may also be specified in the previous code
     505                 :            :             // block, in which case whichever value is greater will take on.
     506                 :            : 
     507                 :            :             pMergeAttr = static_cast<const ScMergeAttr*>(
     508         [ +  - ]:          4 :                 pDocument->GetAttr( nCurX, nCurY, nTab, ATTR_MERGE ) );
     509         [ -  + ]:          4 :             if ( pMergeAttr->IsMerged() )
     510                 :            :             {
     511                 :          0 :                 SCsCOL nColSpan = pMergeAttr->GetColMerge();
     512                 :          0 :                 SCsROW nRowSpan = pMergeAttr->GetRowMerge();
     513                 :            : 
     514 [ #  # ][ #  # ]:          0 :                 if ( !( nBlockStartX >= nCurX + nColSpan - 1 && nBlockStartY >= nCurY + nRowSpan - 1 ) )
     515                 :            :                 {
     516         [ #  # ]:          0 :                     if ( nBlockStartX <= nCurX + nColSpan - 1 )
     517                 :            :                     {
     518         [ #  # ]:          0 :                         SCsCOL nCurXOffsetTemp = (nCurX < nCurX + nColSpan - 1) ? nColSpan - 1 : 0;
     519         [ #  # ]:          0 :                         nCurXOffset = nCurXOffset > nCurXOffsetTemp ? nCurXOffset : nCurXOffsetTemp;
     520                 :            :                     }
     521         [ #  # ]:          0 :                     if ( nBlockStartY <= nCurY + nRowSpan - 1 )
     522                 :            :                     {
     523         [ #  # ]:          0 :                         SCsROW nCurYOffsetTemp = (nCurY < nCurY + nRowSpan - 1) ? nRowSpan - 1 : 0;
     524         [ #  # ]:          0 :                         nCurYOffset = nCurYOffset > nCurYOffsetTemp ? nCurYOffset : nCurYOffsetTemp;
     525                 :            :                     }
     526 [ #  # ][ #  # ]:          0 :                     if ( !( nBlockStartX <= nCurX && nBlockStartY <= nCurY ) &&
                 [ #  # ]
     527         [ #  # ]:          0 :                          !( nBlockStartX > nCurX + nColSpan - 1 && nBlockStartY > nCurY + nRowSpan - 1 ) )
     528                 :            :                     {
     529 [ #  # ][ #  # ]:          0 :                         nBlockStartXOffset = (nBlockStartX > nCurX && nBlockStartX <= nCurX + nColSpan - 1) ? nCurX - nBlockStartX : 0;
     530 [ #  # ][ #  # ]:          0 :                         nBlockStartYOffset = (nBlockStartY > nCurY && nBlockStartY <= nCurY + nRowSpan - 1) ? nCurY - nBlockStartY : 0;
     531                 :            :                     }
     532                 :            :                 }
     533                 :            :             }
     534                 :            :             else
     535                 :            :             {
     536                 :            :                 // The current cell is not merged.  Move the anchor cell to its
     537                 :            :                 // original position.
     538         [ +  - ]:          4 :                 if ( !bBlockStartMerged )
     539                 :            :                 {
     540                 :          4 :                     nBlockStartX = nBlockStartXOrig;
     541                 :          4 :                     nBlockStartY = nBlockStartYOrig;
     542                 :            :                 }
     543                 :            :             }
     544                 :            : 
     545                 :          4 :             nBlockStartX = nBlockStartX + nBlockStartXOffset >= 0 ? nBlockStartX + nBlockStartXOffset : 0;
     546                 :          4 :             nBlockStartY = nBlockStartY + nBlockStartYOffset >= 0 ? nBlockStartY + nBlockStartYOffset : 0;
     547                 :          4 :             nBlockEndX = nCurX + nCurXOffset > MAXCOL ? MAXCOL : nCurX + nCurXOffset;
     548                 :          4 :             nBlockEndY = nCurY + nCurYOffset > MAXROW ? MAXROW : nCurY + nCurYOffset;
     549                 :            :         }
     550                 :            :         else
     551                 :            :         {
     552                 :          0 :             nBlockEndX = nCurX;
     553                 :          0 :             nBlockEndY = nCurY;
     554                 :            :         }
     555                 :            : 
     556                 :            :         // Set new selection area
     557         [ +  - ]:          4 :         rMark.SetMarkArea( ScRange( nBlockStartX, nBlockStartY, nTab, nBlockEndX, nBlockEndY, nTab ) );
     558                 :            : 
     559         [ +  - ]:          4 :         UpdateSelectionOverlay();
     560         [ +  - ]:          4 :         SelectionChanged();
     561                 :            : 
     562                 :          4 :         nOldCurX = nCurX;
     563                 :          4 :         nOldCurY = nCurY;
     564                 :            : 
     565         [ +  - ]:          4 :         aViewData.GetViewShell()->UpdateInputHandler();
     566                 :            :     }
     567                 :            : 
     568 [ +  - ][ +  - ]:          5 :     if ( !bCols && !bRows )
     569                 :          5 :         aHdrFunc.SetAnchorFlag( false );
     570                 :          5 : }
     571                 :            : 
     572                 :          0 : void ScTabView::GetPageMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, SCsCOL& rPageX, SCsROW& rPageY)
     573                 :            : {
     574                 :            :     SCCOL nCurX;
     575                 :            :     SCROW nCurY;
     576         [ #  # ]:          0 :     if (aViewData.IsRefMode())
     577                 :            :     {
     578                 :          0 :         nCurX = aViewData.GetRefEndX();
     579                 :          0 :         nCurY = aViewData.GetRefEndY();
     580                 :            :     }
     581         [ #  # ]:          0 :     else if (IsBlockMode())
     582                 :            :     {
     583                 :            :         // block end position.
     584                 :          0 :         nCurX = nBlockEndX;
     585                 :          0 :         nCurY = nBlockEndY;
     586                 :            :     }
     587                 :            :     else
     588                 :            :     {
     589                 :            :         // cursor position
     590                 :          0 :         nCurX = aViewData.GetCurX();
     591                 :          0 :         nCurY = aViewData.GetCurY();
     592                 :            :     }
     593                 :            : 
     594                 :          0 :     ScSplitPos eWhich = aViewData.GetActivePart();
     595                 :          0 :     ScHSplitPos eWhichX = WhichH( eWhich );
     596                 :          0 :     ScVSplitPos eWhichY = WhichV( eWhich );
     597                 :            : 
     598                 :            :     SCsCOL nPageX;
     599                 :            :     SCsROW nPageY;
     600         [ #  # ]:          0 :     if (nMovX >= 0)
     601                 :          0 :         nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, 1, eWhichX )) * nMovX;
     602                 :            :     else
     603                 :          0 :         nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, -1, eWhichX )) * nMovX;
     604                 :            : 
     605         [ #  # ]:          0 :     if (nMovY >= 0)
     606                 :          0 :         nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, 1, eWhichY )) * nMovY;
     607                 :            :     else
     608                 :          0 :         nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, -1, eWhichY )) * nMovY;
     609                 :            : 
     610 [ #  # ][ #  # ]:          0 :     if (nMovX != 0 && nPageX == 0) nPageX = (nMovX>0) ? 1 : -1;
                 [ #  # ]
     611 [ #  # ][ #  # ]:          0 :     if (nMovY != 0 && nPageY == 0) nPageY = (nMovY>0) ? 1 : -1;
                 [ #  # ]
     612                 :            : 
     613                 :          0 :     rPageX = nPageX;
     614                 :          0 :     rPageY = nPageY;
     615                 :          0 : }
     616                 :            : 
     617                 :          0 : void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
     618                 :            :                                        SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode)
     619                 :            : {
     620                 :          0 :     SCCOL nNewX = -1;
     621                 :          0 :     SCROW nNewY = -1;
     622                 :            :     // current cursor position.
     623                 :          0 :     SCCOL nCurX = aViewData.GetCurX();
     624                 :          0 :     SCROW nCurY = aViewData.GetCurY();
     625                 :            : 
     626         [ #  # ]:          0 :     if (aViewData.IsRefMode())
     627                 :            :     {
     628                 :          0 :         nNewX = aViewData.GetRefEndX();
     629                 :          0 :         nNewY = aViewData.GetRefEndY();
     630                 :          0 :         nCurX = aViewData.GetRefStartX();
     631                 :          0 :         nCurY = aViewData.GetRefStartY();
     632                 :            :     }
     633         [ #  # ]:          0 :     else if (IsBlockMode())
     634                 :            :     {
     635                 :            :         // block end position.
     636                 :          0 :         nNewX = nBlockEndX;
     637                 :          0 :         nNewY = nBlockEndY;
     638                 :            :     }
     639                 :            :     else
     640                 :            :     {
     641                 :          0 :         nNewX = nCurX;
     642                 :          0 :         nNewY = nCurY;
     643                 :            :     }
     644                 :            : 
     645         [ #  # ]:          0 :     ScDocument* pDoc = aViewData.GetDocument();
     646                 :          0 :     SCTAB nTab = aViewData.GetTabNo();
     647                 :            : 
     648                 :            :     //  FindAreaPos kennt nur -1 oder 1 als Richtung
     649                 :            : 
     650                 :            :     SCsCOLROW i;
     651         [ #  # ]:          0 :     if ( nMovX > 0 )
     652         [ #  # ]:          0 :         for ( i=0; i<nMovX; i++ )
     653         [ #  # ]:          0 :             pDoc->FindAreaPos( nNewX, nCurY, nTab,  SC_MOVE_RIGHT );
     654         [ #  # ]:          0 :     if ( nMovX < 0 )
     655         [ #  # ]:          0 :         for ( i=0; i<-nMovX; i++ )
     656         [ #  # ]:          0 :             pDoc->FindAreaPos( nNewX, nCurY, nTab, SC_MOVE_LEFT );
     657         [ #  # ]:          0 :     if ( nMovY > 0 )
     658         [ #  # ]:          0 :         for ( i=0; i<nMovY; i++ )
     659         [ #  # ]:          0 :             pDoc->FindAreaPos( nCurX, nNewY, nTab,  SC_MOVE_DOWN );
     660         [ #  # ]:          0 :     if ( nMovY < 0 )
     661         [ #  # ]:          0 :         for ( i=0; i<-nMovY; i++ )
     662         [ #  # ]:          0 :             pDoc->FindAreaPos( nCurX, nNewY, nTab,  SC_MOVE_UP );
     663                 :            : 
     664         [ #  # ]:          0 :     if (eMode==SC_FOLLOW_JUMP)                  // unten/rechts nicht zuviel grau anzeigen
     665                 :            :     {
     666 [ #  # ][ #  # ]:          0 :         if (nMovX != 0 && nNewX == MAXCOL)
     667                 :          0 :             eMode = SC_FOLLOW_LINE;
     668 [ #  # ][ #  # ]:          0 :         if (nMovY != 0 && nNewY == MAXROW)
     669                 :          0 :             eMode = SC_FOLLOW_LINE;
     670                 :            :     }
     671                 :            : 
     672         [ #  # ]:          0 :     if (aViewData.IsRefMode())
     673                 :            :     {
     674                 :          0 :         rAreaX = nNewX - aViewData.GetRefEndX();
     675                 :          0 :         rAreaY = nNewY - aViewData.GetRefEndY();
     676                 :            :     }
     677         [ #  # ]:          0 :     else if (IsBlockMode())
     678                 :            :     {
     679                 :          0 :         rAreaX = nNewX - nBlockEndX;
     680                 :          0 :         rAreaY = nNewY - nBlockEndY;
     681                 :            :     }
     682                 :            :     else
     683                 :            :     {
     684                 :          0 :         rAreaX = nNewX - nCurX;
     685                 :          0 :         rAreaY = nNewY - nCurY;
     686                 :            :     }
     687                 :          0 :     rMode = eMode;
     688                 :          0 : }
     689                 :            : 
     690                 :          0 : void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX)
     691                 :            : {
     692                 :          0 :     ScDocument* pDoc = aViewData.GetDocument();
     693                 :          0 :     SCTAB nTab = aViewData.GetTabNo();
     694                 :            : 
     695                 :          0 :     bool bSkipProtected = false, bSkipUnprotected = false;
     696                 :          0 :     ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
     697 [ #  # ][ #  # ]:          0 :     if (pProtect && pProtect->isProtected())
                 [ #  # ]
     698                 :            :     {
     699                 :          0 :         bSkipProtected   = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
     700                 :          0 :         bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
     701                 :            :     }
     702                 :            : 
     703                 :          0 :     bool bSkipCell = false;
     704                 :          0 :     bool bHFlip = false;
     705         [ #  # ]:          0 :     do
     706                 :            :     {
     707 [ #  # ][ #  # ]:          0 :         bSkipCell = pDoc->ColHidden(rCurX, nTab) || pDoc->IsHorOverlapped(rCurX, rCurY, nTab);
     708 [ #  # ][ #  # ]:          0 :         if (bSkipProtected && !bSkipCell)
     709                 :          0 :             bSkipCell = pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
     710 [ #  # ][ #  # ]:          0 :         if (bSkipUnprotected && !bSkipCell)
     711                 :          0 :             bSkipCell = !pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
     712                 :            : 
     713         [ #  # ]:          0 :         if (bSkipCell)
     714                 :            :         {
     715 [ #  # ][ #  # ]:          0 :             if (rCurX <= 0 || rCurX >= MAXCOL)
     716                 :            :             {
     717         [ #  # ]:          0 :                 if (bHFlip)
     718                 :            :                 {
     719                 :          0 :                     rCurX = nOldX;
     720                 :          0 :                     bSkipCell = false;
     721                 :            :                 }
     722                 :            :                 else
     723                 :            :                 {
     724                 :          0 :                     nMovX = -nMovX;
     725         [ #  # ]:          0 :                     if (nMovX > 0)
     726                 :          0 :                         ++rCurX;
     727                 :            :                     else
     728                 :          0 :                         --rCurX;
     729                 :          0 :                     bHFlip = true;
     730                 :            :                 }
     731                 :            :             }
     732                 :            :             else
     733         [ #  # ]:          0 :                 if (nMovX > 0)
     734                 :          0 :                     ++rCurX;
     735                 :            :                 else
     736                 :          0 :                     --rCurX;
     737                 :            :         }
     738                 :            :     }
     739                 :            :     while (bSkipCell);
     740                 :            : 
     741         [ #  # ]:          0 :     if (pDoc->IsVerOverlapped(rCurX, rCurY, nTab))
     742                 :            :     {
     743                 :          0 :         aViewData.SetOldCursor(rCurX, rCurY);
     744         [ #  # ]:          0 :         while (pDoc->IsVerOverlapped(rCurX, rCurY, nTab))
     745                 :          0 :             --rCurY;
     746                 :            :     }
     747                 :          0 : }
     748                 :            : 
     749                 :          0 : void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY)
     750                 :            : {
     751                 :          0 :     ScDocument* pDoc = aViewData.GetDocument();
     752                 :          0 :     SCTAB nTab = aViewData.GetTabNo();
     753                 :            : 
     754                 :          0 :     bool bSkipProtected = false, bSkipUnprotected = false;
     755                 :          0 :     ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
     756 [ #  # ][ #  # ]:          0 :     if (pProtect && pProtect->isProtected())
                 [ #  # ]
     757                 :            :     {
     758                 :          0 :         bSkipProtected   = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
     759                 :          0 :         bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
     760                 :            :     }
     761                 :            : 
     762                 :          0 :     bool bSkipCell = false;
     763                 :          0 :     bool bVFlip = false;
     764         [ #  # ]:          0 :     do
     765                 :            :     {
     766                 :          0 :         SCROW nLastRow = -1;
     767 [ #  # ][ #  # ]:          0 :         bSkipCell = pDoc->RowHidden(rCurY, nTab, NULL, &nLastRow) || pDoc->IsVerOverlapped( rCurX, rCurY, nTab );
         [ #  # ][ #  # ]
     768 [ #  # ][ #  # ]:          0 :         if (bSkipProtected && !bSkipCell)
     769         [ #  # ]:          0 :             bSkipCell = pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
     770 [ #  # ][ #  # ]:          0 :         if (bSkipUnprotected && !bSkipCell)
     771         [ #  # ]:          0 :             bSkipCell = !pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
     772                 :            : 
     773         [ #  # ]:          0 :         if (bSkipCell)
     774                 :            :         {
     775 [ #  # ][ #  # ]:          0 :             if (rCurY <= 0 || rCurY >= MAXROW)
     776                 :            :             {
     777         [ #  # ]:          0 :                 if (bVFlip)
     778                 :            :                 {
     779                 :          0 :                     rCurY = nOldY;
     780                 :          0 :                     bSkipCell = false;
     781                 :            :                 }
     782                 :            :                 else
     783                 :            :                 {
     784                 :          0 :                     nMovY = -nMovY;
     785         [ #  # ]:          0 :                     if (nMovY > 0)
     786                 :          0 :                         ++rCurY;
     787                 :            :                     else
     788                 :          0 :                         --rCurY;
     789                 :          0 :                     bVFlip = true;
     790                 :            :                 }
     791                 :            :             }
     792                 :            :             else
     793         [ #  # ]:          0 :                 if (nMovY > 0)
     794                 :          0 :                     ++rCurY;
     795                 :            :                 else
     796                 :          0 :                     --rCurY;
     797                 :            :         }
     798                 :            :     }
     799                 :            :     while (bSkipCell);
     800                 :            : 
     801         [ #  # ]:          0 :     if (pDoc->IsHorOverlapped(rCurX, rCurY, nTab))
     802                 :            :     {
     803                 :          0 :         aViewData.SetOldCursor(rCurX, rCurY);
     804         [ #  # ]:          0 :         while (pDoc->IsHorOverlapped(rCurX, rCurY, nTab))
     805                 :          0 :             --rCurX;
     806                 :            :     }
     807                 :          0 : }
     808                 :            : 
     809                 :          4 : void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
     810                 :            : {
     811 [ +  + ][ -  + ]:          4 :     if (!nMovX && !nMovY)
     812                 :            :         // Nothing to do.  Bail out.
     813                 :          4 :         return;
     814                 :            : 
     815                 :          4 :     ScTabViewShell* pViewShell = aViewData.GetViewShell();
     816 [ -  + ][ +  - ]:          4 :     bool bRefInputMode = pViewShell && pViewShell->IsRefInputMode();
     817 [ -  + ][ #  # ]:          4 :     if (bRefInputMode && !aViewData.IsRefMode())
                 [ -  + ]
     818                 :            :         // initialize formula reference mode if it hasn't already.
     819                 :          0 :         InitRefMode(aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo(), SC_REFTYPE_REF);
     820                 :            : 
     821                 :          4 :     ScDocument* pDoc = aViewData.GetDocument();
     822                 :            : 
     823         [ -  + ]:          4 :     if (aViewData.IsRefMode())
     824                 :            :     {
     825                 :            :         // formula reference mode
     826                 :            : 
     827                 :          0 :         SCCOL nNewX = aViewData.GetRefEndX();
     828                 :          0 :         SCROW nNewY = aViewData.GetRefEndY();
     829                 :          0 :         SCTAB nRefTab = aViewData.GetRefEndZ();
     830                 :            : 
     831                 :          0 :         bool bSelectLocked = true;
     832                 :          0 :         bool bSelectUnlocked = true;
     833         [ #  # ]:          0 :         ScTableProtection* pTabProtection = pDoc->GetTabProtection(nRefTab);
     834 [ #  # ][ #  # ]:          0 :         if (pTabProtection && pTabProtection->isProtected())
         [ #  # ][ #  # ]
     835                 :            :         {
     836         [ #  # ]:          0 :             bSelectLocked   = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
     837         [ #  # ]:          0 :             bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
     838                 :            :         }
     839                 :            : 
     840         [ #  # ]:          0 :         moveCursorByProtRule(nNewX, nNewY, nMovX, nMovY, nRefTab, pDoc);
     841                 :          0 :         checkBoundary(nNewX, nNewY);
     842                 :            : 
     843         [ #  # ]:          0 :         if (nMovX)
     844                 :            :         {
     845                 :          0 :             SCCOL nTempX = nNewX;
     846 [ #  # ][ #  # ]:          0 :             while (pDoc->IsHorOverlapped(nTempX, nNewY, nRefTab))
     847                 :            :             {
     848         [ #  # ]:          0 :                 if (nMovX > 0)
     849                 :          0 :                     ++nTempX;
     850                 :            :                 else
     851                 :          0 :                     --nTempX;
     852         [ #  # ]:          0 :                 if (!checkBoundary(nTempX, nNewY))
     853                 :          0 :                     break;
     854                 :            :             }
     855 [ #  # ][ #  # ]:          0 :             if (isCellQualified(pDoc, nTempX, nNewY, nRefTab, bSelectLocked, bSelectUnlocked))
     856                 :          0 :                 nNewX = nTempX;
     857                 :            :         }
     858                 :            : 
     859         [ #  # ]:          0 :         if (nMovY)
     860                 :            :         {
     861                 :          0 :             SCROW nTempY = nNewY;
     862 [ #  # ][ #  # ]:          0 :             while (pDoc->IsVerOverlapped(nNewX, nTempY, nRefTab))
     863                 :            :             {
     864         [ #  # ]:          0 :                 if (nMovY > 0)
     865                 :          0 :                     ++nTempY;
     866                 :            :                 else
     867                 :          0 :                     --nTempY;
     868         [ #  # ]:          0 :                 if (!checkBoundary(nNewX, nTempY))
     869                 :          0 :                     break;
     870                 :            :             }
     871 [ #  # ][ #  # ]:          0 :             if (isCellQualified(pDoc, nNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked))
     872                 :          0 :                 nNewY = nTempY;
     873                 :            :         }
     874                 :            : 
     875         [ #  # ]:          0 :         pDoc->SkipOverlapped(nNewX, nNewY, nRefTab);
     876         [ #  # ]:          0 :         UpdateRef(nNewX, nNewY, nRefTab);
     877         [ #  # ]:          0 :         AlignToCursor(nNewX, nNewY, eMode);
     878                 :            :     }
     879                 :            :     else
     880                 :            :     {
     881                 :            :         // normal selection mode
     882                 :            : 
     883                 :          4 :         SCTAB nTab = aViewData.GetTabNo();
     884                 :          4 :         SCCOL nOrigX = aViewData.GetCurX();
     885                 :          4 :         SCROW nOrigY = aViewData.GetCurY();
     886                 :            : 
     887                 :            :         // Note that the origin position *never* moves during selection.
     888                 :            : 
     889         [ +  + ]:          4 :         if (!IsBlockMode())
     890                 :          2 :             InitBlockMode(nOrigX, nOrigY, nTab, true);
     891                 :            : 
     892                 :          4 :         moveCursorByProtRule(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc);
     893                 :          4 :         checkBoundary(nBlockEndX, nBlockEndY);
     894                 :          4 :         moveCursorByMergedCell(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc, aViewData);
     895                 :          4 :         checkBoundary(nBlockEndX, nBlockEndY);
     896                 :            : 
     897                 :          4 :         MarkCursor(nBlockEndX, nBlockEndY, nTab, false, false, true);
     898                 :            : 
     899                 :            :         // Check if the entire row(s) or column(s) are selected.
     900                 :          4 :         ScSplitPos eActive = aViewData.GetActivePart();
     901 [ -  + ][ +  - ]:          4 :         bool bRowSelected = (nBlockStartX == 0 && nBlockEndX == MAXCOL);
     902 [ +  - ][ -  + ]:          4 :         bool bColSelected = (nBlockStartY == 0 && nBlockEndY == MAXROW);
     903         [ -  + ]:          4 :         SCsCOL nAlignX = bRowSelected ? aViewData.GetPosX(WhichH(eActive)) : nBlockEndX;
     904         [ -  + ]:          4 :         SCsROW nAlignY = bColSelected ? aViewData.GetPosY(WhichV(eActive)) : nBlockEndY;
     905                 :          4 :         AlignToCursor(nAlignX, nAlignY, eMode);
     906                 :            : 
     907                 :          4 :         SelectionChanged();
     908                 :            :     }
     909                 :            : }
     910                 :            : 
     911                 :          0 : void ScTabView::ExpandBlockPage(SCsCOL nMovX, SCsROW nMovY)
     912                 :            : {
     913                 :            :     SCsCOL nPageX;
     914                 :            :     SCsROW nPageY;
     915         [ #  # ]:          0 :     GetPageMoveEndPosition(nMovX, nMovY, nPageX, nPageY);
     916         [ #  # ]:          0 :     ExpandBlock(nPageX, nPageY, SC_FOLLOW_FIX);
     917                 :          0 : }
     918                 :            : 
     919                 :          0 : void ScTabView::ExpandBlockArea(SCsCOL nMovX, SCsROW nMovY)
     920                 :            : {
     921                 :            :     SCsCOL nAreaX;
     922                 :            :     SCsROW nAreaY;
     923                 :            :     ScFollowMode eMode;
     924         [ #  # ]:          0 :     GetAreaMoveEndPosition(nMovX, nMovY, SC_FOLLOW_JUMP, nAreaX, nAreaY, eMode);
     925         [ #  # ]:          0 :     ExpandBlock(nAreaX, nAreaY, eMode);
     926                 :          0 : }
     927                 :            : 
     928                 :          0 : void ScTabView::UpdateCopySourceOverlay()
     929                 :            : {
     930         [ #  # ]:          0 :     for (sal_uInt8 i = 0; i < 4; ++i)
     931 [ #  # ][ #  # ]:          0 :         if (pGridWin[i] && pGridWin[i]->IsVisible())
                 [ #  # ]
     932                 :          0 :             pGridWin[i]->UpdateCopySourceOverlay();
     933                 :          0 : }
     934                 :            : 
     935                 :         41 : void ScTabView::UpdateSelectionOverlay()
     936                 :            : {
     937         [ +  + ]:        205 :     for (sal_uInt16 i=0; i<4; i++)
     938 [ +  + ][ +  - ]:        164 :         if ( pGridWin[i] && pGridWin[i]->IsVisible() )
                 [ +  + ]
     939                 :         41 :             pGridWin[i]->UpdateSelectionOverlay();
     940                 :         41 : }
     941                 :            : 
     942                 :          0 : void ScTabView::UpdateShrinkOverlay()
     943                 :            : {
     944         [ #  # ]:          0 :     for (sal_uInt16 i=0; i<4; i++)
     945 [ #  # ][ #  # ]:          0 :         if ( pGridWin[i] && pGridWin[i]->IsVisible() )
                 [ #  # ]
     946                 :          0 :             pGridWin[i]->UpdateShrinkOverlay();
     947                 :          0 : }
     948                 :            : 
     949                 :       1215 : void ScTabView::UpdateAllOverlays()
     950                 :            : {
     951         [ +  + ]:       6075 :     for (sal_uInt16 i=0; i<4; i++)
     952 [ +  + ][ +  + ]:       4860 :         if ( pGridWin[i] && pGridWin[i]->IsVisible() )
                 [ +  + ]
     953                 :        986 :             pGridWin[i]->UpdateAllOverlays();
     954                 :       1215 : }
     955                 :            : 
     956                 :            : //!
     957                 :            : //! PaintBlock in zwei Methoden aufteilen: RepaintBlock und RemoveBlock o.ae.
     958                 :            : //!
     959                 :            : 
     960                 :        472 : void ScTabView::PaintBlock( bool bReset )
     961                 :            : {
     962                 :        472 :     ScMarkData& rMark = aViewData.GetMarkData();
     963                 :        472 :     SCTAB nTab = aViewData.GetTabNo();
     964                 :        472 :     bool bMark = rMark.IsMarked();
     965                 :        472 :     bool bMulti = rMark.IsMultiMarked();
     966 [ +  + ][ +  + ]:        472 :     if (bMark || bMulti)
     967                 :            :     {
     968                 :         18 :         ScRange aMarkRange;
     969         [ +  - ]:         18 :         HideAllCursors();
     970         [ +  + ]:         18 :         if (bMulti)
     971                 :            :         {
     972                 :         16 :             bool bFlag = rMark.GetMarkingFlag();
     973                 :         16 :             rMark.SetMarking(false);
     974         [ +  - ]:         16 :             rMark.MarkToMulti();
     975         [ +  - ]:         16 :             rMark.GetMultiMarkArea(aMarkRange);
     976         [ +  - ]:         16 :             rMark.MarkToSimple();
     977                 :         16 :             rMark.SetMarking(bFlag);
     978                 :            : 
     979                 :         16 :             bMark = rMark.IsMarked();
     980                 :            :         }
     981                 :            :         else
     982         [ +  - ]:          2 :             rMark.GetMarkArea(aMarkRange);
     983                 :            : 
     984                 :         18 :         nBlockStartX = aMarkRange.aStart.Col();
     985                 :         18 :         nBlockStartY = aMarkRange.aStart.Row();
     986                 :         18 :         nBlockStartZ = aMarkRange.aStart.Tab();
     987                 :         18 :         nBlockEndX = aMarkRange.aEnd.Col();
     988                 :         18 :         nBlockEndY = aMarkRange.aEnd.Row();
     989                 :         18 :         nBlockEndZ = aMarkRange.aEnd.Tab();
     990                 :            : 
     991                 :         18 :         bool bDidReset = false;
     992                 :            : 
     993 [ +  - ][ +  - ]:         18 :         if ( nTab>=nBlockStartZ && nTab<=nBlockEndZ )
     994                 :            :         {
     995         [ +  + ]:         18 :             if ( bReset )
     996                 :            :             {
     997                 :            :                 // Invertieren beim Loeschen nur auf aktiver View
     998         [ +  - ]:         16 :                 if ( aViewData.IsActive() )
     999                 :            :                 {
    1000         [ +  - ]:         16 :                     rMark.ResetMark();
    1001         [ +  - ]:         16 :                     UpdateSelectionOverlay();
    1002                 :         16 :                     bDidReset = true;
    1003                 :            :                 }
    1004                 :            :             }
    1005                 :            :             else
    1006         [ +  - ]:          2 :                 PaintMarks( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY );
    1007                 :            :         }
    1008                 :            : 
    1009 [ +  + ][ -  + ]:         18 :         if ( bReset && !bDidReset )
    1010         [ #  # ]:          0 :             rMark.ResetMark();
    1011                 :            : 
    1012         [ +  - ]:         18 :         ShowAllCursors();
    1013                 :            :     }
    1014                 :        472 : }
    1015                 :            : 
    1016                 :          0 : void ScTabView::SelectAll( bool bContinue )
    1017                 :            : {
    1018                 :          0 :     ScMarkData& rMark = aViewData.GetMarkData();
    1019                 :          0 :     SCTAB nTab = aViewData.GetTabNo();
    1020                 :            : 
    1021         [ #  # ]:          0 :     if (rMark.IsMarked())
    1022                 :            :     {
    1023                 :          0 :         ScRange aMarkRange;
    1024         [ #  # ]:          0 :         rMark.GetMarkArea( aMarkRange );
    1025         [ #  # ]:          0 :         if ( aMarkRange == ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) )
    1026                 :          0 :             return;
    1027                 :            :     }
    1028                 :            : 
    1029                 :          0 :     DoneBlockMode( bContinue );
    1030                 :          0 :     InitBlockMode( 0,0,nTab );
    1031                 :          0 :     MarkCursor( MAXCOL,MAXROW,nTab );
    1032                 :            : 
    1033                 :          0 :     SelectionChanged();
    1034                 :            : }
    1035                 :            : 
    1036                 :          0 : void ScTabView::SelectAllTables()
    1037                 :            : {
    1038                 :          0 :     ScDocument* pDoc = aViewData.GetDocument();
    1039                 :          0 :     ScMarkData& rMark = aViewData.GetMarkData();
    1040                 :          0 :     SCTAB nCount = pDoc->GetTableCount();
    1041                 :            : 
    1042         [ #  # ]:          0 :     if (nCount>1)
    1043                 :            :     {
    1044         [ #  # ]:          0 :         for (SCTAB i=0; i<nCount; i++)
    1045                 :          0 :             rMark.SelectTable( i, true );
    1046                 :            : 
    1047                 :          0 :         aViewData.GetDocShell()->PostPaintExtras();
    1048                 :          0 :         SfxBindings& rBind = aViewData.GetBindings();
    1049                 :          0 :         rBind.Invalidate( FID_FILL_TAB );
    1050                 :          0 :         rBind.Invalidate( FID_TAB_DESELECTALL );
    1051                 :            :     }
    1052                 :          0 : }
    1053                 :            : 
    1054                 :          0 : void ScTabView::DeselectAllTables()
    1055                 :            : {
    1056                 :          0 :     ScDocument* pDoc = aViewData.GetDocument();
    1057                 :          0 :     ScMarkData& rMark = aViewData.GetMarkData();
    1058                 :          0 :     SCTAB nTab = aViewData.GetTabNo();
    1059                 :          0 :     SCTAB nCount = pDoc->GetTableCount();
    1060                 :            : 
    1061         [ #  # ]:          0 :     for (SCTAB i=0; i<nCount; i++)
    1062                 :          0 :         rMark.SelectTable( i, ( i == nTab ) );
    1063                 :            : 
    1064                 :          0 :     aViewData.GetDocShell()->PostPaintExtras();
    1065                 :          0 :     SfxBindings& rBind = aViewData.GetBindings();
    1066                 :          0 :     rBind.Invalidate( FID_FILL_TAB );
    1067                 :          0 :     rBind.Invalidate( FID_TAB_DESELECTALL );
    1068                 :          0 : }
    1069                 :            : 
    1070                 :          0 : bool lcl_FitsInWindow( double fScaleX, double fScaleY, sal_uInt16 nZoom,
    1071                 :            :                         long nWindowX, long nWindowY, ScDocument* pDoc, SCTAB nTab,
    1072                 :            :                         SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
    1073                 :            :                         SCCOL nFixPosX, SCROW nFixPosY )
    1074                 :            : {
    1075         [ #  # ]:          0 :     double fZoomFactor = (double)Fraction(nZoom,100);
    1076                 :          0 :     fScaleX *= fZoomFactor;
    1077                 :          0 :     fScaleY *= fZoomFactor;
    1078                 :            : 
    1079                 :          0 :     long nBlockX = 0;
    1080                 :            :     SCCOL nCol;
    1081         [ #  # ]:          0 :     for (nCol=0; nCol<nFixPosX; nCol++)
    1082                 :            :     {
    1083                 :            :         //  for frozen panes, add both parts
    1084                 :          0 :         sal_uInt16 nColTwips = pDoc->GetColWidth( nCol, nTab );
    1085         [ #  # ]:          0 :         if (nColTwips)
    1086                 :            :         {
    1087                 :          0 :             nBlockX += (long)(nColTwips * fScaleX);
    1088         [ #  # ]:          0 :             if (nBlockX > nWindowX)
    1089                 :          0 :                 return false;
    1090                 :            :         }
    1091                 :            :     }
    1092         [ #  # ]:          0 :     for (nCol=nStartCol; nCol<=nEndCol; nCol++)
    1093                 :            :     {
    1094                 :          0 :         sal_uInt16 nColTwips = pDoc->GetColWidth( nCol, nTab );
    1095         [ #  # ]:          0 :         if (nColTwips)
    1096                 :            :         {
    1097                 :          0 :             nBlockX += (long)(nColTwips * fScaleX);
    1098         [ #  # ]:          0 :             if (nBlockX > nWindowX)
    1099                 :          0 :                 return false;
    1100                 :            :         }
    1101                 :            :     }
    1102                 :            : 
    1103                 :          0 :     long nBlockY = 0;
    1104         [ #  # ]:          0 :     for (SCROW nRow = 0; nRow <= nFixPosY-1; ++nRow)
    1105                 :            :     {
    1106         [ #  # ]:          0 :         if (pDoc->RowHidden(nRow, nTab))
    1107                 :          0 :             continue;
    1108                 :            : 
    1109                 :            :         //  for frozen panes, add both parts
    1110                 :          0 :         sal_uInt16 nRowTwips = pDoc->GetRowHeight(nRow, nTab);
    1111         [ #  # ]:          0 :         if (nRowTwips)
    1112                 :            :         {
    1113                 :          0 :             nBlockY += (long)(nRowTwips * fScaleY);
    1114         [ #  # ]:          0 :             if (nBlockY > nWindowY)
    1115                 :          0 :                 return false;
    1116                 :            :         }
    1117                 :            :     }
    1118         [ #  # ]:          0 :     for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
    1119                 :            :     {
    1120                 :          0 :         sal_uInt16 nRowTwips = pDoc->GetRowHeight(nRow, nTab);
    1121         [ #  # ]:          0 :         if (nRowTwips)
    1122                 :            :         {
    1123                 :          0 :             nBlockY += (long)(nRowTwips * fScaleY);
    1124         [ #  # ]:          0 :             if (nBlockY > nWindowY)
    1125                 :          0 :                 return false;
    1126                 :            :         }
    1127                 :            :     }
    1128                 :            : 
    1129                 :          0 :     return true;
    1130                 :            : }
    1131                 :            : 
    1132                 :          0 : sal_uInt16 ScTabView::CalcZoom( SvxZoomType eType, sal_uInt16 nOldZoom )
    1133                 :            : {
    1134                 :          0 :     sal_uInt16 nZoom = 0; // Ergebnis
    1135                 :            : 
    1136   [ #  #  #  # ]:          0 :     switch ( eType )
    1137                 :            :     {
    1138                 :            :         case SVX_ZOOM_PERCENT: // rZoom ist kein besonderer prozentualer Wert
    1139                 :          0 :             nZoom = nOldZoom;
    1140                 :          0 :             break;
    1141                 :            : 
    1142                 :            :         case SVX_ZOOM_OPTIMAL:  // nZoom entspricht der optimalen Gr"o\se
    1143                 :            :             {
    1144                 :          0 :                 ScMarkData& rMark = aViewData.GetMarkData();
    1145                 :          0 :                 ScDocument* pDoc = aViewData.GetDocument();
    1146                 :            : 
    1147 [ #  # ][ #  # ]:          0 :                 if (!rMark.IsMarked() && !rMark.IsMultiMarked())
                 [ #  # ]
    1148                 :          0 :                     nZoom = 100;                // nothing selected
    1149                 :            :                 else
    1150                 :            :                 {
    1151                 :          0 :                     SCTAB   nTab = aViewData.GetTabNo();
    1152                 :          0 :                     ScRange aMarkRange;
    1153 [ #  # ][ #  # ]:          0 :                     if ( aViewData.GetSimpleArea( aMarkRange ) != SC_MARK_SIMPLE )
    1154         [ #  # ]:          0 :                         rMark.GetMultiMarkArea( aMarkRange );
    1155                 :            : 
    1156                 :          0 :                     SCCOL   nStartCol = aMarkRange.aStart.Col();
    1157                 :          0 :                     SCROW   nStartRow = aMarkRange.aStart.Row();
    1158                 :          0 :                     SCTAB   nStartTab = aMarkRange.aStart.Tab();
    1159                 :          0 :                     SCCOL   nEndCol = aMarkRange.aEnd.Col();
    1160                 :          0 :                     SCROW   nEndRow = aMarkRange.aEnd.Row();
    1161                 :          0 :                     SCTAB   nEndTab = aMarkRange.aEnd.Tab();
    1162                 :            : 
    1163 [ #  # ][ #  # ]:          0 :                     if ( nTab < nStartTab && nTab > nEndTab )
    1164                 :          0 :                         nTab = nStartTab;
    1165                 :            : 
    1166                 :          0 :                     ScSplitPos eUsedPart = aViewData.GetActivePart();
    1167                 :            : 
    1168                 :          0 :                     SCCOL nFixPosX = 0;
    1169                 :          0 :                     SCROW nFixPosY = 0;
    1170         [ #  # ]:          0 :                     if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
    1171                 :            :                     {
    1172                 :            :                         //  use right part
    1173         [ #  # ]:          0 :                         eUsedPart = (WhichV(eUsedPart)==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT;
    1174                 :          0 :                         nFixPosX = aViewData.GetFixPosX();
    1175         [ #  # ]:          0 :                         if ( nStartCol < nFixPosX )
    1176                 :          0 :                             nStartCol = nFixPosX;
    1177                 :            :                     }
    1178         [ #  # ]:          0 :                     if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
    1179                 :            :                     {
    1180                 :            :                         //  use bottom part
    1181         [ #  # ]:          0 :                         eUsedPart = (WhichH(eUsedPart)==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
    1182                 :          0 :                         nFixPosY = aViewData.GetFixPosY();
    1183         [ #  # ]:          0 :                         if ( nStartRow < nFixPosY )
    1184                 :          0 :                             nStartRow = nFixPosY;
    1185                 :            :                     }
    1186                 :            : 
    1187         [ #  # ]:          0 :                     if (pGridWin[eUsedPart])
    1188                 :            :                     {
    1189                 :            :                         //  Because scale is rounded to pixels, the only reliable way to find
    1190                 :            :                         //  the right scale is to check if a zoom fits
    1191                 :            : 
    1192                 :          0 :                         Size aWinSize = pGridWin[eUsedPart]->GetOutputSizePixel();
    1193                 :            : 
    1194                 :            :                         //  for frozen panes, use sum of both parts for calculation
    1195                 :            : 
    1196         [ #  # ]:          0 :                         if ( nFixPosX != 0 )
    1197         [ #  # ]:          0 :                             aWinSize.Width() += GetGridWidth( SC_SPLIT_LEFT );
    1198         [ #  # ]:          0 :                         if ( nFixPosY != 0 )
    1199         [ #  # ]:          0 :                             aWinSize.Height() += GetGridHeight( SC_SPLIT_TOP );
    1200                 :            : 
    1201                 :          0 :                         ScDocShell* pDocSh = aViewData.GetDocShell();
    1202         [ #  # ]:          0 :                         double nPPTX = ScGlobal::nScreenPPTX / pDocSh->GetOutputFactor();
    1203                 :          0 :                         double nPPTY = ScGlobal::nScreenPPTY;
    1204                 :            : 
    1205                 :          0 :                         sal_uInt16 nMin = MINZOOM;
    1206                 :          0 :                         sal_uInt16 nMax = MAXZOOM;
    1207         [ #  # ]:          0 :                         while ( nMax > nMin )
    1208                 :            :                         {
    1209                 :          0 :                             sal_uInt16 nTest = (nMin+nMax+1)/2;
    1210 [ #  # ][ #  # ]:          0 :                             if ( lcl_FitsInWindow(
    1211                 :          0 :                                         nPPTX, nPPTY, nTest, aWinSize.Width(), aWinSize.Height(),
    1212                 :            :                                         pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow,
    1213                 :          0 :                                         nFixPosX, nFixPosY ) )
    1214                 :          0 :                                 nMin = nTest;
    1215                 :            :                             else
    1216                 :          0 :                                 nMax = nTest-1;
    1217                 :            :                         }
    1218                 :            :                         OSL_ENSURE( nMin == nMax, "Schachtelung ist falsch" );
    1219                 :          0 :                         nZoom = nMin;
    1220                 :            : 
    1221         [ #  # ]:          0 :                         if ( nZoom != nOldZoom )
    1222                 :            :                         {
    1223                 :            :                             // scroll to block only in active split part
    1224                 :            :                             // (the part for which the size was calculated)
    1225                 :            : 
    1226         [ #  # ]:          0 :                             if ( nStartCol <= nEndCol )
    1227         [ #  # ]:          0 :                                 aViewData.SetPosX( WhichH(eUsedPart), nStartCol );
    1228         [ #  # ]:          0 :                             if ( nStartRow <= nEndRow )
    1229         [ #  # ]:          0 :                                 aViewData.SetPosY( WhichV(eUsedPart), nStartRow );
    1230                 :            :                         }
    1231                 :            :                     }
    1232                 :            :                 }
    1233                 :            :             }
    1234                 :          0 :             break;
    1235                 :            : 
    1236                 :            :             case SVX_ZOOM_WHOLEPAGE:    // nZoom entspricht der ganzen Seite oder
    1237                 :            :             case SVX_ZOOM_PAGEWIDTH:    // nZoom entspricht der Seitenbreite
    1238                 :            :                 {
    1239                 :          0 :                     SCTAB               nCurTab     = aViewData.GetTabNo();
    1240                 :          0 :                     ScDocument*         pDoc        = aViewData.GetDocument();
    1241                 :          0 :                     ScStyleSheetPool*   pStylePool  = pDoc->GetStyleSheetPool();
    1242                 :            :                     SfxStyleSheetBase*  pStyleSheet =
    1243                 :            :                                             pStylePool->Find( pDoc->GetPageStyle( nCurTab ),
    1244 [ #  # ][ #  # ]:          0 :                                                               SFX_STYLE_FAMILY_PAGE );
                 [ #  # ]
    1245                 :            : 
    1246                 :            :                     OSL_ENSURE( pStyleSheet, "PageStyle not found :-/" );
    1247                 :            : 
    1248         [ #  # ]:          0 :                     if ( pStyleSheet )
    1249                 :            :                     {
    1250                 :            :                         ScPrintFunc aPrintFunc( aViewData.GetDocShell(),
    1251                 :          0 :                                                 aViewData.GetViewShell()->GetPrinter(true),
    1252 [ #  # ][ #  # ]:          0 :                                                 nCurTab );
    1253                 :            : 
    1254         [ #  # ]:          0 :                         Size aPageSize = aPrintFunc.GetDataSize();
    1255                 :            : 
    1256                 :            :                         //  use the size of the largest GridWin for normal split,
    1257                 :            :                         //  or both combined for frozen panes, with the (document) size
    1258                 :            :                         //  of the frozen part added to the page size
    1259                 :            :                         //  (with frozen panes, the size of the individual parts
    1260                 :            :                         //  depends on the scale that is to be calculated)
    1261                 :            : 
    1262         [ #  # ]:          0 :                         if ( !pGridWin[SC_SPLIT_BOTTOMLEFT] ) return 0;
    1263                 :          0 :                         Size aWinSize = pGridWin[SC_SPLIT_BOTTOMLEFT]->GetOutputSizePixel();
    1264                 :          0 :                         ScSplitMode eHMode = aViewData.GetHSplitMode();
    1265 [ #  # ][ #  # ]:          0 :                         if ( eHMode != SC_SPLIT_NONE && pGridWin[SC_SPLIT_BOTTOMRIGHT] )
    1266                 :            :                         {
    1267                 :          0 :                             long nOtherWidth = pGridWin[SC_SPLIT_BOTTOMRIGHT]->
    1268                 :          0 :                                                         GetOutputSizePixel().Width();
    1269         [ #  # ]:          0 :                             if ( eHMode == SC_SPLIT_FIX )
    1270                 :            :                             {
    1271                 :          0 :                                 aWinSize.Width() += nOtherWidth;
    1272         [ #  # ]:          0 :                                 for ( SCCOL nCol = aViewData.GetPosX(SC_SPLIT_LEFT);
    1273                 :          0 :                                         nCol < aViewData.GetFixPosX(); nCol++ )
    1274         [ #  # ]:          0 :                                     aPageSize.Width() += pDoc->GetColWidth( nCol, nCurTab );
    1275                 :            :                             }
    1276         [ #  # ]:          0 :                             else if ( nOtherWidth > aWinSize.Width() )
    1277                 :          0 :                                 aWinSize.Width() = nOtherWidth;
    1278                 :            :                         }
    1279                 :          0 :                         ScSplitMode eVMode = aViewData.GetVSplitMode();
    1280 [ #  # ][ #  # ]:          0 :                         if ( eVMode != SC_SPLIT_NONE && pGridWin[SC_SPLIT_TOPLEFT] )
    1281                 :            :                         {
    1282                 :          0 :                             long nOtherHeight = pGridWin[SC_SPLIT_TOPLEFT]->
    1283                 :          0 :                                                         GetOutputSizePixel().Height();
    1284         [ #  # ]:          0 :                             if ( eVMode == SC_SPLIT_FIX )
    1285                 :            :                             {
    1286                 :          0 :                                 aWinSize.Height() += nOtherHeight;
    1287                 :          0 :                                 aPageSize.Height() += pDoc->GetRowHeight(
    1288                 :            :                                         aViewData.GetPosY(SC_SPLIT_TOP),
    1289         [ #  # ]:          0 :                                         aViewData.GetFixPosY()-1, nCurTab);
    1290                 :            :                             }
    1291         [ #  # ]:          0 :                             else if ( nOtherHeight > aWinSize.Height() )
    1292                 :          0 :                                 aWinSize.Height() = nOtherHeight;
    1293                 :            :                         }
    1294                 :            : 
    1295         [ #  # ]:          0 :                         double nPPTX = ScGlobal::nScreenPPTX / aViewData.GetDocShell()->GetOutputFactor();
    1296                 :          0 :                         double nPPTY = ScGlobal::nScreenPPTY;
    1297                 :            : 
    1298                 :          0 :                         long nZoomX = (long) ( aWinSize.Width() * 100 /
    1299                 :          0 :                                                ( aPageSize.Width() * nPPTX ) );
    1300                 :          0 :                         long nZoomY = (long) ( aWinSize.Height() * 100 /
    1301                 :          0 :                                                ( aPageSize.Height() * nPPTY ) );
    1302                 :          0 :                         long nNew = nZoomX;
    1303                 :            : 
    1304 [ #  # ][ #  # ]:          0 :                         if (eType == SVX_ZOOM_WHOLEPAGE && nZoomY < nNew)
    1305                 :          0 :                             nNew = nZoomY;
    1306                 :            : 
    1307 [ #  # ][ #  # ]:          0 :                         nZoom = (sal_uInt16) nNew;
    1308                 :            :                     }
    1309                 :            :                 }
    1310                 :          0 :                 break;
    1311                 :            : 
    1312                 :            :         default:
    1313                 :            :             OSL_FAIL("Unknown Zoom-Revision");
    1314                 :          0 :             nZoom = 0;
    1315                 :            :     }
    1316                 :            : 
    1317                 :          0 :     return nZoom;
    1318                 :            : }
    1319                 :            : 
    1320                 :            : //  wird z.B. gerufen, wenn sich das View-Fenster verschiebt:
    1321                 :            : 
    1322                 :        458 : void ScTabView::StopMarking()
    1323                 :            : {
    1324                 :        458 :     ScSplitPos eActive = aViewData.GetActivePart();
    1325         [ +  - ]:        458 :     if (pGridWin[eActive])
    1326                 :        458 :         pGridWin[eActive]->StopMarking();
    1327                 :            : 
    1328                 :        458 :     ScHSplitPos eH = WhichH(eActive);
    1329         [ +  - ]:        458 :     if (pColBar[eH])
    1330                 :        458 :         pColBar[eH]->StopMarking();
    1331                 :            : 
    1332                 :        458 :     ScVSplitPos eV = WhichV(eActive);
    1333         [ +  - ]:        458 :     if (pRowBar[eV])
    1334                 :        458 :         pRowBar[eV]->StopMarking();
    1335                 :        458 : }
    1336                 :            : 
    1337                 :       4433 : void ScTabView::HideNoteMarker()
    1338                 :            : {
    1339         [ +  + ]:      22165 :     for (sal_uInt16 i=0; i<4; i++)
    1340 [ +  + ][ +  + ]:      17732 :         if (pGridWin[i] && pGridWin[i]->IsVisible())
                 [ +  + ]
    1341                 :       4204 :             pGridWin[i]->HideNoteMarker();
    1342                 :       4433 : }
    1343                 :            : 
    1344                 :        229 : void ScTabView::MakeDrawLayer()
    1345                 :            : {
    1346         [ +  + ]:        229 :     if (!pDrawView)
    1347                 :            :     {
    1348                 :        210 :         aViewData.GetDocShell()->MakeDrawLayer();
    1349                 :            : 
    1350                 :            :         //  pDrawView wird per Notify gesetzt
    1351                 :            :         OSL_ENSURE(pDrawView,"ScTabView::MakeDrawLayer funktioniert nicht");
    1352                 :            : 
    1353                 :            :         // #114409#
    1354         [ +  + ]:       1050 :         for(sal_uInt16 a(0); a < 4; a++)
    1355                 :            :         {
    1356         [ +  + ]:        840 :             if(pGridWin[a])
    1357                 :            :             {
    1358                 :        210 :                 pGridWin[a]->DrawLayerCreated();
    1359                 :            :             }
    1360                 :            :         }
    1361                 :            :     }
    1362                 :        229 : }
    1363                 :            : 
    1364                 :          0 : void ScTabView::ErrorMessage( sal_uInt16 nGlobStrId )
    1365                 :            : {
    1366 [ #  # ][ #  # ]:          0 :     if ( SC_MOD()->IsInExecuteDrop() )
    1367                 :            :     {
    1368                 :            :         // #i28468# don't show error message when called from Drag&Drop, silently abort instead
    1369                 :          0 :         return;
    1370                 :            :     }
    1371                 :            : 
    1372         [ #  # ]:          0 :     StopMarking();      // falls per Focus aus MouseButtonDown aufgerufen
    1373                 :            : 
    1374         [ #  # ]:          0 :     Window* pParent = aViewData.GetDialogParent();
    1375         [ #  # ]:          0 :     ScWaitCursorOff aWaitOff( pParent );
    1376 [ #  # ][ #  # ]:          0 :     bool bFocus = pParent && pParent->HasFocus();
                 [ #  # ]
    1377                 :            : 
    1378         [ #  # ]:          0 :     if(nGlobStrId==STR_PROTECTIONERR)
    1379                 :            :     {
    1380 [ #  # ][ #  # ]:          0 :         if(aViewData.GetDocShell()->IsReadOnly())
    1381                 :            :         {
    1382                 :          0 :             nGlobStrId=STR_READONLYERR;
    1383                 :            :         }
    1384                 :            :     }
    1385                 :            : 
    1386 [ #  # ][ #  # ]:          0 :     InfoBox aBox( pParent, ScGlobal::GetRscString( nGlobStrId ) );
    1387         [ #  # ]:          0 :     aBox.Execute();
    1388         [ #  # ]:          0 :     if (bFocus)
    1389 [ #  # ][ #  # ]:          0 :         pParent->GrabFocus();
                 [ #  # ]
    1390                 :            : }
    1391                 :            : 
    1392                 :          0 : Window* ScTabView::GetParentOrChild( sal_uInt16 nChildId )
    1393                 :            : {
    1394                 :          0 :     SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame();
    1395                 :            : 
    1396         [ #  # ]:          0 :     if ( pViewFrm->HasChildWindow(nChildId) )
    1397                 :            :     {
    1398                 :          0 :         SfxChildWindow* pChild = pViewFrm->GetChildWindow(nChildId);
    1399         [ #  # ]:          0 :         if (pChild)
    1400                 :            :         {
    1401                 :          0 :             Window* pWin = pChild->GetWindow();
    1402 [ #  # ][ #  # ]:          0 :             if (pWin && pWin->IsVisible())
                 [ #  # ]
    1403                 :          0 :                 return pWin;
    1404                 :            :         }
    1405                 :            :     }
    1406                 :            : 
    1407                 :          0 :     return aViewData.GetDialogParent();
    1408                 :            : }
    1409                 :            : 
    1410                 :          0 : void ScTabView::UpdatePageBreakData( bool bForcePaint )
    1411                 :            : {
    1412                 :          0 :     ScPageBreakData* pNewData = NULL;
    1413                 :            : 
    1414         [ #  # ]:          0 :     if (aViewData.IsPagebreakMode())
    1415                 :            :     {
    1416                 :          0 :         ScDocShell* pDocSh = aViewData.GetDocShell();
    1417                 :          0 :         ScDocument* pDoc = pDocSh->GetDocument();
    1418                 :          0 :         SCTAB nTab = aViewData.GetTabNo();
    1419                 :            : 
    1420         [ #  # ]:          0 :         sal_uInt16 nCount = pDoc->GetPrintRangeCount(nTab);
    1421         [ #  # ]:          0 :         if (!nCount)
    1422                 :          0 :             nCount = 1;
    1423 [ #  # ][ #  # ]:          0 :         pNewData = new ScPageBreakData(nCount);
    1424                 :            : 
    1425 [ #  # ][ #  # ]:          0 :         ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab, 0,0,NULL, NULL, pNewData );
    1426                 :            :         //  ScPrintFunc fuellt im ctor die PageBreakData
    1427         [ #  # ]:          0 :         if ( nCount > 1 )
    1428                 :            :         {
    1429         [ #  # ]:          0 :             aPrintFunc.ResetBreaks(nTab);
    1430         [ #  # ]:          0 :             pNewData->AddPages();
    1431                 :            :         }
    1432                 :            : 
    1433                 :            :         //  Druckbereiche veraendert?
    1434 [ #  # ][ #  # ]:          0 :         if ( bForcePaint || ( pPageBreakData && !pPageBreakData->IsEqual( *pNewData ) ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1435 [ #  # ][ #  # ]:          0 :             PaintGrid();
    1436                 :            :     }
    1437                 :            : 
    1438         [ #  # ]:          0 :     delete pPageBreakData;
    1439                 :          0 :     pPageBreakData = pNewData;
    1440                 :          0 : }
    1441                 :            : 
    1442                 :            : 
    1443                 :            : 
    1444                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10