LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/view - viewdata.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 134 1711 7.8 %
Date: 2012-12-27 Functions: 17 105 16.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "scitems.hxx"
      22             : #include <editeng/eeitem.hxx>
      23             : 
      24             : 
      25             : #include <sfx2/viewfrm.hxx>
      26             : #include <editeng/adjitem.hxx>
      27             : #include <svx/algitem.hxx>
      28             : #include <editeng/brshitem.hxx>
      29             : #include <svtools/colorcfg.hxx>
      30             : #include <editeng/editview.hxx>
      31             : #include <editeng/editstat.hxx>
      32             : #include <editeng/outliner.hxx>
      33             : #include <editeng/unolingu.hxx>
      34             : #include <editeng/justifyitem.hxx>
      35             : 
      36             : #include <vcl/svapp.hxx>
      37             : #include <rtl/math.hxx>
      38             : 
      39             : #include <sax/tools/converter.hxx>
      40             : 
      41             : #include "viewdata.hxx"
      42             : #include "docoptio.hxx"
      43             : #include "scmod.hxx"
      44             : #include "global.hxx"
      45             : #include "document.hxx"
      46             : #include "attrib.hxx"
      47             : #include "tabview.hxx"
      48             : #include "tabvwsh.hxx"
      49             : #include "docsh.hxx"
      50             : #include "sc.hrc"
      51             : #include "patattr.hxx"
      52             : #include "editutil.hxx"
      53             : #include "scextopt.hxx"
      54             : #include "miscuno.hxx"
      55             : #include "unonames.hxx"
      56             : #include "inputopt.hxx"
      57             : #include "viewutil.hxx"
      58             : #include "markdata.hxx"
      59             : #include "stlalgorithm.hxx"
      60             : #include "ViewSettingsSequenceDefines.hxx"
      61             : #include <rtl/ustrbuf.hxx>
      62             : #include <comphelper/processfactory.hxx>
      63             : #include <comphelper/string.hxx>
      64             : #include <com/sun/star/container/XNameContainer.hpp>
      65             : 
      66             : using namespace com::sun::star;
      67             : 
      68             : #define SC_GROWY_SMALL_EXTRA    100
      69             : #define SC_GROWY_BIG_EXTRA      200
      70             : 
      71             : #define TAG_TABBARWIDTH "tw:"
      72             : 
      73             : static sal_Bool bMoveArea = false;              //! Member?
      74             : sal_uInt16 nEditAdjust = SVX_ADJUST_LEFT;       //! Member !!!
      75             : 
      76           1 : ScViewDataTable::ScViewDataTable() :
      77             :                 eZoomType( SVX_ZOOM_PERCENT ),
      78             :                 aZoomX( 1,1 ),
      79             :                 aZoomY( 1,1 ),
      80             :                 aPageZoomX( 3,5 ),              // Page-Default: 60%
      81             :                 aPageZoomY( 3,5 ),
      82             :                 nHSplitPos( 0 ),
      83             :                 nVSplitPos( 0 ),
      84             :                 eHSplitMode( SC_SPLIT_NONE ),
      85             :                 eVSplitMode( SC_SPLIT_NONE ),
      86             :                 eWhichActive( SC_SPLIT_BOTTOMLEFT ),
      87             :                 nFixPosX( 0 ),
      88             :                 nFixPosY( 0 ),
      89             :                 nCurX( 0 ),
      90             :                 nCurY( 0 ),
      91             :                 bShowGrid( true ),
      92           1 :                 mbOldCursorValid( false )
      93             : {
      94           1 :     nPosX[0]=nPosX[1]=0;
      95           1 :     nPosY[0]=nPosY[1]=0;
      96           1 :     nTPosX[0]=nTPosX[1]=0;
      97           1 :     nTPosY[0]=nTPosY[1]=0;
      98           1 :     nMPosX[0]=nMPosX[1]=0;
      99           1 :     nMPosY[0]=nMPosY[1]=0;
     100           1 :     nPixPosX[0]=nPixPosX[1]=0;
     101           1 :     nPixPosY[0]=nPixPosY[1]=0;
     102           1 : }
     103             : 
     104           1 : ScViewDataTable::~ScViewDataTable()
     105             : {
     106           1 : }
     107             : 
     108           0 : void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& /*rViewData*/, SCTAB /*nTab*/) const
     109             : {
     110           0 :     rSettings.realloc(SC_TABLE_VIEWSETTINGS_COUNT);
     111           0 :     beans::PropertyValue* pSettings = rSettings.getArray();
     112           0 :     if (pSettings)
     113             :     {
     114           0 :         pSettings[SC_CURSOR_X].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONX));
     115           0 :         pSettings[SC_CURSOR_X].Value <<= sal_Int32(nCurX);
     116           0 :         pSettings[SC_CURSOR_Y].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONY));
     117           0 :         pSettings[SC_CURSOR_Y].Value <<= sal_Int32(nCurY);
     118           0 :         pSettings[SC_HORIZONTAL_SPLIT_MODE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITMODE));
     119           0 :         pSettings[SC_HORIZONTAL_SPLIT_MODE].Value <<= sal_Int16(eHSplitMode);
     120           0 :         pSettings[SC_VERTICAL_SPLIT_MODE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITMODE));
     121           0 :         pSettings[SC_VERTICAL_SPLIT_MODE].Value <<= sal_Int16(eVSplitMode);
     122           0 :         pSettings[SC_HORIZONTAL_SPLIT_POSITION].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITPOSITION));
     123           0 :         if (eHSplitMode == SC_SPLIT_FIX)
     124           0 :             pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosX);
     125             :         else
     126           0 :             pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nHSplitPos);
     127           0 :         pSettings[SC_VERTICAL_SPLIT_POSITION].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITPOSITION));
     128           0 :         if (eVSplitMode == SC_SPLIT_FIX)
     129           0 :             pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosY);
     130             :         else
     131           0 :             pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nVSplitPos);
     132           0 :         pSettings[SC_ACTIVE_SPLIT_RANGE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVESPLITRANGE));
     133           0 :         pSettings[SC_ACTIVE_SPLIT_RANGE].Value <<= sal_Int16(eWhichActive);
     134           0 :         pSettings[SC_POSITION_LEFT].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONLEFT));
     135           0 :         pSettings[SC_POSITION_LEFT].Value <<= sal_Int32(nPosX[SC_SPLIT_LEFT]);
     136           0 :         pSettings[SC_POSITION_RIGHT].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONRIGHT));
     137           0 :         pSettings[SC_POSITION_RIGHT].Value <<= sal_Int32(nPosX[SC_SPLIT_RIGHT]);
     138           0 :         pSettings[SC_POSITION_TOP].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONTOP));
     139           0 :         pSettings[SC_POSITION_TOP].Value <<= sal_Int32(nPosY[SC_SPLIT_TOP]);
     140           0 :         pSettings[SC_POSITION_BOTTOM].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONBOTTOM));
     141           0 :         pSettings[SC_POSITION_BOTTOM].Value <<= sal_Int32(nPosY[SC_SPLIT_BOTTOM]);
     142             : 
     143           0 :         sal_Int32 nZoomValue ((aZoomY.GetNumerator() * 100) / aZoomY.GetDenominator());
     144           0 :         sal_Int32 nPageZoomValue ((aPageZoomY.GetNumerator() * 100) / aPageZoomY.GetDenominator());
     145           0 :         pSettings[SC_TABLE_ZOOM_TYPE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMTYPE));
     146           0 :         pSettings[SC_TABLE_ZOOM_TYPE].Value <<= sal_Int16(eZoomType);
     147           0 :         pSettings[SC_TABLE_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE));
     148           0 :         pSettings[SC_TABLE_ZOOM_VALUE].Value <<= nZoomValue;
     149           0 :         pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE));
     150           0 :         pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
     151             : 
     152           0 :         pSettings[SC_TABLE_SHOWGRID].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWGRID));
     153           0 :         pSettings[SC_TABLE_SHOWGRID].Value <<= static_cast<sal_Bool>(bShowGrid);
     154             :     }
     155           0 : }
     156             : 
     157           0 : void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& aSettings, ScViewData& rViewData, SCTAB nTab, bool& rHasZoom )
     158             : {
     159           0 :     rHasZoom = false;
     160             : 
     161           0 :     sal_Int32 nCount(aSettings.getLength());
     162           0 :     sal_Int32 nTemp32(0);
     163           0 :     sal_Int16 nTemp16(0);
     164           0 :     sal_Int32 nTempPosV(0);
     165           0 :     sal_Int32 nTempPosH(0);
     166           0 :     sal_Int32 nTempPosVTw(0);
     167           0 :     sal_Int32 nTempPosHTw(0);
     168           0 :     bool bHasVSplitInTwips = false;
     169           0 :     bool bHasHSplitInTwips = false;
     170           0 :     for (sal_Int32 i = 0; i < nCount; i++)
     171             :     {
     172           0 :         rtl::OUString sName(aSettings[i].Name);
     173           0 :         if (sName.compareToAscii(SC_CURSORPOSITIONX) == 0)
     174             :         {
     175           0 :             aSettings[i].Value >>= nTemp32;
     176           0 :             nCurX = SanitizeCol( static_cast<SCCOL>(nTemp32));
     177             :         }
     178           0 :         else if (sName.compareToAscii(SC_CURSORPOSITIONY) == 0)
     179             :         {
     180           0 :             aSettings[i].Value >>= nTemp32;
     181           0 :             nCurY = SanitizeRow( static_cast<SCROW>(nTemp32));
     182             :         }
     183           0 :         else if (sName.compareToAscii(SC_HORIZONTALSPLITMODE) == 0)
     184             :         {
     185           0 :             aSettings[i].Value >>= nTemp16;
     186           0 :             eHSplitMode = static_cast<ScSplitMode>(nTemp16);
     187             :         }
     188           0 :         else if (sName.compareToAscii(SC_VERTICALSPLITMODE) == 0)
     189             :         {
     190           0 :             aSettings[i].Value >>= nTemp16;
     191           0 :             eVSplitMode = static_cast<ScSplitMode>(nTemp16);
     192             :         }
     193           0 :         else if (sName.compareToAscii(SC_HORIZONTALSPLITPOSITION) == 0)
     194             :         {
     195           0 :             aSettings[i].Value >>= nTempPosH;
     196           0 :             bHasHSplitInTwips = false;
     197             :         }
     198           0 :         else if (sName.compareToAscii(SC_VERTICALSPLITPOSITION) == 0)
     199             :         {
     200           0 :             aSettings[i].Value >>= nTempPosV;
     201           0 :             bHasVSplitInTwips = false;
     202             :         }
     203           0 :         else if (sName.compareToAscii(SC_HORIZONTALSPLITPOSITION_TWIPS) == 0)
     204             :         {
     205           0 :             aSettings[i].Value >>= nTempPosHTw;
     206           0 :             bHasHSplitInTwips = true;
     207             :         }
     208           0 :         else if (sName.compareToAscii(SC_VERTICALSPLITPOSITION_TWIPS) == 0)
     209             :         {
     210           0 :             aSettings[i].Value >>= nTempPosVTw;
     211           0 :             bHasVSplitInTwips = true;
     212             :         }
     213           0 :         else if (sName.compareToAscii(SC_ACTIVESPLITRANGE) == 0)
     214             :         {
     215           0 :             aSettings[i].Value >>= nTemp16;
     216           0 :             eWhichActive = static_cast<ScSplitPos>(nTemp16);
     217             :         }
     218           0 :         else if (sName.compareToAscii(SC_POSITIONLEFT) == 0)
     219             :         {
     220           0 :             aSettings[i].Value >>= nTemp32;
     221           0 :             nPosX[SC_SPLIT_LEFT] = SanitizeCol( static_cast<SCCOL>(nTemp32));
     222             :         }
     223           0 :         else if (sName.compareToAscii(SC_POSITIONRIGHT) == 0)
     224             :         {
     225           0 :             aSettings[i].Value >>= nTemp32;
     226           0 :             nPosX[SC_SPLIT_RIGHT] = SanitizeCol( static_cast<SCCOL>(nTemp32));
     227             :         }
     228           0 :         else if (sName.compareToAscii(SC_POSITIONTOP) == 0)
     229             :         {
     230           0 :             aSettings[i].Value >>= nTemp32;
     231           0 :             nPosY[SC_SPLIT_TOP] = SanitizeRow( static_cast<SCROW>(nTemp32));
     232             :         }
     233           0 :         else if (sName.compareToAscii(SC_POSITIONBOTTOM) == 0)
     234             :         {
     235           0 :             aSettings[i].Value >>= nTemp32;
     236           0 :             nPosY[SC_SPLIT_BOTTOM] = SanitizeRow( static_cast<SCROW>(nTemp32));
     237             :         }
     238           0 :         else if (sName.compareToAscii(SC_ZOOMTYPE) == 0)
     239             :         {
     240           0 :             aSettings[i].Value >>= nTemp16;
     241           0 :             eZoomType = SvxZoomType(nTemp16);
     242           0 :             rHasZoom = true;        // set if there is any zoom information
     243             :         }
     244           0 :         else if (sName.compareToAscii(SC_ZOOMVALUE) == 0)
     245             :         {
     246           0 :             aSettings[i].Value >>= nTemp32;
     247           0 :             Fraction aZoom(nTemp32, 100);
     248           0 :             aZoomX = aZoomY = aZoom;
     249           0 :             rHasZoom = true;
     250             :         }
     251           0 :         else if (sName.compareToAscii(SC_PAGEVIEWZOOMVALUE) == 0)
     252             :         {
     253           0 :             aSettings[i].Value >>= nTemp32;
     254           0 :             Fraction aZoom(nTemp32, 100);
     255           0 :             aPageZoomX = aPageZoomY = aZoom;
     256           0 :             rHasZoom = true;
     257             :         }
     258           0 :         else if (sName.compareToAscii(SC_UNO_SHOWGRID) == 0)
     259             :         {
     260           0 :             aSettings[i].Value >>= bShowGrid;
     261             :         }
     262           0 :         else if (sName.compareToAscii(SC_TABLESELECTED) == 0)
     263             :         {
     264           0 :             bool bSelected = false;
     265           0 :             aSettings[i].Value >>= bSelected;
     266           0 :             rViewData.GetMarkData().SelectTable( nTab, bSelected );
     267             :         }
     268           0 :         else if (sName.compareToAscii(SC_UNONAME_TABCOLOR) == 0)
     269             :         {
     270             :             // There are documents out there that have their tab color defined as a view setting.
     271           0 :             sal_Int32 nColor = COL_AUTO;
     272           0 :             aSettings[i].Value >>= nColor;
     273           0 :             if (static_cast<ColorData>(nColor) != COL_AUTO)
     274             :             {
     275           0 :                 ScDocument* pDoc = rViewData.GetDocument();
     276           0 :                 pDoc->SetTabBgColor(nTab, Color(static_cast<ColorData>(nColor)));
     277             :             }
     278             :         }
     279           0 :     }
     280           0 :     if (eHSplitMode == SC_SPLIT_FIX)
     281           0 :         nFixPosX = SanitizeCol( static_cast<SCCOL>( bHasHSplitInTwips ? nTempPosHTw : nTempPosH ));
     282             :     else
     283           0 :         nHSplitPos = bHasHSplitInTwips ? static_cast< long >( nTempPosHTw * rViewData.GetPPTX() ) : nTempPosH;
     284             : 
     285           0 :     if (eVSplitMode == SC_SPLIT_FIX)
     286           0 :         nFixPosY = SanitizeRow( static_cast<SCROW>( bHasVSplitInTwips ? nTempPosVTw : nTempPosV ));
     287             :     else
     288           0 :         nVSplitPos = bHasVSplitInTwips ? static_cast< long >( nTempPosVTw * rViewData.GetPPTY() ) : nTempPosV;
     289           0 : }
     290             : 
     291           1 : ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh ) :
     292           1 :         mpMarkData(new ScMarkData),
     293             :         pDocShell   ( pDocSh ),
     294             :         pDoc        ( NULL ),
     295             :         pView       ( pViewSh ),
     296             :         pViewShell  ( pViewSh ),
     297           1 :         pOptions    ( new ScViewOptions ),
     298             :         pSpellingView ( NULL ),
     299             :         aLogicMode  ( MAP_100TH_MM ),
     300             :         eDefZoomType( SVX_ZOOM_PERCENT ),
     301             :         aDefZoomX   ( 1,1 ),
     302             :         aDefZoomY   ( 1,1 ),
     303             :         aDefPageZoomX( 3,5 ),
     304             :         aDefPageZoomY( 3,5 ),
     305             :         eRefType    ( SC_REFTYPE_NONE ),
     306             :         nTabNo      ( 0 ),
     307             :         nRefTabNo   ( 0 ),
     308             :         nPasteFlags ( SC_PASTE_NONE ),
     309             :         eEditActivePart( SC_SPLIT_BOTTOMLEFT ),
     310             :         nFillMode   ( SC_FILL_NONE ),
     311             :         bActive     ( true ),                   //! wie initialisieren?
     312             :         bIsRefMode  ( false ),
     313             :         bDelMarkValid( false ),
     314             :         bPagebreak  ( false ),
     315           3 :         bSelCtrlMouseClick( false )
     316             : {
     317           1 :     mpMarkData->SelectOneTable(0); // Sync with nTabNo.
     318             : 
     319           1 :     SetGridMode     ( sal_True );
     320           1 :     SetSyntaxMode   ( false );
     321           1 :     SetHeaderMode   ( sal_True );
     322           1 :     SetTabMode      ( sal_True );
     323           1 :     SetVScrollMode  ( sal_True );
     324           1 :     SetHScrollMode  ( sal_True );
     325           1 :     SetOutlineMode  ( sal_True );
     326             : 
     327             :     aScrSize = Size( (long) ( STD_COL_WIDTH           * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ),
     328           1 :                      (long) ( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) );
     329           1 :     maTabData.push_back( new ScViewDataTable );
     330           1 :     pThisTab = maTabData[nTabNo];
     331           5 :     for (sal_uInt16 j=0; j<4; j++)
     332             :     {
     333           4 :         pEditView[j] = NULL;
     334           4 :         bEditActive[j] = false;
     335             :     }
     336             : 
     337           1 :     nEditEndCol = nEditStartCol = nEditCol = 0;
     338           1 :     nEditEndRow = nEditRow = 0;
     339           1 :     nTabStartCol = SC_TABSTART_NONE;
     340             : 
     341           1 :     if (pDocShell)
     342             :     {
     343           1 :         pDoc = pDocShell->GetDocument();
     344           1 :         *pOptions = pDoc->GetViewOptions();
     345             :     }
     346             : 
     347             :     //  keine ausgeblendete Tabelle anzeigen:
     348           1 :     if (pDoc && !pDoc->IsVisible(nTabNo))
     349             :     {
     350           0 :         while ( !pDoc->IsVisible(nTabNo) && pDoc->HasTable(nTabNo+1) )
     351             :         {
     352           0 :             ++nTabNo;
     353           0 :             maTabData.push_back(NULL);
     354             :         }
     355           0 :         maTabData[nTabNo] = new ScViewDataTable() ;
     356           0 :         pThisTab = maTabData[nTabNo];
     357             :     }
     358             : 
     359           1 :     CalcPPT();
     360           1 : }
     361             : 
     362           0 : ScViewData::ScViewData( const ScViewData& rViewData ) :
     363             :         maTabData( rViewData.maTabData ),
     364           0 :         mpMarkData(new ScMarkData(*rViewData.mpMarkData)),
     365             :         pDocShell   ( rViewData.pDocShell ),
     366             :         pDoc        ( rViewData.pDoc ),
     367             :         pView       ( rViewData.pView ),
     368             :         pViewShell  ( rViewData.pViewShell ),
     369           0 :         pOptions    ( new ScViewOptions( *(rViewData.pOptions) )  ),
     370             :         pSpellingView ( rViewData.pSpellingView ),
     371             :         aLogicMode  ( rViewData.aLogicMode ),
     372             :         eDefZoomType( rViewData.eDefZoomType ),
     373             :         aDefZoomX   ( rViewData.aDefZoomX ),
     374             :         aDefZoomY   ( rViewData.aDefZoomY ),
     375             :         aDefPageZoomX( rViewData.aDefPageZoomX ),
     376             :         aDefPageZoomY( rViewData.aDefPageZoomY ),
     377             :         eRefType    ( SC_REFTYPE_NONE ),
     378             :         nTabNo      ( rViewData.nTabNo ),
     379             :         nRefTabNo   ( rViewData.nTabNo ),           // kein RefMode
     380             :         eEditActivePart( rViewData.eEditActivePart ),
     381             :         nFillMode   ( SC_FILL_NONE ),
     382             :         bActive     ( true ),                               //! wie initialisieren?
     383             :         bIsRefMode  ( false ),
     384             :         bDelMarkValid( false ),
     385             :         bPagebreak  ( rViewData.bPagebreak ),
     386           0 :         bSelCtrlMouseClick( rViewData.bSelCtrlMouseClick )
     387             : {
     388             : 
     389           0 :     SetGridMode     ( rViewData.IsGridMode() );
     390           0 :     SetSyntaxMode   ( rViewData.IsSyntaxMode() );
     391           0 :     SetHeaderMode   ( rViewData.IsHeaderMode() );
     392           0 :     SetTabMode      ( rViewData.IsTabMode() );
     393           0 :     SetVScrollMode  ( rViewData.IsVScrollMode() );
     394           0 :     SetHScrollMode  ( rViewData.IsHScrollMode() );
     395           0 :     SetOutlineMode  ( rViewData.IsOutlineMode() );
     396             : 
     397           0 :     aScrSize = rViewData.aScrSize;
     398             : 
     399           0 :     pThisTab = maTabData[nTabNo];
     400           0 :     for (sal_uInt16 j=0; j<4; j++)
     401             :     {
     402           0 :         pEditView[j] = NULL;
     403           0 :         bEditActive[j] = false;
     404             :     }
     405             : 
     406           0 :     nEditEndCol = nEditStartCol = nEditCol = 0;
     407           0 :     nEditEndRow = nEditRow = 0;
     408           0 :     nTabStartCol = SC_TABSTART_NONE;
     409           0 :     CalcPPT();
     410           0 : }
     411             : 
     412           0 : void ScViewData::InitData( ScDocument* pDocument )
     413             : {
     414           0 :     pDoc = pDocument;
     415           0 :     *pOptions = pDoc->GetViewOptions();
     416           0 : }
     417             : 
     418             : 
     419           0 : ScDocument* ScViewData::GetDocument() const
     420             : {
     421           0 :     if (pDoc)
     422           0 :         return pDoc;
     423           0 :     else if (pDocShell)
     424           0 :         return pDocShell->GetDocument();
     425             : 
     426             :     OSL_FAIL("kein Document an ViewData");
     427           0 :     return NULL;
     428             : }
     429             : 
     430           2 : ScViewData::~ScViewData()
     431             : {
     432           1 :     KillEditView();
     433           1 :     delete pOptions;
     434             :     ::std::for_each(
     435           1 :         maTabData.begin(), maTabData.end(), ScDeleteObjectByPtr<ScViewDataTable>());
     436           1 : }
     437             : 
     438           0 : void ScViewData::UpdateCurrentTab()
     439             : {
     440           0 :     pThisTab = maTabData[nTabNo];
     441           0 :     while (!pThisTab)
     442             :     {
     443           0 :         if (nTabNo > 0)
     444           0 :             pThisTab = maTabData[--nTabNo];
     445             :         else
     446           0 :             pThisTab = maTabData[0] = new ScViewDataTable;
     447             :     }
     448           0 : }
     449             : 
     450           0 : void ScViewData::InsertTab( SCTAB nTab )
     451             : {
     452           0 :     if( nTab >= static_cast<SCTAB>(maTabData.size()))
     453           0 :         maTabData.resize(nTab+1, NULL);
     454             :     else
     455           0 :         maTabData.insert( maTabData.begin() + nTab, (ScViewDataTable *)NULL );
     456           0 :     CreateTabData( nTab );
     457             : 
     458           0 :     UpdateCurrentTab();
     459           0 :     mpMarkData->InsertTab( nTab );
     460           0 : }
     461             : 
     462           0 : void ScViewData::InsertTabs( SCTAB nTab, SCTAB nNewSheets )
     463             : {
     464           0 :     if( nTab+nNewSheets >= static_cast<SCTAB>(maTabData.size()))
     465           0 :         maTabData.resize(nTab+nNewSheets, NULL);
     466             :     else
     467             :     {
     468           0 :         maTabData.insert( maTabData.begin() + nTab, nNewSheets, NULL );
     469             :     }
     470           0 :     for (SCTAB i = nTab; i < nTab + nNewSheets; ++i)
     471             :     {
     472           0 :         CreateTabData( i );
     473           0 :         mpMarkData->InsertTab( i );
     474             :     }
     475           0 :     UpdateCurrentTab();
     476           0 : }
     477             : 
     478           0 : void ScViewData::DeleteTab( SCTAB nTab )
     479             : {
     480           0 :     delete maTabData.at(nTab);
     481             : 
     482           0 :     maTabData.erase(maTabData.begin() + nTab);
     483           0 :     UpdateCurrentTab();
     484           0 :     mpMarkData->DeleteTab( nTab );
     485           0 : }
     486             : 
     487           0 : void ScViewData::DeleteTabs( SCTAB nTab, SCTAB nSheets )
     488             : {
     489           0 :     for (SCTAB i = 0; i < nSheets; ++i)
     490             :     {
     491           0 :         mpMarkData->DeleteTab( nTab + i );
     492           0 :         delete maTabData.at(nTab + i);
     493             :     }
     494             : 
     495           0 :     maTabData.erase(maTabData.begin() + nTab, maTabData.begin()+ nTab+nSheets);
     496           0 :     UpdateCurrentTab();
     497           0 : }
     498             : 
     499           0 : void ScViewData::CopyTab( SCTAB nSrcTab, SCTAB nDestTab )
     500             : {
     501           0 :     if (nDestTab==SC_TAB_APPEND)
     502           0 :         nDestTab = pDoc->GetTableCount() - 1;   // am Doc muss vorher kopiert worden sein
     503             : 
     504           0 :     if (nDestTab > MAXTAB)
     505             :     {
     506             :         OSL_FAIL("Zuviele Tabellen");
     507           0 :         return;
     508             :     }
     509             : 
     510           0 :     if (nSrcTab >= static_cast<SCTAB>(maTabData.size()))
     511             :         OSL_FAIL("pTabData out of bounds, FIX IT");
     512             : 
     513           0 :     EnsureTabDataSize(nDestTab + 1);
     514             : 
     515           0 :     if ( maTabData[nSrcTab] )
     516           0 :         maTabData.insert(maTabData.begin() + nDestTab, new ScViewDataTable( *maTabData[nSrcTab] ));
     517             :     else
     518           0 :         maTabData.insert(maTabData.begin() + nDestTab, (ScViewDataTable *)NULL);
     519             : 
     520           0 :     UpdateCurrentTab();
     521           0 :     mpMarkData->InsertTab( nDestTab );
     522             : }
     523             : 
     524           0 : void ScViewData::MoveTab( SCTAB nSrcTab, SCTAB nDestTab )
     525             : {
     526           0 :     if (nDestTab==SC_TAB_APPEND)
     527           0 :         nDestTab = pDoc->GetTableCount() - 1;
     528           0 :     ScViewDataTable* pTab = NULL;
     529           0 :     if (nSrcTab < static_cast<SCTAB>(maTabData.size()))
     530             :     {
     531           0 :         pTab = maTabData[nSrcTab];
     532           0 :         maTabData.erase( maTabData.begin() + nSrcTab );
     533             :     }
     534             : 
     535           0 :     if (nDestTab < static_cast<SCTAB>(maTabData.size()))
     536           0 :         maTabData.insert( maTabData.begin() + nDestTab, pTab );
     537             :     else
     538             :     {
     539           0 :         EnsureTabDataSize(nDestTab + 1);
     540           0 :         maTabData[nDestTab] = pTab;
     541             :     }
     542             : 
     543           0 :     UpdateCurrentTab();
     544           0 :     mpMarkData->DeleteTab( nSrcTab );
     545           0 :     mpMarkData->InsertTab( nDestTab );            // ggf. angepasst
     546           0 : }
     547             : 
     548           0 : void ScViewData::CreateTabData( std::vector< SCTAB >& rvTabs )
     549             : {
     550           0 :     std::vector< SCTAB >::iterator it_end = rvTabs.end();
     551           0 :     for ( std::vector< SCTAB >::iterator it = rvTabs.begin(); it != it_end; ++it )
     552           0 :         CreateTabData(*it);
     553           0 : }
     554             : 
     555           0 : void ScViewData::SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs )
     556             : {
     557           0 :     sal_Bool bAll = ( tabs.empty() );
     558             : 
     559           0 :     if ( !bAll ) // create associated table data
     560           0 :         CreateTabData( tabs );
     561             : 
     562           0 :     if ( bAll )
     563             :     {
     564           0 :         for ( SCTAB i = 0; i < static_cast<SCTAB>(maTabData.size()); ++i )
     565             :         {
     566           0 :             if ( maTabData[i] )
     567           0 :                 maTabData[i]->eZoomType = eNew;
     568             :         }
     569           0 :         eDefZoomType = eNew;
     570             :     }
     571             :     else
     572             :     {
     573           0 :         std::vector< SCTAB >::iterator it_end = tabs.end();
     574           0 :         std::vector< SCTAB >::iterator it = tabs.begin();
     575           0 :         for ( ; it != it_end; ++it )
     576             :         {
     577           0 :             SCTAB i = *it;
     578           0 :             if ( i < static_cast<SCTAB>(maTabData.size()) && maTabData[i] )
     579           0 :                 maTabData[i]->eZoomType = eNew;
     580             :         }
     581             :     }
     582           0 : }
     583             : 
     584           0 : void ScViewData::SetZoomType( SvxZoomType eNew, sal_Bool bAll )
     585             : {
     586           0 :     std::vector< SCTAB > vTabs; // Empty for all tabs
     587           0 :     if ( !bAll ) // get selected tabs
     588             :     {
     589           0 :         ScMarkData::iterator itr = mpMarkData->begin(), itrEnd = mpMarkData->end();
     590           0 :         vTabs.insert(vTabs.begin(), itr, itrEnd);
     591             :     }
     592           0 :     SetZoomType( eNew, vTabs );
     593           0 : }
     594             : 
     595           0 : void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs )
     596             : {
     597           0 :     sal_Bool bAll = ( tabs.empty() );
     598           0 :     if ( !bAll ) // create associated table data
     599           0 :         CreateTabData( tabs );
     600           0 :     Fraction aFrac20( 1,5 );
     601           0 :     Fraction aFrac400( 4,1 );
     602             : 
     603           0 :     Fraction aValidX = rNewX;
     604           0 :     if (aValidX<aFrac20)
     605           0 :         aValidX = aFrac20;
     606           0 :     if (aValidX>aFrac400)
     607           0 :         aValidX = aFrac400;
     608             : 
     609           0 :     Fraction aValidY = rNewY;
     610           0 :     if (aValidY<aFrac20)
     611           0 :         aValidY = aFrac20;
     612           0 :     if (aValidY>aFrac400)
     613           0 :         aValidY = aFrac400;
     614             : 
     615           0 :     if ( bAll )
     616             :     {
     617           0 :         for ( SCTAB i = 0; i < static_cast<SCTAB>(maTabData.size()); ++i )
     618             :         {
     619           0 :             if ( maTabData[i] )
     620             :             {
     621           0 :                 if ( bPagebreak )
     622             :                 {
     623           0 :                     maTabData[i]->aPageZoomX = aValidX;
     624           0 :                     maTabData[i]->aPageZoomY = aValidY;
     625             :                 }
     626             :                 else
     627             :                 {
     628           0 :                     maTabData[i]->aZoomX = aValidX;
     629           0 :                     maTabData[i]->aZoomY = aValidY;
     630             :                 }
     631             :             }
     632             :         }
     633           0 :         if ( bPagebreak )
     634             :         {
     635           0 :             aDefPageZoomX = aValidX;
     636           0 :             aDefPageZoomY = aValidY;
     637             :         }
     638             :         else
     639             :         {
     640           0 :             aDefZoomX = aValidX;
     641           0 :             aDefZoomY = aValidY;
     642             :         }
     643             :     }
     644             :     else
     645             :     {
     646           0 :         std::vector< SCTAB >::iterator it_end = tabs.end();
     647           0 :         std::vector< SCTAB >::iterator it = tabs.begin();
     648           0 :         for ( ; it != it_end; ++it )
     649             :         {
     650           0 :             SCTAB i = *it;
     651           0 :             if ( i < static_cast<SCTAB>(maTabData.size()) && maTabData[i] )
     652             :             {
     653           0 :                 if ( bPagebreak )
     654             :                 {
     655           0 :                     maTabData[i]->aPageZoomX = aValidX;
     656           0 :                     maTabData[i]->aPageZoomY = aValidY;
     657             :                 }
     658             :                 else
     659             :                 {
     660           0 :                     maTabData[i]->aZoomX = aValidX;
     661           0 :                     maTabData[i]->aZoomY = aValidY;
     662             :                 }
     663             :             }
     664             :         }
     665             :     }
     666           0 :     RefreshZoom();
     667           0 : }
     668             : 
     669           0 : void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, sal_Bool bAll )
     670             : {
     671           0 :     std::vector< SCTAB > vTabs;
     672           0 :     if ( !bAll ) // get selected tabs
     673             :     {
     674           0 :         ScMarkData::iterator itr = mpMarkData->begin(), itrEnd = mpMarkData->end();
     675           0 :         vTabs.insert(vTabs.begin(), itr, itrEnd);
     676             :     }
     677           0 :     SetZoom( rNewX, rNewY, vTabs );
     678           0 : }
     679             : 
     680           0 : void ScViewData::SetShowGrid( bool bShow )
     681             : {
     682           0 :     CreateSelectedTabData();
     683           0 :     maTabData[nTabNo]->bShowGrid = bShow;
     684           0 : }
     685             : 
     686           0 : void ScViewData::RefreshZoom()
     687             : {
     688             :     // recalculate zoom-dependent values (only for current sheet)
     689             : 
     690           0 :     CalcPPT();
     691           0 :     RecalcPixPos();
     692           0 :     aScenButSize = Size(0,0);
     693           0 :     aLogicMode.SetScaleX( GetZoomX() );
     694           0 :     aLogicMode.SetScaleY( GetZoomY() );
     695           0 : }
     696             : 
     697           0 : void ScViewData::SetPagebreakMode( bool bSet )
     698             : {
     699           0 :     bPagebreak = bSet;
     700             : 
     701           0 :     RefreshZoom();
     702           0 : }
     703             : 
     704             : 
     705           0 : ScMarkType ScViewData::GetSimpleArea( ScRange & rRange, ScMarkData & rNewMark ) const
     706             : {
     707           0 :     ScMarkType eMarkType = SC_MARK_NONE;
     708             : 
     709           0 :     if ( rNewMark.IsMarked() || rNewMark.IsMultiMarked() )
     710             :     {
     711           0 :         if ( rNewMark.IsMultiMarked() )
     712           0 :             rNewMark.MarkToSimple();
     713             : 
     714           0 :         if ( rNewMark.IsMarked() && !rNewMark.IsMultiMarked() )
     715             :         {
     716           0 :             rNewMark.GetMarkArea( rRange );
     717           0 :             if (ScViewUtil::HasFiltered( rRange, GetDocument()))
     718           0 :                 eMarkType = SC_MARK_SIMPLE_FILTERED;
     719             :             else
     720           0 :                 eMarkType = SC_MARK_SIMPLE;
     721             :         }
     722             :         else
     723           0 :             eMarkType = SC_MARK_MULTI;
     724             :     }
     725           0 :     if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
     726             :     {
     727           0 :         if (eMarkType == SC_MARK_NONE)
     728           0 :             eMarkType = SC_MARK_SIMPLE;
     729           0 :         rRange = ScRange( GetCurX(), GetCurY(), GetTabNo() );
     730             :     }
     731           0 :     return eMarkType;
     732             : }
     733             : 
     734             : 
     735           0 : ScMarkType ScViewData::GetSimpleArea( SCCOL& rStartCol, SCROW& rStartRow, SCTAB& rStartTab,
     736             :                                 SCCOL& rEndCol, SCROW& rEndRow, SCTAB& rEndTab ) const
     737             : {
     738             :     //  parameter bMergeMark is no longer needed: The view's selection is never modified
     739             :     //  (a local copy is used), and a multi selection that adds to a single range can always
     740             :     //  be treated like a single selection (GetSimpleArea isn't used in selection
     741             :     //  handling itself)
     742             : 
     743           0 :     ScRange aRange;
     744           0 :     ScMarkData aNewMark(*mpMarkData);       // use a local copy for MarkToSimple
     745           0 :     ScMarkType eMarkType = GetSimpleArea( aRange, aNewMark);
     746           0 :     aRange.GetVars( rStartCol, rStartRow, rStartTab, rEndCol, rEndRow, rEndTab);
     747           0 :     return eMarkType;
     748             : }
     749             : 
     750           0 : ScMarkType ScViewData::GetSimpleArea( ScRange& rRange ) const
     751             : {
     752             :     //  parameter bMergeMark is no longer needed, see above
     753             : 
     754           0 :     ScMarkData aNewMark(*mpMarkData);       // use a local copy for MarkToSimple
     755           0 :     return GetSimpleArea( rRange, aNewMark);
     756             : }
     757             : 
     758           0 : void ScViewData::GetMultiArea( ScRangeListRef& rRange ) const
     759             : {
     760             :     //  parameter bMergeMark is no longer needed, see GetSimpleArea
     761             : 
     762           0 :     ScMarkData aNewMark(*mpMarkData);       // use a local copy for MarkToSimple
     763             : 
     764           0 :     sal_Bool bMulti = aNewMark.IsMultiMarked();
     765           0 :     if (bMulti)
     766             :     {
     767           0 :         aNewMark.MarkToSimple();
     768           0 :         bMulti = aNewMark.IsMultiMarked();
     769             :     }
     770           0 :     if (bMulti)
     771             :     {
     772           0 :         rRange = new ScRangeList;
     773           0 :         aNewMark.FillRangeListWithMarks( rRange, false );
     774             :     }
     775             :     else
     776             :     {
     777           0 :         ScRange aSimple;
     778           0 :         GetSimpleArea(aSimple);
     779           0 :         rRange = new ScRangeList;
     780           0 :         rRange->Append(aSimple);
     781           0 :     }
     782           0 : }
     783             : 
     784           0 : sal_Bool ScViewData::SimpleColMarked()
     785             : {
     786             :     SCCOL nStartCol;
     787             :     SCROW nStartRow;
     788             :     SCTAB nStartTab;
     789             :     SCCOL nEndCol;
     790             :     SCROW nEndRow;
     791             :     SCTAB nEndTab;
     792           0 :     if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
     793           0 :         if (nStartRow==0 && nEndRow==MAXROW)
     794           0 :             return sal_True;
     795             : 
     796           0 :     return false;
     797             : }
     798             : 
     799           0 : sal_Bool ScViewData::SimpleRowMarked()
     800             : {
     801             :     SCCOL nStartCol;
     802             :     SCROW nStartRow;
     803             :     SCTAB nStartTab;
     804             :     SCCOL nEndCol;
     805             :     SCROW nEndRow;
     806             :     SCTAB nEndTab;
     807           0 :     if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
     808           0 :         if (nStartCol==0 && nEndCol==MAXCOL)
     809           0 :             return sal_True;
     810             : 
     811           0 :     return false;
     812             : }
     813             : 
     814           0 : sal_Bool ScViewData::IsMultiMarked()
     815             : {
     816             :     // Test for "real" multi selection, calling MarkToSimple on a local copy,
     817             :     // and taking filtered in simple area marks into account.
     818             : 
     819           0 :     ScRange aDummy;
     820           0 :     ScMarkType eType = GetSimpleArea(aDummy);
     821           0 :     return (eType & SC_MARK_SIMPLE) != SC_MARK_SIMPLE;
     822             : }
     823             : 
     824           0 : void ScViewData::SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
     825             : {
     826           0 :     nFillMode   = SC_FILL_FILL;
     827           0 :     nFillStartX = nStartCol;
     828           0 :     nFillStartY = nStartRow;
     829           0 :     nFillEndX   = nEndCol;
     830           0 :     nFillEndY   = nEndRow;
     831           0 : }
     832             : 
     833           0 : void ScViewData::SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
     834             :                                 sal_uInt8 nMode )
     835             : {
     836           0 :     nFillMode   = nMode;
     837           0 :     nFillStartX = nStartCol;
     838           0 :     nFillStartY = nStartRow;
     839           0 :     nFillEndX   = nEndCol;
     840           0 :     nFillEndY   = nEndRow;
     841           0 : }
     842             : 
     843           0 : void ScViewData::ResetFillMode()
     844             : {
     845           0 :     nFillMode   = SC_FILL_NONE;
     846           0 : }
     847             : 
     848           0 : void ScViewData::GetFillData( SCCOL& rStartCol, SCROW& rStartRow,
     849             :                                 SCCOL& rEndCol, SCROW& rEndRow )
     850             : {
     851           0 :     rStartCol = nFillStartX;
     852           0 :     rStartRow = nFillStartY;
     853           0 :     rEndCol   = nFillEndX;
     854           0 :     rEndRow   = nFillEndY;
     855           0 : }
     856             : 
     857           0 : SCCOL ScViewData::GetOldCurX() const
     858             : {
     859           0 :     if (pThisTab->mbOldCursorValid)
     860           0 :         return pThisTab->nOldCurX;
     861             :     else
     862           0 :         return pThisTab->nCurX;
     863             : }
     864             : 
     865           0 : SCROW ScViewData::GetOldCurY() const
     866             : {
     867           0 :     if (pThisTab->mbOldCursorValid)
     868           0 :         return pThisTab->nOldCurY;
     869             :     else
     870           0 :         return pThisTab->nCurY;
     871             : }
     872             : 
     873           0 : void ScViewData::SetOldCursor( SCCOL nNewX, SCROW nNewY )
     874             : {
     875           0 :     pThisTab->nOldCurX = nNewX;
     876           0 :     pThisTab->nOldCurY = nNewY;
     877           0 :     pThisTab->mbOldCursorValid = true;
     878           0 : }
     879             : 
     880           0 : void ScViewData::ResetOldCursor()
     881             : {
     882           0 :     pThisTab->mbOldCursorValid = false;
     883           0 : }
     884             : 
     885           0 : Rectangle ScViewData::GetEditArea( ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY,
     886             :                                     Window* pWin, const ScPatternAttr* pPattern,
     887             :                                     sal_Bool bForceToTop )
     888             : {
     889           0 :     return ScEditUtil( pDoc, nPosX, nPosY, nTabNo, GetScrPos(nPosX,nPosY,eWhich,sal_True),
     890           0 :                         pWin, nPPTX, nPPTY, GetZoomX(), GetZoomY() ).
     891           0 :                             GetEditArea( pPattern, bForceToTop );
     892             : }
     893             : 
     894           0 : void ScViewData::SetEditEngine( ScSplitPos eWhich,
     895             :                                 ScEditEngineDefaulter* pNewEngine,
     896             :                                 Window* pWin, SCCOL nNewX, SCROW nNewY )
     897             : {
     898           0 :     sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTabNo );
     899           0 :     ScHSplitPos eHWhich = WhichH(eWhich);
     900             : 
     901           0 :     sal_Bool bWasThere = false;
     902           0 :     if (pEditView[eWhich])
     903             :     {
     904             :         //  Wenn die View schon da ist, nichts aufrufen, was die Cursorposition aendert
     905             : 
     906           0 :         if (bEditActive[eWhich])
     907           0 :             bWasThere = sal_True;
     908             :         else
     909           0 :             pEditView[eWhich]->SetEditEngine(pNewEngine);
     910             : 
     911           0 :         if (pEditView[eWhich]->GetWindow() != pWin)
     912             :         {
     913           0 :             pEditView[eWhich]->SetWindow(pWin);
     914             :             OSL_FAIL("EditView Window geaendert");
     915             :         }
     916             :     }
     917             :     else
     918             :     {
     919           0 :         pEditView[eWhich] = new EditView( pNewEngine, pWin );
     920             :     }
     921             : 
     922             :     //  bei IdleFormat wird manchmal ein Cursor gemalt, wenn die View schon weg ist (23576)
     923             : 
     924           0 :     sal_uLong nEC = pNewEngine->GetControlWord();
     925           0 :     pNewEngine->SetControlWord(nEC & ~EE_CNTRL_DOIDLEFORMAT);
     926             : 
     927           0 :     sal_uLong nVC = pEditView[eWhich]->GetControlWord();
     928           0 :     pEditView[eWhich]->SetControlWord(nVC & ~EV_CNTRL_AUTOSCROLL);
     929             : 
     930           0 :     bEditActive[eWhich] = true;
     931             : 
     932           0 :     const ScPatternAttr* pPattern = pDoc->GetPattern( nNewX, nNewY, nTabNo );
     933             :     SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)
     934           0 :                                     pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue();
     935             : 
     936             :     sal_Bool bBreak = ( eJust == SVX_HOR_JUSTIFY_BLOCK ) ||
     937           0 :                     ((SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue();
     938             : 
     939           0 :     sal_Bool bAsianVertical = pNewEngine->IsVertical();     // set by InputHandler
     940             : 
     941           0 :     Rectangle aPixRect = ScEditUtil( pDoc, nNewX,nNewY,nTabNo, GetScrPos(nNewX,nNewY,eWhich),
     942           0 :                                         pWin, nPPTX,nPPTY,GetZoomX(),GetZoomY() ).
     943           0 :                                             GetEditArea( pPattern, sal_True );
     944             : 
     945             :     //  when right-aligned, leave space for the cursor
     946             :     //  in vertical mode, editing is always right-aligned
     947           0 :     if ( nEditAdjust == SVX_ADJUST_RIGHT || bAsianVertical )
     948           0 :         aPixRect.Right() += 1;
     949             : 
     950           0 :     Rectangle aOutputArea = pWin->PixelToLogic( aPixRect, GetLogicMode() );
     951           0 :     pEditView[eWhich]->SetOutputArea( aOutputArea );
     952             : 
     953           0 :     if ( bActive && eWhich == GetActivePart() )
     954             :     {
     955             :         // keep the part that has the active edit view available after
     956             :         // switching sheets or reference input on a different part
     957           0 :         eEditActivePart = eWhich;
     958             : 
     959             :         //  modify members nEditCol etc. only if also extending for needed area
     960           0 :         nEditCol = nNewX;
     961           0 :         nEditRow = nNewY;
     962           0 :         const ScMergeAttr* pMergeAttr = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
     963           0 :         nEditEndCol = nEditCol;
     964           0 :         if (pMergeAttr->GetColMerge() > 1)
     965           0 :             nEditEndCol += pMergeAttr->GetColMerge() - 1;
     966           0 :         nEditEndRow = nEditRow;
     967           0 :         if (pMergeAttr->GetRowMerge() > 1)
     968           0 :             nEditEndRow += pMergeAttr->GetRowMerge() - 1;
     969           0 :         nEditStartCol = nEditCol;
     970             : 
     971             :         //  For growing use only the alignment value from the attribute, numbers
     972             :         //  (existing or started) with default aligment extend to the right.
     973           0 :         sal_Bool bGrowCentered = ( eJust == SVX_HOR_JUSTIFY_CENTER );
     974           0 :         sal_Bool bGrowToLeft = ( eJust == SVX_HOR_JUSTIFY_RIGHT );      // visual left
     975           0 :         sal_Bool bGrowBackwards = bGrowToLeft;                          // logical left
     976           0 :         if ( bLayoutRTL )
     977           0 :             bGrowBackwards = !bGrowBackwards;                       // invert on RTL sheet
     978           0 :         if ( bAsianVertical )
     979           0 :             bGrowCentered = bGrowToLeft = bGrowBackwards = false;   // keep old behavior for asian mode
     980             : 
     981             :         long nSizeXPix;
     982           0 :         if (bBreak && !bAsianVertical)
     983           0 :             nSizeXPix = aPixRect.GetWidth();    // Papersize -> kein H-Scrolling
     984             :         else
     985             :         {
     986             :             OSL_ENSURE(pView,"keine View fuer EditView");
     987             : 
     988           0 :             if ( bGrowCentered )
     989             :             {
     990             :                 //  growing into both directions until one edge is reached
     991             :                 //! should be limited to whole cells in both directions
     992           0 :                 long nLeft = aPixRect.Left();
     993           0 :                 long nRight = pView->GetGridWidth(eHWhich) - aPixRect.Right();
     994           0 :                 nSizeXPix = aPixRect.GetWidth() + 2 * Min( nLeft, nRight );
     995             :             }
     996           0 :             else if ( bGrowToLeft )
     997           0 :                 nSizeXPix = aPixRect.Right();   // space that's available in the window when growing to the left
     998             :             else
     999           0 :                 nSizeXPix = pView->GetGridWidth(eHWhich) - aPixRect.Left();
    1000             : 
    1001           0 :             if ( nSizeXPix <= 0 )
    1002           0 :                 nSizeXPix = aPixRect.GetWidth();    // editing outside to the right of the window -> keep cell width
    1003             :         }
    1004             :         OSL_ENSURE(pView,"keine View fuer EditView");
    1005           0 :         long nSizeYPix = pView->GetGridHeight(WhichV(eWhich)) - aPixRect.Top();
    1006           0 :         if ( nSizeYPix <= 0 )
    1007           0 :             nSizeYPix = aPixRect.GetHeight();   // editing outside below the window -> keep cell height
    1008             : 
    1009           0 :         Size aPaperSize = pView->GetActiveWin()->PixelToLogic( Size( nSizeXPix, nSizeYPix ), GetLogicMode() );
    1010           0 :         if ( bBreak && !bAsianVertical && SC_MOD()->GetInputOptions().GetTextWysiwyg() )
    1011             :         {
    1012             :             //  if text is formatted for printer, use the exact same paper width
    1013             :             //  (and same line breaks) as for output.
    1014             : 
    1015           0 :             Fraction aFract(1,1);
    1016             :             Rectangle aUtilRect = ScEditUtil( pDoc,nNewX,nNewY,nTabNo, Point(0,0), pWin,
    1017           0 :                                     HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( pPattern, false );
    1018           0 :             aPaperSize.Width() = aUtilRect.GetWidth();
    1019             :         }
    1020           0 :         pNewEngine->SetPaperSize( aPaperSize );
    1021             : 
    1022             :         // sichtbarer Ausschnitt
    1023           0 :         Size aPaper = pNewEngine->GetPaperSize();
    1024           0 :         Rectangle aVis = pEditView[eWhich]->GetVisArea();
    1025           0 :         long nDiff = aVis.Right() - aVis.Left();
    1026           0 :         if ( nEditAdjust == SVX_ADJUST_RIGHT )
    1027             :         {
    1028           0 :             aVis.Right() = aPaper.Width() - 1;
    1029           0 :             bMoveArea = !bLayoutRTL;
    1030             :         }
    1031           0 :         else if ( nEditAdjust == SVX_ADJUST_CENTER )
    1032             :         {
    1033           0 :             aVis.Right() = ( aPaper.Width() - 1 + nDiff ) / 2;
    1034           0 :             bMoveArea = sal_True;   // always
    1035             :         }
    1036             :         else
    1037             :         {
    1038           0 :             aVis.Right() = nDiff;
    1039           0 :             bMoveArea = bLayoutRTL;
    1040             :         }
    1041           0 :         aVis.Left() = aVis.Right() - nDiff;
    1042             :         // #i49561# Important note:
    1043             :         // The set offset of the visible area of the EditView for centered and
    1044             :         // right alignment in horizontal layout is consider by instances of
    1045             :         // class <ScEditObjectViewForwarder> in its methods <LogicToPixel(..)>
    1046             :         // and <PixelToLogic(..)>. This is needed for the correct visibility
    1047             :         // of paragraphs in edit mode at the accessibility API.
    1048           0 :         pEditView[eWhich]->SetVisArea(aVis);
    1049             :         //  UpdateMode has been disabled in ScInputHandler::StartTable
    1050             :         //  must be enabled before EditGrowY (GetTextHeight)
    1051           0 :         pNewEngine->SetUpdateMode( sal_True );
    1052             : 
    1053           0 :         pNewEngine->SetStatusEventHdl( LINK( this, ScViewData, EditEngineHdl ) );
    1054             : 
    1055           0 :         EditGrowY( sal_True );      // adjust to existing text content
    1056           0 :         EditGrowX();
    1057             : 
    1058           0 :         Point aDocPos = pEditView[eWhich]->GetWindowPosTopLeft(0);
    1059           0 :         if (aDocPos.Y() < aOutputArea.Top())
    1060           0 :             pEditView[eWhich]->Scroll( 0, aOutputArea.Top() - aDocPos.Y() );
    1061             :     }
    1062             : 
    1063             :                                                     // hier muss bEditActive schon gesetzt sein
    1064             :                                                     // (wegen Map-Mode bei Paint)
    1065           0 :     if (!bWasThere)
    1066           0 :         pNewEngine->InsertView(pEditView[eWhich]);
    1067             : 
    1068             :     //      background color of the cell
    1069           0 :     Color aBackCol = ((const SvxBrushItem&)pPattern->GetItem(ATTR_BACKGROUND)).GetColor();
    1070             : 
    1071           0 :     ScModule* pScMod = SC_MOD();
    1072           0 :     if ( aBackCol.GetTransparency() > 0 )
    1073             :     {
    1074           0 :         aBackCol.SetColor( pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
    1075             :     }
    1076           0 :     pEditView[eWhich]->SetBackgroundColor( aBackCol );
    1077             : 
    1078           0 :     pEditView[eWhich]->Invalidate();            //  needed ??
    1079             :     //  needed, wenn position changed
    1080           0 : }
    1081             : 
    1082           0 : IMPL_LINK_NOARG_INLINE_START(ScViewData, EmptyEditHdl)
    1083             : {
    1084           0 :     return 0;
    1085             : }
    1086           0 : IMPL_LINK_NOARG_INLINE_END(ScViewData, EmptyEditHdl)
    1087             : 
    1088           0 : IMPL_LINK( ScViewData, EditEngineHdl, EditStatus *, pStatus )
    1089             : {
    1090           0 :     sal_uLong nStatus = pStatus->GetStatusWord();
    1091           0 :     if (nStatus & (EE_STAT_HSCROLL | EE_STAT_TEXTHEIGHTCHANGED | EE_STAT_TEXTWIDTHCHANGED | EE_STAT_CURSOROUT))
    1092             :     {
    1093           0 :         EditGrowY();
    1094           0 :         EditGrowX();
    1095             : 
    1096           0 :         if (nStatus & EE_STAT_CURSOROUT)
    1097             :         {
    1098           0 :             ScSplitPos eWhich = GetActivePart();
    1099           0 :             if (pEditView[eWhich])
    1100           0 :                 pEditView[eWhich]->ShowCursor(false);
    1101             :         }
    1102             :     }
    1103           0 :     return 0;
    1104             : }
    1105             : 
    1106           0 : void ScViewData::EditGrowX()
    1107             : {
    1108           0 :     ScDocument* pLocalDoc = GetDocument();
    1109             : 
    1110           0 :     ScSplitPos eWhich = GetActivePart();
    1111           0 :     ScHSplitPos eHWhich = WhichH(eWhich);
    1112           0 :     EditView* pCurView = pEditView[eWhich];
    1113             : 
    1114           0 :     if ( !pCurView || !bEditActive[eWhich])
    1115           0 :         return;
    1116             : 
    1117           0 :     sal_Bool bLayoutRTL = pLocalDoc->IsLayoutRTL( nTabNo );
    1118             : 
    1119             :     ScEditEngineDefaulter* pEngine =
    1120           0 :         (ScEditEngineDefaulter*) pCurView->GetEditEngine();
    1121           0 :     Window* pWin = pCurView->GetWindow();
    1122             : 
    1123           0 :     SCCOL nLeft = GetPosX(eHWhich);
    1124           0 :     SCCOL nRight = nLeft + VisibleCellsX(eHWhich);
    1125             : 
    1126           0 :     Size        aSize = pEngine->GetPaperSize();
    1127           0 :     Rectangle   aArea = pCurView->GetOutputArea();
    1128           0 :     long        nOldRight = aArea.Right();
    1129             : 
    1130             :     //  Margin ist schon bei der urspruenglichen Breite beruecksichtigt
    1131           0 :     long nTextWidth = pEngine->CalcTextWidth();
    1132             : 
    1133           0 :     sal_Bool bChanged = false;
    1134           0 :     sal_Bool bAsianVertical = pEngine->IsVertical();
    1135             : 
    1136             :     //  get bGrow... variables the same way as in SetEditEngine
    1137           0 :     const ScPatternAttr* pPattern = pLocalDoc->GetPattern( nEditCol, nEditRow, nTabNo );
    1138             :     SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)
    1139           0 :                                     pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue();
    1140           0 :     sal_Bool bGrowCentered = ( eJust == SVX_HOR_JUSTIFY_CENTER );
    1141           0 :     sal_Bool bGrowToLeft = ( eJust == SVX_HOR_JUSTIFY_RIGHT );      // visual left
    1142           0 :     sal_Bool bGrowBackwards = bGrowToLeft;                          // logical left
    1143           0 :     if ( bLayoutRTL )
    1144           0 :         bGrowBackwards = !bGrowBackwards;                       // invert on RTL sheet
    1145           0 :     if ( bAsianVertical )
    1146           0 :         bGrowCentered = bGrowToLeft = bGrowBackwards = false;   // keep old behavior for asian mode
    1147             : 
    1148           0 :     sal_Bool bUnevenGrow = false;
    1149           0 :     if ( bGrowCentered )
    1150             :     {
    1151           0 :         while (aArea.GetWidth() + 0 < nTextWidth && ( nEditStartCol > nLeft || nEditEndCol < nRight ) )
    1152             :         {
    1153           0 :             long nLogicLeft = 0;
    1154           0 :             if ( nEditStartCol > nLeft )
    1155             :             {
    1156           0 :                 --nEditStartCol;
    1157           0 :                 long nLeftPix = ToPixel( pLocalDoc->GetColWidth( nEditStartCol, nTabNo ), nPPTX );
    1158           0 :                 nLogicLeft = pWin->PixelToLogic(Size(nLeftPix,0)).Width();
    1159             :             }
    1160           0 :             long nLogicRight = 0;
    1161           0 :             if ( nEditEndCol < nRight )
    1162             :             {
    1163           0 :                 ++nEditEndCol;
    1164           0 :                 long nRightPix = ToPixel( pLocalDoc->GetColWidth( nEditEndCol, nTabNo ), nPPTX );
    1165           0 :                 nLogicRight = pWin->PixelToLogic(Size(nRightPix,0)).Width();
    1166             :             }
    1167             : 
    1168           0 :             aArea.Left() -= bLayoutRTL ? nLogicRight : nLogicLeft;
    1169           0 :             aArea.Right() += bLayoutRTL ? nLogicLeft : nLogicRight;
    1170             : 
    1171           0 :             if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
    1172             :             {
    1173           0 :                 long nCenter = ( aArea.Left() + aArea.Right() ) / 2;
    1174           0 :                 long nHalf = aSize.Width() / 2;
    1175           0 :                 aArea.Left() = nCenter - nHalf + 1;
    1176           0 :                 aArea.Right() = nCenter + aSize.Width() - nHalf - 1;
    1177             :             }
    1178             : 
    1179           0 :             bChanged = sal_True;
    1180           0 :             if ( nLogicLeft != nLogicRight )
    1181           0 :                 bUnevenGrow = sal_True;
    1182             :         }
    1183             :     }
    1184           0 :     else if ( bGrowBackwards )
    1185             :     {
    1186           0 :         while (aArea.GetWidth() + 0 < nTextWidth && nEditStartCol > nLeft)
    1187             :         {
    1188           0 :             --nEditStartCol;
    1189           0 :             long nPix = ToPixel( pLocalDoc->GetColWidth( nEditStartCol, nTabNo ), nPPTX );
    1190           0 :             long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
    1191           0 :             if ( !bLayoutRTL )
    1192           0 :                 aArea.Left() -= nLogicWidth;
    1193             :             else
    1194           0 :                 aArea.Right() += nLogicWidth;
    1195             : 
    1196           0 :             if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
    1197             :             {
    1198           0 :                 if ( !bLayoutRTL )
    1199           0 :                     aArea.Left() = aArea.Right() - aSize.Width() + 1;
    1200             :                 else
    1201           0 :                     aArea.Right() = aArea.Left() + aSize.Width() - 1;
    1202             :             }
    1203             : 
    1204           0 :             bChanged = sal_True;
    1205             :         }
    1206             :     }
    1207             :     else
    1208             :     {
    1209           0 :         while (aArea.GetWidth() + 0 < nTextWidth && nEditEndCol < nRight)
    1210             :         {
    1211           0 :             ++nEditEndCol;
    1212           0 :             long nPix = ToPixel( pLocalDoc->GetColWidth( nEditEndCol, nTabNo ), nPPTX );
    1213           0 :             long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
    1214           0 :             if ( bLayoutRTL )
    1215           0 :                 aArea.Left() -= nLogicWidth;
    1216             :             else
    1217           0 :                 aArea.Right() += nLogicWidth;
    1218             : 
    1219           0 :             if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
    1220             :             {
    1221           0 :                 if ( bLayoutRTL )
    1222           0 :                     aArea.Left() = aArea.Right() - aSize.Width() + 1;
    1223             :                 else
    1224           0 :                     aArea.Right() = aArea.Left() + aSize.Width() - 1;
    1225             :             }
    1226             : 
    1227           0 :             bChanged = sal_True;
    1228             :         }
    1229             :     }
    1230             : 
    1231           0 :     if (bChanged)
    1232             :     {
    1233           0 :         if ( bMoveArea || bGrowCentered || bGrowBackwards || bLayoutRTL )
    1234             :         {
    1235           0 :             Rectangle aVis = pCurView->GetVisArea();
    1236             : 
    1237           0 :             if ( bGrowCentered )
    1238             :             {
    1239             :                 //  switch to center-aligned (undo?) and reset VisArea to center
    1240             : 
    1241           0 :                 pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
    1242             : 
    1243           0 :                 long nCenter = aSize.Width() / 2;
    1244           0 :                 long nVisSize = aArea.GetWidth();
    1245           0 :                 aVis.Left() = nCenter - nVisSize / 2;
    1246           0 :                 aVis.Right() = aVis.Left() + nVisSize - 1;
    1247             :             }
    1248           0 :             else if ( bGrowToLeft )
    1249             :             {
    1250             :                 //  switch to right-aligned (undo?) and reset VisArea to the right
    1251             : 
    1252           0 :                 pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
    1253             : 
    1254           0 :                 aVis.Right() = aSize.Width() - 1;
    1255           0 :                 aVis.Left() = aSize.Width() - aArea.GetWidth();     // with the new, increased area
    1256             :             }
    1257             :             else
    1258             :             {
    1259             :                 //  switch to left-aligned (undo?) and reset VisArea to the left
    1260             : 
    1261           0 :                 pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
    1262             : 
    1263           0 :                 long nMove = aVis.Left();
    1264           0 :                 aVis.Left() = 0;
    1265           0 :                 aVis.Right() -= nMove;
    1266             :             }
    1267           0 :             pCurView->SetVisArea( aVis );
    1268           0 :             bMoveArea = false;
    1269             :         }
    1270             : 
    1271           0 :         pCurView->SetOutputArea(aArea);
    1272             : 
    1273             :         //  In vertical mode, the whole text is moved to the next cell (right-aligned),
    1274             :         //  so everything must be repainted. Otherwise, paint only the new area.
    1275             :         //  If growing in centered alignment, if the cells left and right have different sizes,
    1276             :         //  the whole text will move, and may not even obscure all of the original display.
    1277           0 :         if ( bUnevenGrow )
    1278             :         {
    1279           0 :             aArea.Left() = pWin->PixelToLogic( Point(0,0) ).X();
    1280           0 :             aArea.Right() = pWin->PixelToLogic( aScrSize ).Width();
    1281             :         }
    1282           0 :         else if ( !bAsianVertical && !bGrowToLeft && !bGrowCentered )
    1283           0 :             aArea.Left() = nOldRight;
    1284           0 :         pWin->Invalidate(aArea);
    1285             :     }
    1286             : }
    1287             : 
    1288           0 : void ScViewData::EditGrowY( sal_Bool bInitial )
    1289             : {
    1290           0 :     ScSplitPos eWhich = GetActivePart();
    1291           0 :     ScVSplitPos eVWhich = WhichV(eWhich);
    1292           0 :     EditView* pCurView = pEditView[eWhich];
    1293             : 
    1294           0 :     if ( !pCurView || !bEditActive[eWhich])
    1295             :         return;
    1296             : 
    1297           0 :     sal_uLong nControl = pEditView[eWhich]->GetControlWord();
    1298           0 :     if ( nControl & EV_CNTRL_AUTOSCROLL )
    1299             :     {
    1300             :         //  if end of screen had already been reached and scrolling enabled,
    1301             :         //  don't further try to grow the edit area
    1302             : 
    1303           0 :         pCurView->SetOutputArea( pCurView->GetOutputArea() );   // re-align to pixels
    1304             :         return;
    1305             :     }
    1306             : 
    1307           0 :     EditEngine* pEngine = pCurView->GetEditEngine();
    1308           0 :     Window* pWin = pCurView->GetWindow();
    1309             : 
    1310           0 :     SCROW nBottom = GetPosY(eVWhich) + VisibleCellsY(eVWhich);
    1311             : 
    1312           0 :     Size        aSize = pEngine->GetPaperSize();
    1313           0 :     Rectangle   aArea = pCurView->GetOutputArea();
    1314           0 :     long        nOldBottom = aArea.Bottom();
    1315           0 :     long        nTextHeight = pEngine->GetTextHeight();
    1316             : 
    1317             :     //  When editing a formula in a cell with optimal height, allow a larger portion
    1318             :     //  to be clipped before extending to following rows, to avoid obscuring cells for
    1319             :     //  reference input (next row is likely to be useful in formulas).
    1320           0 :     long nAllowedExtra = SC_GROWY_SMALL_EXTRA;
    1321           0 :     if ( nEditEndRow == nEditRow && !( pDoc->GetRowFlags( nEditRow, nTabNo ) & CR_MANUALSIZE ) &&
    1322           0 :             pEngine->GetParagraphCount() <= 1 )
    1323             :     {
    1324             :         //  If the (only) paragraph starts with a '=', it's a formula.
    1325             :         //  If this is the initial call and the text is empty, allow the larger value, too,
    1326             :         //  because this occurs in the normal progress of editing a formula.
    1327             :         //  Subsequent calls with empty text might involve changed attributes (including
    1328             :         //  font height), so they are treated like normal text.
    1329           0 :         String aText = pEngine->GetText( (sal_uInt16) 0 );
    1330           0 :         if ( ( aText.Len() == 0 && bInitial ) || aText.GetChar(0) == (sal_Unicode)'=' )
    1331           0 :             nAllowedExtra = SC_GROWY_BIG_EXTRA;
    1332             :     }
    1333             : 
    1334           0 :     sal_Bool bChanged = false;
    1335           0 :     sal_Bool bMaxReached = false;
    1336           0 :     while (aArea.GetHeight() + nAllowedExtra < nTextHeight && nEditEndRow < nBottom && !bMaxReached)
    1337             :     {
    1338           0 :         ++nEditEndRow;
    1339           0 :         ScDocument* pLocalDoc = GetDocument();
    1340           0 :         long nPix = ToPixel( pLocalDoc->GetRowHeight( nEditEndRow, nTabNo ), nPPTY );
    1341           0 :         aArea.Bottom() += pWin->PixelToLogic(Size(0,nPix)).Height();
    1342             : 
    1343           0 :         if ( aArea.Bottom() > aArea.Top() + aSize.Height() - 1 )
    1344             :         {
    1345           0 :             aArea.Bottom() = aArea.Top() + aSize.Height() - 1;
    1346           0 :             bMaxReached = sal_True;     // don't occupy more cells beyond paper size
    1347             :         }
    1348             : 
    1349           0 :         bChanged = sal_True;
    1350           0 :         nAllowedExtra = SC_GROWY_SMALL_EXTRA;   // larger value is only for first row
    1351             :     }
    1352             : 
    1353           0 :     if (bChanged)
    1354             :     {
    1355           0 :         pCurView->SetOutputArea(aArea);
    1356             : 
    1357           0 :         if (nEditEndRow >= nBottom || bMaxReached)
    1358             :         {
    1359           0 :             if ((nControl & EV_CNTRL_AUTOSCROLL) == 0)
    1360           0 :                 pCurView->SetControlWord( nControl | EV_CNTRL_AUTOSCROLL );
    1361             :         }
    1362             : 
    1363           0 :         aArea.Top() = nOldBottom;
    1364           0 :         pWin->Invalidate(aArea);
    1365             :     }
    1366             : }
    1367             : 
    1368           0 : void ScViewData::ResetEditView()
    1369             : {
    1370           0 :     EditEngine* pEngine = NULL;
    1371           0 :     for (sal_uInt16 i=0; i<4; i++)
    1372           0 :         if (pEditView[i])
    1373             :         {
    1374           0 :             if (bEditActive[i])
    1375             :             {
    1376           0 :                 pEngine = pEditView[i]->GetEditEngine();
    1377           0 :                 pEngine->RemoveView(pEditView[i]);
    1378           0 :                 pEditView[i]->SetOutputArea( Rectangle() );
    1379             :             }
    1380           0 :             bEditActive[i] = false;
    1381             :         }
    1382             : 
    1383           0 :     if (pEngine)
    1384           0 :         pEngine->SetStatusEventHdl( LINK( this, ScViewData, EmptyEditHdl ) );
    1385           0 : }
    1386             : 
    1387           1 : void ScViewData::KillEditView()
    1388             : {
    1389           5 :     for (sal_uInt16 i=0; i<4; i++)
    1390           4 :         if (pEditView[i])
    1391             :         {
    1392           0 :             if (bEditActive[i])
    1393           0 :                 pEditView[i]->GetEditEngine()->RemoveView(pEditView[i]);
    1394           0 :             delete pEditView[i];
    1395           0 :             pEditView[i] = NULL;
    1396             :         }
    1397           1 : }
    1398             : 
    1399           0 : void ScViewData::GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCol, SCROW& rRow )
    1400             : {
    1401           0 :     rViewPtr = pEditView[eWhich];
    1402           0 :     rCol = nEditCol;
    1403           0 :     rRow = nEditRow;
    1404           0 : }
    1405             : 
    1406           1 : void ScViewData::CreateTabData( SCTAB nNewTab )
    1407             : {
    1408           1 :     EnsureTabDataSize(nNewTab + 1);
    1409             : 
    1410           1 :     if (!maTabData[nNewTab])
    1411             :     {
    1412           0 :         maTabData[nNewTab] = new ScViewDataTable;
    1413             : 
    1414           0 :         maTabData[nNewTab]->eZoomType  = eDefZoomType;
    1415           0 :         maTabData[nNewTab]->aZoomX     = aDefZoomX;
    1416           0 :         maTabData[nNewTab]->aZoomY     = aDefZoomY;
    1417           0 :         maTabData[nNewTab]->aPageZoomX = aDefPageZoomX;
    1418           0 :         maTabData[nNewTab]->aPageZoomY = aDefPageZoomY;
    1419             :     }
    1420           1 : }
    1421             : 
    1422           0 : void ScViewData::CreateSelectedTabData()
    1423             : {
    1424           0 :     ScMarkData::iterator itr = mpMarkData->begin(), itrEnd = mpMarkData->end();
    1425           0 :     for (; itr != itrEnd; ++itr)
    1426           0 :         CreateTabData(*itr);
    1427           0 : }
    1428             : 
    1429           1 : void ScViewData::EnsureTabDataSize(size_t nSize)
    1430             : {
    1431           1 :     if (nSize >= maTabData.size())
    1432             :     {
    1433           1 :         size_t n = nSize - maTabData.size() + 1;
    1434           1 :         maTabData.insert(maTabData.end(), n, NULL);
    1435             :     }
    1436           1 : }
    1437             : 
    1438           1 : void ScViewData::SetTabNo( SCTAB nNewTab )
    1439             : {
    1440           1 :     if (!ValidTab(nNewTab))
    1441             :     {
    1442             :         OSL_FAIL("falsche Tabellennummer");
    1443           1 :         return;
    1444             :     }
    1445             : 
    1446           1 :     nTabNo = nNewTab;
    1447           1 :     CreateTabData(nTabNo);
    1448           1 :     pThisTab = maTabData[nTabNo];
    1449             : 
    1450           1 :     CalcPPT();          //  for common column width correction
    1451           1 :     RecalcPixPos();     //! nicht immer noetig!
    1452             : }
    1453             : 
    1454           1 : void ScViewData::SetActivePart( ScSplitPos eNewActive )
    1455             : {
    1456           1 :     pThisTab->eWhichActive = eNewActive;
    1457           1 : }
    1458             : 
    1459           0 : Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const
    1460             : {
    1461             :     OSL_ENSURE( eWhich==SC_SPLIT_LEFT || eWhich==SC_SPLIT_RIGHT, "Falsche Position" );
    1462           0 :     ScSplitPos ePos = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
    1463           0 :     return GetScrPos( nWhereX, nWhereY, ePos );
    1464             : }
    1465             : 
    1466           0 : Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const
    1467             : {
    1468             :     OSL_ENSURE( eWhich==SC_SPLIT_TOP || eWhich==SC_SPLIT_BOTTOM, "Falsche Position" );
    1469           0 :     ScSplitPos ePos = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
    1470           0 :     return GetScrPos( nWhereX, nWhereY, ePos );
    1471             : }
    1472             : 
    1473           0 : Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
    1474             :                                 sal_Bool bAllowNeg ) const
    1475             : {
    1476           0 :     ScHSplitPos eWhichX = SC_SPLIT_LEFT;
    1477           0 :     ScVSplitPos eWhichY = SC_SPLIT_BOTTOM;
    1478           0 :     switch( eWhich )
    1479             :     {
    1480             :         case SC_SPLIT_TOPLEFT:
    1481           0 :             eWhichX = SC_SPLIT_LEFT;
    1482           0 :             eWhichY = SC_SPLIT_TOP;
    1483           0 :             break;
    1484             :         case SC_SPLIT_TOPRIGHT:
    1485           0 :             eWhichX = SC_SPLIT_RIGHT;
    1486           0 :             eWhichY = SC_SPLIT_TOP;
    1487           0 :             break;
    1488             :         case SC_SPLIT_BOTTOMLEFT:
    1489           0 :             eWhichX = SC_SPLIT_LEFT;
    1490           0 :             eWhichY = SC_SPLIT_BOTTOM;
    1491           0 :             break;
    1492             :         case SC_SPLIT_BOTTOMRIGHT:
    1493           0 :             eWhichX = SC_SPLIT_RIGHT;
    1494           0 :             eWhichY = SC_SPLIT_BOTTOM;
    1495           0 :             break;
    1496             :     }
    1497             : 
    1498           0 :     if (pView)
    1499             :     {
    1500           0 :         ((ScViewData*)this)->aScrSize.Width()  = pView->GetGridWidth(eWhichX);
    1501           0 :         ((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY);
    1502             :     }
    1503             : 
    1504             :     sal_uInt16 nTSize;
    1505             : 
    1506           0 :     SCCOL   nPosX = GetPosX(eWhichX);
    1507             :     SCCOL   nX;
    1508             : 
    1509           0 :     long nScrPosX=0;
    1510           0 :     if (nWhereX >= nPosX)
    1511           0 :         for (nX=nPosX; nX<nWhereX && (bAllowNeg || nScrPosX<=aScrSize.Width()); nX++)
    1512             :         {
    1513           0 :             if ( nX > MAXCOL )
    1514           0 :                 nScrPosX = 65535;
    1515             :             else
    1516             :             {
    1517           0 :                 nTSize = pDoc->GetColWidth( nX, nTabNo );
    1518           0 :                 if (nTSize)
    1519             :                 {
    1520           0 :                     long nSizeXPix = ToPixel( nTSize, nPPTX );
    1521           0 :                     nScrPosX += nSizeXPix;
    1522             :                 }
    1523             :             }
    1524             :         }
    1525           0 :     else if (bAllowNeg)
    1526           0 :         for (nX=nPosX; nX>nWhereX;)
    1527             :         {
    1528           0 :             --nX;
    1529           0 :             nTSize = pDoc->GetColWidth( nX, nTabNo );
    1530           0 :             if (nTSize)
    1531             :             {
    1532           0 :                 long nSizeXPix = ToPixel( nTSize, nPPTX );
    1533           0 :                 nScrPosX -= nSizeXPix;
    1534             :             }
    1535             :         }
    1536             : 
    1537           0 :     SCROW   nPosY = GetPosY(eWhichY);
    1538             :     SCROW   nY;
    1539             : 
    1540           0 :     long nScrPosY=0;
    1541           0 :     if (nWhereY >= nPosY)
    1542           0 :         for (nY=nPosY; nY<nWhereY && (bAllowNeg || nScrPosY<=aScrSize.Height()); nY++)
    1543             :         {
    1544           0 :             if ( nY > MAXROW )
    1545           0 :                 nScrPosY = 65535;
    1546             :             else
    1547             :             {
    1548           0 :                 nTSize = pDoc->GetRowHeight( nY, nTabNo );
    1549           0 :                 if (nTSize)
    1550             :                 {
    1551           0 :                     long nSizeYPix = ToPixel( nTSize, nPPTY );
    1552           0 :                     nScrPosY += nSizeYPix;
    1553             :                 }
    1554           0 :                 else if ( nY < MAXROW )
    1555             :                 {
    1556             :                     // skip multiple hidden rows (forward only for now)
    1557           0 :                     SCROW nNext = pDoc->FirstVisibleRow(nY + 1, MAXROW, nTabNo);
    1558           0 :                     if ( nNext > MAXROW )
    1559           0 :                         nY = MAXROW;
    1560             :                     else
    1561           0 :                         nY = nNext - 1;     // +=nDir advances to next visible row
    1562             :                 }
    1563             :             }
    1564             :         }
    1565           0 :     else if (bAllowNeg)
    1566           0 :         for (nY=nPosY; nY>nWhereY;)
    1567             :         {
    1568           0 :             --nY;
    1569           0 :             nTSize = pDoc->GetRowHeight( nY, nTabNo );
    1570           0 :             if (nTSize)
    1571             :             {
    1572           0 :                 long nSizeYPix = ToPixel( nTSize, nPPTY );
    1573           0 :                 nScrPosY -= nSizeYPix;
    1574             :             }
    1575             :         }
    1576             : 
    1577           0 :     if ( pDoc->IsLayoutRTL( nTabNo ) )
    1578             :     {
    1579             :         //  mirror horizontal position
    1580           0 :         nScrPosX = aScrSize.Width() - 1 - nScrPosX;
    1581             :     }
    1582             : 
    1583           0 :     if (nScrPosX > 32767) nScrPosX=32767;
    1584           0 :     if (nScrPosY > 32767) nScrPosY=32767;
    1585           0 :     return Point( nScrPosX, nScrPosY );
    1586             : }
    1587             : 
    1588             : //
    1589             : //      Number of cells on a screen
    1590             : //
    1591             : 
    1592           0 : SCCOL ScViewData::CellsAtX( SCsCOL nPosX, SCsCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeX ) const
    1593             : {
    1594             :     OSL_ENSURE( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" );
    1595             : 
    1596           0 :     if (pView)
    1597           0 :         ((ScViewData*)this)->aScrSize.Width()  = pView->GetGridWidth(eWhichX);
    1598             : 
    1599             :     SCsCOL  nX;
    1600           0 :     sal_uInt16  nScrPosX = 0;
    1601           0 :     if (nScrSizeX == SC_SIZE_NONE) nScrSizeX = (sal_uInt16) aScrSize.Width();
    1602             : 
    1603           0 :     if (nDir==1)
    1604           0 :         nX = nPosX;             // vorwaerts
    1605             :     else
    1606           0 :         nX = nPosX-1;           // rueckwaerts
    1607             : 
    1608           0 :     sal_Bool bOut = false;
    1609           0 :     for ( ; nScrPosX<=nScrSizeX && !bOut; nX = sal::static_int_cast<SCsCOL>(nX + nDir) )
    1610             :     {
    1611           0 :         SCsCOL  nColNo = nX;
    1612           0 :         if ( nColNo < 0 || nColNo > MAXCOL )
    1613           0 :             bOut = sal_True;
    1614             :         else
    1615             :         {
    1616           0 :             sal_uInt16 nTSize = pDoc->GetColWidth( nColNo, nTabNo );
    1617           0 :             if (nTSize)
    1618             :             {
    1619           0 :                 long nSizeXPix = ToPixel( nTSize, nPPTX );
    1620           0 :                 nScrPosX = sal::static_int_cast<sal_uInt16>( nScrPosX + (sal_uInt16) nSizeXPix );
    1621             :             }
    1622             :         }
    1623             :     }
    1624             : 
    1625           0 :     if (nDir==1)
    1626           0 :         nX = sal::static_int_cast<SCsCOL>( nX - nPosX );
    1627             :     else
    1628           0 :         nX = (nPosX-1)-nX;
    1629             : 
    1630           0 :     if (nX>0) --nX;
    1631           0 :     return nX;
    1632             : }
    1633             : 
    1634           0 : SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, sal_uInt16 nScrSizeY ) const
    1635             : {
    1636             :     OSL_ENSURE( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" );
    1637             : 
    1638           0 :     if (pView)
    1639           0 :         ((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY);
    1640             : 
    1641           0 :     if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = (sal_uInt16) aScrSize.Height();
    1642             : 
    1643             :     SCROW nY;
    1644             : 
    1645           0 :     if (nDir==1)
    1646             :     {
    1647             :         // forward
    1648           0 :         nY = nPosY;
    1649           0 :         long nScrPosY = 0;
    1650           0 :         AddPixelsWhile( nScrPosY, nScrSizeY, nY, MAXROW, nPPTY, pDoc, nTabNo);
    1651             :         // Original loop ended on last evaluated +1 or if that was MAXROW even
    1652             :         // on MAXROW+2.
    1653           0 :         nY += (nY == MAXROW ? 2 : 1);
    1654           0 :         nY -= nPosY;
    1655             :     }
    1656             :     else
    1657             :     {
    1658             :         // backward
    1659           0 :         nY = nPosY-1;
    1660           0 :         long nScrPosY = 0;
    1661           0 :         AddPixelsWhileBackward( nScrPosY, nScrSizeY, nY, 0, nPPTY, pDoc, nTabNo);
    1662             :         // Original loop ended on last evaluated -1 or if that was 0 even on
    1663             :         // -2.
    1664           0 :         nY -= (nY == 0 ? 2 : 1);
    1665           0 :         nY = (nPosY-1)-nY;
    1666             :     }
    1667             : 
    1668           0 :     if (nY>0) --nY;
    1669           0 :     return nY;
    1670             : }
    1671             : 
    1672           0 : SCCOL ScViewData::VisibleCellsX( ScHSplitPos eWhichX ) const
    1673             : {
    1674           0 :     return CellsAtX( GetPosX( eWhichX ), 1, eWhichX, SC_SIZE_NONE );
    1675             : }
    1676             : 
    1677           0 : SCROW ScViewData::VisibleCellsY( ScVSplitPos eWhichY ) const
    1678             : {
    1679           0 :     return CellsAtY( GetPosY( eWhichY ), 1, eWhichY, SC_SIZE_NONE );
    1680             : }
    1681             : 
    1682           0 : SCCOL ScViewData::PrevCellsX( ScHSplitPos eWhichX ) const
    1683             : {
    1684           0 :     return CellsAtX( GetPosX( eWhichX ), -1, eWhichX, SC_SIZE_NONE );
    1685             : }
    1686             : 
    1687           0 : SCROW ScViewData::PrevCellsY( ScVSplitPos eWhichY ) const
    1688             : {
    1689           0 :     return CellsAtY( GetPosY( eWhichY ), -1, eWhichY, SC_SIZE_NONE );
    1690             : }
    1691             : 
    1692             : 
    1693           0 : bool ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, long& rSizeXPix, long& rSizeYPix ) const
    1694             : {
    1695           0 :     const ScMergeAttr* pMerge = (const ScMergeAttr*) pDoc->GetAttr( nX,nY,nTabNo, ATTR_MERGE );
    1696           0 :     if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
    1697             :     {
    1698           0 :         long nOutWidth = 0;
    1699           0 :         long nOutHeight = 0;
    1700           0 :         SCCOL nCountX = pMerge->GetColMerge();
    1701           0 :         for (SCCOL i=0; i<nCountX; i++)
    1702           0 :             nOutWidth += ToPixel( pDoc->GetColWidth(nX+i,nTabNo), nPPTX );
    1703           0 :         SCROW nCountY = pMerge->GetRowMerge();
    1704             : 
    1705           0 :         for (SCROW nRow = nY; nRow <= nY+nCountY-1; ++nRow)
    1706             :         {
    1707           0 :             SCROW nLastRow = nRow;
    1708           0 :             if (pDoc->RowHidden(nRow, nTabNo, NULL, &nLastRow))
    1709             :             {
    1710           0 :                 nRow = nLastRow;
    1711           0 :                 continue;
    1712             :             }
    1713             : 
    1714           0 :             sal_uInt16 nHeight = pDoc->GetRowHeight(nRow, nTabNo);
    1715           0 :             nOutHeight += ToPixel(nHeight, nPPTY);
    1716             :         }
    1717             : 
    1718           0 :         rSizeXPix = nOutWidth;
    1719           0 :         rSizeYPix = nOutHeight;
    1720           0 :         return true;
    1721             :     }
    1722             :     else
    1723             :     {
    1724           0 :         rSizeXPix = ToPixel( pDoc->GetColWidth( nX, nTabNo ), nPPTX );
    1725           0 :         rSizeYPix = ToPixel( pDoc->GetRowHeight( nY, nTabNo ), nPPTY );
    1726           0 :         return false;
    1727             :     }
    1728             : }
    1729             : 
    1730           0 : sal_Bool ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich,
    1731             :                                         SCsCOL& rPosX, SCsROW& rPosY,
    1732             :                                         sal_Bool bTestMerge, sal_Bool bRepair, sal_Bool bNextIfLarge )
    1733             : {
    1734             :     //  special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
    1735             : 
    1736           0 :     ScHSplitPos eHWhich = WhichH(eWhich);
    1737           0 :     ScVSplitPos eVWhich = WhichV(eWhich);
    1738             : 
    1739           0 :     if ( pDoc->IsLayoutRTL( nTabNo ) )
    1740             :     {
    1741             :         //  mirror horizontal position
    1742           0 :         if (pView)
    1743           0 :             aScrSize.Width() = pView->GetGridWidth(eHWhich);
    1744           0 :         nClickX = aScrSize.Width() - 1 - nClickX;
    1745             :     }
    1746             : 
    1747           0 :     SCsCOL nStartPosX = GetPosX(eHWhich);
    1748           0 :     SCsROW nStartPosY = GetPosY(eVWhich);
    1749           0 :     rPosX = nStartPosX;
    1750           0 :     rPosY = nStartPosY;
    1751           0 :     long nScrX = 0;
    1752           0 :     long nScrY = 0;
    1753             : 
    1754           0 :     if (nClickX > 0)
    1755             :     {
    1756           0 :         while ( rPosX<=MAXCOL && nClickX >= nScrX )
    1757             :         {
    1758           0 :             nScrX += ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX );
    1759           0 :             ++rPosX;
    1760             :         }
    1761           0 :         --rPosX;
    1762             :     }
    1763             :     else
    1764             :     {
    1765           0 :         while ( rPosX>0 && nClickX < nScrX )
    1766             :         {
    1767           0 :             --rPosX;
    1768           0 :             nScrX -= ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX );
    1769             :         }
    1770             :     }
    1771             : 
    1772           0 :     if (nClickY > 0)
    1773           0 :         AddPixelsWhile( nScrY, nClickY, rPosY, MAXROW, nPPTY, pDoc, nTabNo );
    1774             :     else
    1775             :     {
    1776             :         /* TODO: could need some "SubPixelsWhileBackward" method */
    1777           0 :         while ( rPosY>0 && nClickY < nScrY )
    1778             :         {
    1779           0 :             --rPosY;
    1780           0 :             nScrY -= ToPixel( pDoc->GetRowHeight( rPosY, nTabNo ), nPPTY );
    1781             :         }
    1782             :     }
    1783             : 
    1784           0 :     if (bNextIfLarge)       //  zu grosse Zellen ?
    1785             :     {
    1786           0 :         if ( rPosX == nStartPosX && nClickX > 0 )
    1787             :         {
    1788           0 :             if (pView)
    1789           0 :                 aScrSize.Width() = pView->GetGridWidth(eHWhich);
    1790           0 :             if ( nClickX > aScrSize.Width() )
    1791           0 :                 ++rPosX;
    1792             :         }
    1793           0 :         if ( rPosY == nStartPosY && nClickY > 0 )
    1794             :         {
    1795           0 :             if (pView)
    1796           0 :                 aScrSize.Height() = pView->GetGridHeight(eVWhich);
    1797           0 :             if ( nClickY > aScrSize.Height() )
    1798           0 :                 ++rPosY;
    1799             :         }
    1800             :     }
    1801             : 
    1802           0 :     if (rPosX<0) rPosX=0;
    1803           0 :     if (rPosX>MAXCOL) rPosX=MAXCOL;
    1804           0 :     if (rPosY<0) rPosY=0;
    1805           0 :     if (rPosY>MAXROW) rPosY=MAXROW;
    1806             : 
    1807           0 :     if (bTestMerge)
    1808             :     {
    1809             :         //! public Methode um Position anzupassen
    1810             : 
    1811           0 :         SCCOL nOrigX = rPosX;
    1812           0 :         SCROW nOrigY = rPosY;
    1813           0 :         pDoc->SkipOverlapped(rPosX, rPosY, nTabNo);
    1814           0 :         bool bHOver = (nOrigX != rPosX);
    1815           0 :         bool bVOver = (nOrigY != rPosY);
    1816             : 
    1817           0 :         if ( bRepair && ( bHOver || bVOver ) )
    1818             :         {
    1819             :             const ScMergeAttr* pMerge = (const ScMergeAttr*)
    1820           0 :                                 pDoc->GetAttr( rPosX, rPosY, nTabNo, ATTR_MERGE );
    1821           0 :             if ( ( bHOver && pMerge->GetColMerge() <= 1 ) ||
    1822           0 :                  ( bVOver && pMerge->GetRowMerge() <= 1 ) )
    1823             :             {
    1824             :                 OSL_FAIL("Merge-Fehler gefunden");
    1825             : 
    1826           0 :                 pDoc->RemoveFlagsTab( 0,0, MAXCOL,MAXROW, nTabNo, SC_MF_HOR | SC_MF_VER );
    1827           0 :                 SCCOL nEndCol = MAXCOL;
    1828           0 :                 SCROW nEndRow = MAXROW;
    1829           0 :                 pDoc->ExtendMerge( 0,0, nEndCol,nEndRow, nTabNo, sal_True );
    1830           0 :                 if (pDocShell)
    1831           0 :                     pDocShell->PostPaint( ScRange(0,0,nTabNo,MAXCOL,MAXROW,nTabNo), PAINT_GRID );
    1832             :             }
    1833             :         }
    1834             :     }
    1835             : 
    1836           0 :     return false;
    1837             : }
    1838             : 
    1839           0 : void ScViewData::GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich,
    1840             :                                         SCsCOL nPosX, SCsROW nPosY, sal_Bool& rLeft, sal_Bool& rTop )
    1841             : {
    1842           0 :     sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTabNo );
    1843           0 :     long nLayoutSign = bLayoutRTL ? -1 : 1;
    1844             : 
    1845           0 :     Point aCellStart = GetScrPos( nPosX, nPosY, eWhich, sal_True );
    1846             :     long nSizeX;
    1847             :     long nSizeY;
    1848           0 :     GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY );
    1849           0 :     rLeft = ( rClickPos.X() - aCellStart.X() ) * nLayoutSign <= nSizeX / 2;
    1850           0 :     rTop  = rClickPos.Y() - aCellStart.Y() <= nSizeY / 2;
    1851           0 : }
    1852             : 
    1853           1 : void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX )
    1854             : {
    1855           1 :     if (nNewPosX != 0)
    1856             :     {
    1857           0 :         SCCOL nOldPosX = pThisTab->nPosX[eWhich];
    1858           0 :         long nTPosX = pThisTab->nTPosX[eWhich];
    1859           0 :         long nPixPosX = pThisTab->nPixPosX[eWhich];
    1860             :         SCCOL i;
    1861           0 :         if ( nNewPosX > nOldPosX )
    1862           0 :             for ( i=nOldPosX; i<nNewPosX; i++ )
    1863             :             {
    1864           0 :                 long nThis = pDoc->GetColWidth( i,nTabNo );
    1865           0 :                 nTPosX -= nThis;
    1866           0 :                 nPixPosX -= ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTX);
    1867             :             }
    1868             :         else
    1869           0 :             for ( i=nNewPosX; i<nOldPosX; i++ )
    1870             :             {
    1871           0 :                 long nThis = pDoc->GetColWidth( i,nTabNo );
    1872           0 :                 nTPosX += nThis;
    1873           0 :                 nPixPosX += ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTX);
    1874             :             }
    1875             : 
    1876           0 :         pThisTab->nPosX[eWhich] = nNewPosX;
    1877           0 :         pThisTab->nTPosX[eWhich] = nTPosX;
    1878           0 :         pThisTab->nMPosX[eWhich] = (long) (nTPosX * HMM_PER_TWIPS);
    1879           0 :         pThisTab->nPixPosX[eWhich] = nPixPosX;
    1880             :     }
    1881             :     else
    1882           1 :         pThisTab->nPixPosX[eWhich] =
    1883           2 :         pThisTab->nTPosX[eWhich] =
    1884           2 :         pThisTab->nMPosX[eWhich] =
    1885           4 :         pThisTab->nPosX[eWhich] = 0;
    1886           1 : }
    1887             : 
    1888           1 : void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY )
    1889             : {
    1890           1 :     if (nNewPosY != 0)
    1891             :     {
    1892           0 :         SCROW nOldPosY = pThisTab->nPosY[eWhich];
    1893           0 :         long nTPosY = pThisTab->nTPosY[eWhich];
    1894           0 :         long nPixPosY = pThisTab->nPixPosY[eWhich];
    1895             :         SCROW i, nHeightEndRow;
    1896           0 :         if ( nNewPosY > nOldPosY )
    1897           0 :             for ( i=nOldPosY; i<nNewPosY; i++ )
    1898             :             {
    1899           0 :                 long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow );
    1900           0 :                 SCROW nRows = std::min( nNewPosY, nHeightEndRow + 1) - i;
    1901           0 :                 i = nHeightEndRow;
    1902           0 :                 nTPosY -= nThis * nRows;
    1903           0 :                 nPixPosY -= ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTY) * nRows;
    1904             :             }
    1905             :         else
    1906           0 :             for ( i=nNewPosY; i<nOldPosY; i++ )
    1907             :             {
    1908           0 :                 long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow );
    1909           0 :                 SCROW nRows = std::min( nOldPosY, nHeightEndRow + 1) - i;
    1910           0 :                 i = nHeightEndRow;
    1911           0 :                 nTPosY += nThis * nRows;
    1912           0 :                 nPixPosY += ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTY) * nRows;
    1913             :             }
    1914             : 
    1915           0 :         pThisTab->nPosY[eWhich] = nNewPosY;
    1916           0 :         pThisTab->nTPosY[eWhich] = nTPosY;
    1917           0 :         pThisTab->nMPosY[eWhich] = (long) (nTPosY * HMM_PER_TWIPS);
    1918           0 :         pThisTab->nPixPosY[eWhich] = nPixPosY;
    1919             :     }
    1920             :     else
    1921           1 :         pThisTab->nPixPosY[eWhich] =
    1922           2 :         pThisTab->nTPosY[eWhich] =
    1923           2 :         pThisTab->nMPosY[eWhich] =
    1924           3 :         pThisTab->nPosY[eWhich] = 0;
    1925           1 : }
    1926             : 
    1927           1 : void ScViewData::RecalcPixPos()             // nach Zoom-Aenderungen
    1928             : {
    1929           3 :     for (sal_uInt16 eWhich=0; eWhich<2; eWhich++)
    1930             :     {
    1931           2 :         long nPixPosX = 0;
    1932           2 :         SCCOL nPosX = pThisTab->nPosX[eWhich];
    1933           2 :         for (SCCOL i=0; i<nPosX; i++)
    1934           0 :             nPixPosX -= ToPixel(pDoc->GetColWidth(i,nTabNo), nPPTX);
    1935           2 :         pThisTab->nPixPosX[eWhich] = nPixPosX;
    1936             : 
    1937           2 :         long nPixPosY = 0;
    1938           2 :         SCROW nPosY = pThisTab->nPosY[eWhich];
    1939           2 :         for (SCROW j=0; j<nPosY; j++)
    1940           0 :             nPixPosY -= ToPixel(pDoc->GetRowHeight(j,nTabNo), nPPTY);
    1941           2 :         pThisTab->nPixPosY[eWhich] = nPixPosY;
    1942             :     }
    1943           1 : }
    1944             : 
    1945           0 : const MapMode& ScViewData::GetLogicMode( ScSplitPos eWhich )
    1946             : {
    1947           0 :     aLogicMode.SetOrigin( Point( pThisTab->nMPosX[WhichH(eWhich)],
    1948           0 :                                     pThisTab->nMPosY[WhichV(eWhich)] ) );
    1949           0 :     return aLogicMode;
    1950             : }
    1951             : 
    1952           0 : const MapMode& ScViewData::GetLogicMode()
    1953             : {
    1954           0 :     aLogicMode.SetOrigin( Point() );
    1955           0 :     return aLogicMode;
    1956             : }
    1957             : 
    1958           0 : void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
    1959             : {
    1960             :     SCCOL nCol;
    1961             :     SCROW nRow;
    1962             :     sal_uInt16 nTSize;
    1963             :     long nSizePix;
    1964           0 :     long nScrPosX = 0;
    1965           0 :     long nScrPosY = 0;
    1966             : 
    1967           0 :     SetActivePart( SC_SPLIT_BOTTOMLEFT );
    1968           0 :     SetPosX( SC_SPLIT_LEFT, nCol1 );
    1969           0 :     SetPosY( SC_SPLIT_BOTTOM, nRow1 );
    1970             : 
    1971           0 :     for (nCol=nCol1; nCol<=nCol2; nCol++)
    1972             :     {
    1973           0 :         nTSize = pDoc->GetColWidth( nCol, nTabNo );
    1974           0 :         if (nTSize)
    1975             :         {
    1976           0 :             nSizePix = ToPixel( nTSize, nPPTX );
    1977           0 :             nScrPosX += (sal_uInt16) nSizePix;
    1978             :         }
    1979             :     }
    1980             : 
    1981           0 :     for (nRow=nRow1; nRow<=nRow2; nRow++)
    1982             :     {
    1983           0 :         nTSize = pDoc->GetRowHeight( nRow, nTabNo );
    1984           0 :         if (nTSize)
    1985             :         {
    1986           0 :             nSizePix = ToPixel( nTSize, nPPTY );
    1987           0 :             nScrPosY += (sal_uInt16) nSizePix;
    1988             :         }
    1989             :     }
    1990             : 
    1991           0 :     aScrSize = Size( nScrPosX, nScrPosY );
    1992           0 : }
    1993             : 
    1994           1 : void ScViewData::SetScreenPos( const Point& rVisAreaStart )
    1995             : {
    1996             :     long nSize;
    1997             :     long nTwips;
    1998             :     long nAdd;
    1999             :     sal_Bool bEnd;
    2000             : 
    2001           1 :     nSize = 0;
    2002           1 :     nTwips = (long) (rVisAreaStart.X() / HMM_PER_TWIPS);
    2003           1 :     if ( pDoc->IsLayoutRTL( nTabNo ) )
    2004           0 :         nTwips = -nTwips;
    2005           1 :     SCCOL nX1 = 0;
    2006           1 :     bEnd = false;
    2007           3 :     while (!bEnd)
    2008             :     {
    2009           1 :         nAdd = (long) pDoc->GetColWidth(nX1,nTabNo);
    2010           1 :         if (nSize+nAdd <= nTwips+1 && nX1<MAXCOL)
    2011             :         {
    2012           0 :             nSize += nAdd;
    2013           0 :             ++nX1;
    2014             :         }
    2015             :         else
    2016           1 :             bEnd = sal_True;
    2017             :     }
    2018             : 
    2019           1 :     nSize = 0;
    2020           1 :     nTwips = (long) (rVisAreaStart.Y() / HMM_PER_TWIPS);
    2021           1 :     SCROW nY1 = 0;
    2022           1 :     bEnd = false;
    2023           3 :     while (!bEnd)
    2024             :     {
    2025           1 :         nAdd = (long) pDoc->GetRowHeight(nY1,nTabNo);
    2026           1 :         if (nSize+nAdd <= nTwips+1 && nY1<MAXROW)
    2027             :         {
    2028           0 :             nSize += nAdd;
    2029           0 :             ++nY1;
    2030             :         }
    2031             :         else
    2032           1 :             bEnd = sal_True;
    2033             :     }
    2034             : 
    2035           1 :     SetActivePart( SC_SPLIT_BOTTOMLEFT );
    2036           1 :     SetPosX( SC_SPLIT_LEFT, nX1 );
    2037           1 :     SetPosY( SC_SPLIT_BOTTOM, nY1 );
    2038             : 
    2039           1 :     SetCurX( nX1 );
    2040           1 :     SetCurY( nY1 );
    2041           1 : }
    2042             : 
    2043           1 : void ScViewData::SetScreen( const Rectangle& rVisArea )
    2044             : {
    2045           1 :     SetScreenPos( rVisArea.TopLeft() );
    2046             : 
    2047             :     //  hier ohne GetOutputFactor(), weil fuer Ausgabe in Metafile
    2048             : 
    2049           1 :     aScrSize = rVisArea.GetSize();
    2050           1 :     aScrSize.Width() = (long)
    2051           1 :         ( aScrSize.Width() * ScGlobal::nScreenPPTX / HMM_PER_TWIPS );
    2052           1 :     aScrSize.Height() = (long)
    2053           1 :         ( aScrSize.Height() * ScGlobal::nScreenPPTY / HMM_PER_TWIPS );
    2054           1 : }
    2055             : 
    2056           0 : SfxObjectShell* ScViewData::GetSfxDocShell() const
    2057             : {
    2058           0 :     return pDocShell;
    2059             : }
    2060             : 
    2061           0 : ScDocFunc& ScViewData::GetDocFunc() const
    2062             : {
    2063           0 :     return pDocShell->GetDocFunc();
    2064             : }
    2065             : 
    2066           0 : SfxBindings& ScViewData::GetBindings()
    2067             : {
    2068             :     OSL_ENSURE( pViewShell, "GetBindings() without ViewShell" );
    2069           0 :     return pViewShell->GetViewFrame()->GetBindings();
    2070             : }
    2071             : 
    2072           0 : SfxDispatcher& ScViewData::GetDispatcher()
    2073             : {
    2074             :     OSL_ENSURE( pViewShell, "GetDispatcher() without ViewShell" );
    2075           0 :     return *pViewShell->GetViewFrame()->GetDispatcher();
    2076             : }
    2077             : 
    2078           0 : ScMarkData& ScViewData::GetMarkData()
    2079             : {
    2080           0 :     return *mpMarkData;
    2081             : }
    2082             : 
    2083           0 : const ScMarkData& ScViewData::GetMarkData() const
    2084             : {
    2085           0 :     return *mpMarkData;
    2086             : }
    2087             : 
    2088           0 : Window* ScViewData::GetDialogParent()
    2089             : {
    2090             :     OSL_ENSURE( pViewShell, "GetDialogParent() ohne ViewShell" );
    2091           0 :     return pViewShell->GetDialogParent();
    2092             : }
    2093             : 
    2094           0 : Window* ScViewData::GetActiveWin()
    2095             : {
    2096             :     OSL_ENSURE( pView, "GetActiveWin() ohne View" );
    2097           0 :     return pView->GetActiveWin();
    2098             : }
    2099             : 
    2100           0 : ScDrawView* ScViewData::GetScDrawView()
    2101             : {
    2102             :     OSL_ENSURE( pView, "GetScDrawView() ohne View" );
    2103           0 :     return pView->GetScDrawView();
    2104             : }
    2105             : 
    2106           0 : sal_Bool ScViewData::IsMinimized()
    2107             : {
    2108             :     OSL_ENSURE( pView, "IsMinimized() ohne View" );
    2109           0 :     return pView->IsMinimized();
    2110             : }
    2111             : 
    2112           0 : void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY )
    2113             : {
    2114           0 :     Fraction aOldX = GetZoomX();
    2115           0 :     Fraction aOldY = GetZoomY();
    2116             : 
    2117           0 :     SetZoom( rNewX, rNewY, false );
    2118             : 
    2119           0 :     Fraction aWidth = GetZoomX();
    2120           0 :     aWidth *= Fraction( aScrSize.Width(),1 );
    2121           0 :     aWidth /= aOldX;
    2122             : 
    2123           0 :     Fraction aHeight = GetZoomY();
    2124           0 :     aHeight *= Fraction( aScrSize.Height(),1 );
    2125           0 :     aHeight /= aOldY;
    2126             : 
    2127           0 :     aScrSize.Width()  = (long) aWidth;
    2128           0 :     aScrSize.Height() = (long) aHeight;
    2129           0 : }
    2130             : 
    2131           2 : void ScViewData::CalcPPT()
    2132             : {
    2133           2 :     nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX();
    2134           2 :     if (pDocShell)
    2135           2 :         nPPTX = nPPTX / pDocShell->GetOutputFactor();   // Faktor ist Drucker zu Bildschirm
    2136           2 :     nPPTY = ScGlobal::nScreenPPTY * (double) GetZoomY();
    2137             : 
    2138             :     //  if detective objects are present,
    2139             :     //  try to adjust horizontal scale so the most common column width has minimal rounding errors,
    2140             :     //  to avoid differences between cell and drawing layer output
    2141             : 
    2142           2 :     if ( pDoc && pDoc->HasDetectiveObjects(nTabNo) )
    2143             :     {
    2144           0 :         SCCOL nEndCol = 0;
    2145           0 :         SCROW nDummy = 0;
    2146           0 :         pDoc->GetTableArea( nTabNo, nEndCol, nDummy );
    2147           0 :         if (nEndCol<20)
    2148           0 :             nEndCol = 20;           // same end position as when determining draw scale
    2149             : 
    2150           0 :         sal_uInt16 nTwips = pDoc->GetCommonWidth( nEndCol, nTabNo );
    2151           0 :         if ( nTwips )
    2152             :         {
    2153           0 :             double fOriginal = nTwips * nPPTX;
    2154           0 :             if ( fOriginal < static_cast<double>(nEndCol) )
    2155             :             {
    2156             :                 //  if one column is smaller than the column count,
    2157             :                 //  rounding errors are likely to add up to a whole column.
    2158             : 
    2159           0 :                 double fRounded = ::rtl::math::approxFloor( fOriginal + 0.5 );
    2160           0 :                 if ( fRounded > 0.0 )
    2161             :                 {
    2162           0 :                     double fScale = fRounded / fOriginal + 1E-6;
    2163           0 :                     if ( fScale >= 0.9 && fScale <= 1.1 )
    2164           0 :                         nPPTX *= fScale;
    2165             :                 }
    2166             :             }
    2167             :         }
    2168             :     }
    2169           2 : }
    2170             : 
    2171             : #define SC_OLD_TABSEP   '/'
    2172             : #define SC_NEW_TABSEP   '+'
    2173             : 
    2174           0 : void ScViewData::WriteUserData(String& rData)
    2175             : {
    2176             :     //  nZoom (bis 364v) oder nZoom/nPageZoom/bPageMode (ab 364w)
    2177             :     //  nTab
    2178             :     //  Tab-ControlBreite
    2179             :     //  pro Tabelle:
    2180             :     //  CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/
    2181             :     //  PosX[links]/PosX[rechts]/PosY[oben]/PosY[unten]
    2182             :     //  wenn Zeilen groesser 8192, "+" statt "/"
    2183             : 
    2184           0 :     sal_uInt16 nZoom = (sal_uInt16)((pThisTab->aZoomY.GetNumerator() * 100) / pThisTab->aZoomY.GetDenominator());
    2185           0 :     rData = String::CreateFromInt32( nZoom );
    2186           0 :     rData += '/';
    2187           0 :     nZoom = (sal_uInt16)((pThisTab->aPageZoomY.GetNumerator() * 100) / pThisTab->aPageZoomY.GetDenominator());
    2188           0 :     rData += String::CreateFromInt32( nZoom );
    2189           0 :     rData += '/';
    2190           0 :     if (bPagebreak)
    2191           0 :         rData += '1';
    2192             :     else
    2193           0 :         rData += '0';
    2194             : 
    2195           0 :     rData += ';';
    2196           0 :     rData += String::CreateFromInt32( nTabNo );
    2197           0 :     rData += ';';
    2198           0 :     rData.AppendAscii(RTL_CONSTASCII_STRINGPARAM( TAG_TABBARWIDTH ));
    2199           0 :     rData += String::CreateFromInt32( pView->GetTabBarWidth() );
    2200             : 
    2201           0 :     SCTAB nTabCount = pDoc->GetTableCount();
    2202           0 :     for (SCTAB i=0; i<nTabCount; i++)
    2203             :     {
    2204           0 :         rData += ';';                   // Numerierung darf auf keinen Fall durcheinanderkommen
    2205           0 :         if (i < static_cast<SCTAB>(maTabData.size()) && maTabData[i])
    2206             :         {
    2207           0 :             sal_Unicode cTabSep = SC_OLD_TABSEP;                // wie 3.1
    2208           0 :             if ( maTabData[i]->nCurY > MAXROW_30 ||
    2209           0 :                  maTabData[i]->nPosY[0] > MAXROW_30 || maTabData[i]->nPosY[1] > MAXROW_30 ||
    2210           0 :                  ( maTabData[i]->eVSplitMode == SC_SPLIT_FIX &&
    2211           0 :                     maTabData[i]->nFixPosY > MAXROW_30 ) )
    2212             :             {
    2213           0 :                 cTabSep = SC_NEW_TABSEP;        // um eine 3.1-Version nicht umzubringen
    2214             :             }
    2215             : 
    2216             : 
    2217           0 :             rData += String::CreateFromInt32( maTabData[i]->nCurX );
    2218           0 :             rData += cTabSep;
    2219           0 :             rData += String::CreateFromInt32( maTabData[i]->nCurY );
    2220           0 :             rData += cTabSep;
    2221           0 :             rData += String::CreateFromInt32( maTabData[i]->eHSplitMode );
    2222           0 :             rData += cTabSep;
    2223           0 :             rData += String::CreateFromInt32( maTabData[i]->eVSplitMode );
    2224           0 :             rData += cTabSep;
    2225           0 :             if ( maTabData[i]->eHSplitMode == SC_SPLIT_FIX )
    2226           0 :                 rData += String::CreateFromInt32( maTabData[i]->nFixPosX );
    2227             :             else
    2228           0 :                 rData += String::CreateFromInt32( maTabData[i]->nHSplitPos );
    2229           0 :             rData += cTabSep;
    2230           0 :             if ( maTabData[i]->eVSplitMode == SC_SPLIT_FIX )
    2231           0 :                 rData += String::CreateFromInt32( maTabData[i]->nFixPosY );
    2232             :             else
    2233           0 :                 rData += String::CreateFromInt32( maTabData[i]->nVSplitPos );
    2234           0 :             rData += cTabSep;
    2235           0 :             rData += String::CreateFromInt32( maTabData[i]->eWhichActive );
    2236           0 :             rData += cTabSep;
    2237           0 :             rData += String::CreateFromInt32( maTabData[i]->nPosX[0] );
    2238           0 :             rData += cTabSep;
    2239           0 :             rData += String::CreateFromInt32( maTabData[i]->nPosX[1] );
    2240           0 :             rData += cTabSep;
    2241           0 :             rData += String::CreateFromInt32( maTabData[i]->nPosY[0] );
    2242           0 :             rData += cTabSep;
    2243           0 :             rData += String::CreateFromInt32( maTabData[i]->nPosY[1] );
    2244             :         }
    2245             :     }
    2246           0 : }
    2247             : 
    2248           0 : void ScViewData::ReadUserData(const String& rData)
    2249             : {
    2250           0 :     if (!rData.Len())       // Leerer String kommt bei "neu Laden"
    2251             :         return;             // dann auch ohne Assertion beenden
    2252             : 
    2253           0 :     xub_StrLen nCount = comphelper::string::getTokenCount(rData, ';');
    2254           0 :     if ( nCount <= 2 )
    2255             :     {
    2256             :         //  beim Reload in der Seitenansicht sind evtl. die Preview-UserData
    2257             :         //  stehengelassen worden. Den Zoom von der Preview will man hier nicht...
    2258             :         OSL_FAIL("ReadUserData: das sind nicht meine Daten");
    2259             :         return;
    2260             :     }
    2261             : 
    2262           0 :     String aTabOpt;
    2263           0 :     xub_StrLen nTagLen = RTL_CONSTASCII_LENGTH(TAG_TABBARWIDTH);
    2264             : 
    2265             :     // nicht pro Tabelle:
    2266           0 :     SCTAB nTabStart = 2;
    2267             : 
    2268           0 :     Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY;    //! evaluate (all sheets?)
    2269             : 
    2270           0 :     String aZoomStr = rData.GetToken(0);                        // Zoom/PageZoom/Modus
    2271           0 :     sal_uInt16 nNormZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.GetToken(0,'/').ToInt32());
    2272           0 :     if ( nNormZoom >= MINZOOM && nNormZoom <= MAXZOOM )
    2273           0 :         aZoomX = aZoomY = Fraction( nNormZoom, 100 );           //  "normaler" Zoom (immer)
    2274           0 :     sal_uInt16 nPageZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.GetToken(1,'/').ToInt32());
    2275           0 :     if ( nPageZoom >= MINZOOM && nPageZoom <= MAXZOOM )
    2276           0 :         aPageZoomX = aPageZoomY = Fraction( nPageZoom, 100 );   // Pagebreak-Zoom, wenn gesetzt
    2277           0 :     sal_Unicode cMode = aZoomStr.GetToken(2,'/').GetChar(0);    // 0 oder "0"/"1"
    2278           0 :     SetPagebreakMode( cMode == '1' );
    2279             :     // SetPagebreakMode muss immer gerufen werden wegen CalcPPT / RecalcPixPos()
    2280             : 
    2281             :     //
    2282             :     //  Tabelle kann ungueltig geworden sein (z.B. letzte Version):
    2283             :     //
    2284           0 :     SCTAB nNewTab = static_cast<SCTAB>(rData.GetToken(1).ToInt32());
    2285           0 :     if (pDoc->HasTable( nNewTab ))
    2286           0 :         SetTabNo(nNewTab);
    2287             : 
    2288             :     //
    2289             :     // wenn vorhanden, TabBar-Breite holen:
    2290             :     //
    2291           0 :     aTabOpt = rData.GetToken(2);
    2292             : 
    2293           0 :     if ( nTagLen && aTabOpt.Copy(0,nTagLen).EqualsAscii(TAG_TABBARWIDTH) )
    2294             :     {
    2295           0 :         pView->SetTabBarWidth( aTabOpt.Copy(nTagLen).ToInt32() );
    2296           0 :         nTabStart = 3;
    2297             :     }
    2298             : 
    2299             :     // pro Tabelle:
    2300           0 :     SCTAB nPos = 0;
    2301           0 :     while ( nCount > nPos+nTabStart )
    2302             :     {
    2303           0 :         aTabOpt = rData.GetToken(static_cast<xub_StrLen>(nPos+nTabStart));
    2304           0 :         EnsureTabDataSize(nPos + 1);
    2305           0 :         if (!maTabData[nPos])
    2306           0 :             maTabData[nPos] = new ScViewDataTable;
    2307             : 
    2308           0 :         sal_Unicode cTabSep = 0;
    2309           0 :         if (comphelper::string::getTokenCount(aTabOpt, SC_OLD_TABSEP) >= 11)
    2310           0 :             cTabSep = SC_OLD_TABSEP;
    2311             : #ifndef SC_LIMIT_ROWS
    2312           0 :         else if (comphelper::string::getTokenCount(aTabOpt, SC_NEW_TABSEP) >= 11)
    2313           0 :             cTabSep = SC_NEW_TABSEP;
    2314             :         // '+' ist nur erlaubt, wenn wir mit Zeilen > 8192 umgehen koennen
    2315             : #endif
    2316             : 
    2317           0 :         if (cTabSep)
    2318             :         {
    2319           0 :             maTabData[nPos]->nCurX = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(0,cTabSep).ToInt32()));
    2320           0 :             maTabData[nPos]->nCurY = SanitizeRow( aTabOpt.GetToken(1,cTabSep).ToInt32());
    2321           0 :             maTabData[nPos]->eHSplitMode = (ScSplitMode) aTabOpt.GetToken(2,cTabSep).ToInt32();
    2322           0 :             maTabData[nPos]->eVSplitMode = (ScSplitMode) aTabOpt.GetToken(3,cTabSep).ToInt32();
    2323             : 
    2324           0 :             if ( maTabData[nPos]->eHSplitMode == SC_SPLIT_FIX )
    2325             :             {
    2326           0 :                 maTabData[nPos]->nFixPosX = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(4,cTabSep).ToInt32()));
    2327           0 :                 UpdateFixX(nPos);
    2328             :             }
    2329             :             else
    2330           0 :                 maTabData[nPos]->nHSplitPos = aTabOpt.GetToken(4,cTabSep).ToInt32();
    2331             : 
    2332           0 :             if ( maTabData[nPos]->eVSplitMode == SC_SPLIT_FIX )
    2333             :             {
    2334           0 :                 maTabData[nPos]->nFixPosY = SanitizeRow( aTabOpt.GetToken(5,cTabSep).ToInt32());
    2335           0 :                 UpdateFixY(nPos);
    2336             :             }
    2337             :             else
    2338           0 :                 maTabData[nPos]->nVSplitPos = aTabOpt.GetToken(5,cTabSep).ToInt32();
    2339             : 
    2340           0 :             maTabData[nPos]->eWhichActive = (ScSplitPos) aTabOpt.GetToken(6,cTabSep).ToInt32();
    2341           0 :             maTabData[nPos]->nPosX[0] = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(7,cTabSep).ToInt32()));
    2342           0 :             maTabData[nPos]->nPosX[1] = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(8,cTabSep).ToInt32()));
    2343           0 :             maTabData[nPos]->nPosY[0] = SanitizeRow( aTabOpt.GetToken(9,cTabSep).ToInt32());
    2344           0 :             maTabData[nPos]->nPosY[1] = SanitizeRow( aTabOpt.GetToken(10,cTabSep).ToInt32());
    2345             : 
    2346             :             //  Test, ob der aktive Teil laut SplitMode ueberhaupt existiert
    2347             :             //  (Bug #44516#)
    2348           0 :             ScSplitPos eTest = maTabData[nPos]->eWhichActive;
    2349           0 :             if ( ( WhichH( eTest ) == SC_SPLIT_RIGHT &&
    2350           0 :                     maTabData[nPos]->eHSplitMode == SC_SPLIT_NONE ) ||
    2351           0 :                  ( WhichV( eTest ) == SC_SPLIT_TOP &&
    2352           0 :                     maTabData[nPos]->eVSplitMode == SC_SPLIT_NONE ) )
    2353             :             {
    2354             :                 //  dann wieder auf Default (unten links)
    2355           0 :                 maTabData[nPos]->eWhichActive = SC_SPLIT_BOTTOMLEFT;
    2356             :                 OSL_FAIL("SplitPos musste korrigiert werden");
    2357             :             }
    2358             :         }
    2359           0 :         ++nPos;
    2360             :     }
    2361             : 
    2362           0 :     RecalcPixPos();
    2363             : }
    2364             : 
    2365           0 : void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const
    2366             : {
    2367             :     // *** Fill extended document data for export filters ***
    2368             : 
    2369             :     // document settings
    2370           0 :     ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
    2371             : 
    2372             :     // displayed sheet
    2373           0 :     rDocSett.mnDisplTab = GetTabNo();
    2374             : 
    2375             :     // width of the tabbar, relative to frame window width
    2376           0 :     rDocSett.mfTabBarWidth = pView->GetPendingRelTabBarWidth();
    2377           0 :     if( rDocSett.mfTabBarWidth < 0.0 )
    2378           0 :         rDocSett.mfTabBarWidth = pView->GetRelTabBarWidth();
    2379             : 
    2380             :     // sheet settings
    2381           0 :     for( SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabData.size()); ++nTab )
    2382             :     {
    2383           0 :         if( const ScViewDataTable* pViewTab = maTabData[ nTab ] )
    2384             :         {
    2385           0 :             ScExtTabSettings& rTabSett = rDocOpt.GetOrCreateTabSettings( nTab );
    2386             : 
    2387             :             // split mode
    2388           0 :             ScSplitMode eHSplit = pViewTab->eHSplitMode;
    2389           0 :             ScSplitMode eVSplit = pViewTab->eVSplitMode;
    2390           0 :             bool bHSplit = eHSplit != SC_SPLIT_NONE;
    2391           0 :             bool bVSplit = eVSplit != SC_SPLIT_NONE;
    2392           0 :             bool bRealSplit = (eHSplit == SC_SPLIT_NORMAL) || (eVSplit == SC_SPLIT_NORMAL);
    2393           0 :             bool bFrozen    = (eHSplit == SC_SPLIT_FIX)    || (eVSplit == SC_SPLIT_FIX);
    2394             :             OSL_ENSURE( !bRealSplit || !bFrozen, "ScViewData::WriteExtOptions - split and freeze in same sheet" );
    2395           0 :             rTabSett.mbFrozenPanes = !bRealSplit && bFrozen;
    2396             : 
    2397             :             // split and freeze position
    2398           0 :             rTabSett.maSplitPos = Point( 0, 0 );
    2399           0 :             rTabSett.maFreezePos.Set( 0, 0, nTab );
    2400           0 :             if( bRealSplit )
    2401             :             {
    2402           0 :                 Point& rSplitPos = rTabSett.maSplitPos;
    2403           0 :                 rSplitPos = Point( bHSplit ? pViewTab->nHSplitPos : 0, bVSplit ? pViewTab->nVSplitPos : 0 );
    2404           0 :                 rSplitPos = Application::GetDefaultDevice()->PixelToLogic( rSplitPos, MapMode( MAP_TWIP ) );
    2405           0 :                 if( pDocShell )
    2406           0 :                     rSplitPos.X() = (long)((double)rSplitPos.X() / pDocShell->GetOutputFactor());
    2407             :             }
    2408           0 :             else if( bFrozen )
    2409             :             {
    2410           0 :                 if( bHSplit ) rTabSett.maFreezePos.SetCol( pViewTab->nFixPosX );
    2411           0 :                 if( bVSplit ) rTabSett.maFreezePos.SetRow( pViewTab->nFixPosY );
    2412             :             }
    2413             : 
    2414             :             // first visible cell in top-left and additional panes
    2415           0 :             rTabSett.maFirstVis.Set( pViewTab->nPosX[ SC_SPLIT_LEFT ], pViewTab->nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ], nTab );
    2416           0 :             rTabSett.maSecondVis.Set( pViewTab->nPosX[ SC_SPLIT_RIGHT ], pViewTab->nPosY[ SC_SPLIT_BOTTOM ], nTab );
    2417             : 
    2418             :             // active pane
    2419           0 :             switch( pViewTab->eWhichActive )
    2420             :             {
    2421             :                 // no horizontal split -> always use left panes
    2422             :                 // no vertical split -> always use top panes
    2423             :                 case SC_SPLIT_TOPLEFT:
    2424           0 :                     rTabSett.meActivePane = SCEXT_PANE_TOPLEFT;
    2425           0 :                 break;
    2426             :                 case SC_SPLIT_TOPRIGHT:
    2427           0 :                     rTabSett.meActivePane = bHSplit ? SCEXT_PANE_TOPRIGHT : SCEXT_PANE_TOPLEFT;
    2428           0 :                 break;
    2429             :                 case SC_SPLIT_BOTTOMLEFT:
    2430           0 :                     rTabSett.meActivePane = bVSplit ? SCEXT_PANE_BOTTOMLEFT : SCEXT_PANE_TOPLEFT;
    2431           0 :                 break;
    2432             :                 case SC_SPLIT_BOTTOMRIGHT:
    2433             :                     rTabSett.meActivePane = bHSplit ?
    2434             :                         (bVSplit ? SCEXT_PANE_BOTTOMRIGHT : SCEXT_PANE_TOPRIGHT) :
    2435           0 :                         (bVSplit ? SCEXT_PANE_BOTTOMLEFT : SCEXT_PANE_TOPLEFT);
    2436           0 :                 break;
    2437             :             }
    2438             : 
    2439             :             // cursor position
    2440           0 :             rTabSett.maCursor.Set( pViewTab->nCurX, pViewTab->nCurY, nTab );
    2441             : 
    2442             :             // sheet selection and selected ranges
    2443           0 :             const ScMarkData& rMarkData = GetMarkData();
    2444           0 :             rTabSett.mbSelected = rMarkData.GetTableSelect( nTab );
    2445           0 :             rMarkData.FillRangeListWithMarks( &rTabSett.maSelection, sal_True );
    2446             : 
    2447             :             // grid color
    2448           0 :             rTabSett.maGridColor.SetColor( COL_AUTO );
    2449           0 :             if( pOptions )
    2450             :             {
    2451           0 :                 const Color& rGridColor = pOptions->GetGridColor();
    2452           0 :                 if( rGridColor.GetColor() != SC_STD_GRIDCOLOR )
    2453           0 :                     rTabSett.maGridColor = rGridColor;
    2454             :             }
    2455           0 :             rTabSett.mbShowGrid = pViewTab->bShowGrid;
    2456             : 
    2457             :             // view mode and zoom
    2458           0 :             rTabSett.mbPageMode = bPagebreak;
    2459           0 :             rTabSett.mnNormalZoom = static_cast< long >( pViewTab->aZoomY * Fraction( 100.0 ) );
    2460           0 :             rTabSett.mnPageZoom = static_cast< long >( pViewTab->aPageZoomY * Fraction( 100.0 ) );
    2461             :         }
    2462             :     }
    2463           0 : }
    2464             : 
    2465           0 : void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt )
    2466             : {
    2467             :     // *** Get extended document data from import filters ***
    2468             : 
    2469           0 :     if( !rDocOpt.IsChanged() ) return;
    2470             : 
    2471             :     // document settings
    2472           0 :     const ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
    2473             : 
    2474             :     // displayed sheet
    2475           0 :     SetTabNo( rDocSett.mnDisplTab );
    2476             : 
    2477             :     /*  Width of the tabbar, relative to frame window width. We do not have the
    2478             :         correct width of the frame window here -> store in ScTabView, which sets
    2479             :         the size in the next resize. */
    2480           0 :     pView->SetPendingRelTabBarWidth( rDocSett.mfTabBarWidth );
    2481             : 
    2482             :     // sheet settings
    2483           0 :     for( SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabData.size()); ++nTab )
    2484             :     {
    2485           0 :         if( const ScExtTabSettings* pTabSett = rDocOpt.GetTabSettings( nTab ) )
    2486             :         {
    2487           0 :             if( !maTabData[ nTab ] )
    2488           0 :                 maTabData[ nTab ] = new ScViewDataTable;
    2489             : 
    2490           0 :             const ScExtTabSettings& rTabSett = *pTabSett;
    2491           0 :             ScViewDataTable& rViewTab = *maTabData[ nTab ];
    2492             : 
    2493             :             // split mode initialization
    2494           0 :             bool bFrozen = rTabSett.mbFrozenPanes;
    2495           0 :             bool bHSplit = bFrozen ? (rTabSett.maFreezePos.Col() > 0) : (rTabSett.maSplitPos.X() > 0);
    2496           0 :             bool bVSplit = bFrozen ? (rTabSett.maFreezePos.Row() > 0) : (rTabSett.maSplitPos.Y() > 0);
    2497             : 
    2498             :             // first visible cell of top-left pane and additional panes
    2499           0 :             rViewTab.nPosX[ SC_SPLIT_LEFT ] = rTabSett.maFirstVis.Col();
    2500           0 :             rViewTab.nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ] = rTabSett.maFirstVis.Row();
    2501           0 :             if( bHSplit ) rViewTab.nPosX[ SC_SPLIT_RIGHT ] = rTabSett.maSecondVis.Col();
    2502           0 :             if( bVSplit ) rViewTab.nPosY[ SC_SPLIT_BOTTOM ] = rTabSett.maSecondVis.Row();
    2503             : 
    2504             :             // split mode, split and freeze position
    2505           0 :             rViewTab.eHSplitMode = rViewTab.eVSplitMode = SC_SPLIT_NONE;
    2506           0 :             rViewTab.nHSplitPos = rViewTab.nVSplitPos = 0;
    2507           0 :             rViewTab.nFixPosX = 0;
    2508           0 :             rViewTab.nFixPosY = 0;
    2509           0 :             if( bFrozen )
    2510             :             {
    2511           0 :                 if( bHSplit )
    2512             :                 {
    2513           0 :                     rViewTab.eHSplitMode = SC_SPLIT_FIX;
    2514           0 :                     rViewTab.nFixPosX = rTabSett.maFreezePos.Col();
    2515           0 :                     UpdateFixX( nTab );
    2516             :                 }
    2517           0 :                 if( bVSplit )
    2518             :                 {
    2519           0 :                     rViewTab.eVSplitMode = SC_SPLIT_FIX;
    2520           0 :                     rViewTab.nFixPosY = rTabSett.maFreezePos.Row();
    2521           0 :                     UpdateFixY( nTab );
    2522             :                 }
    2523             :             }
    2524             :             else
    2525             :             {
    2526             :                 Point aPixel = Application::GetDefaultDevice()->LogicToPixel(
    2527           0 :                                 rTabSett.maSplitPos, MapMode( MAP_TWIP ) );  //! Zoom?
    2528             :                 // the test for use of printer metrics for text formatting here
    2529             :                 // effectively results in the nFactor = 1.0 regardless of the Option setting.
    2530           0 :                 if( pDocShell && SC_MOD()->GetInputOptions().GetTextWysiwyg())
    2531             :                 {
    2532           0 :                     double nFactor = pDocShell->GetOutputFactor();
    2533           0 :                     aPixel.X() = (long)( aPixel.X() * nFactor + 0.5 );
    2534             :                 }
    2535           0 :                 if( bHSplit )
    2536             :                 {
    2537           0 :                     rViewTab.eHSplitMode = SC_SPLIT_NORMAL;
    2538           0 :                     rViewTab.nHSplitPos = aPixel.X();
    2539             :                 }
    2540           0 :                 if( bVSplit )
    2541             :                 {
    2542           0 :                     rViewTab.eVSplitMode = SC_SPLIT_NORMAL;
    2543           0 :                     rViewTab.nVSplitPos = aPixel.Y();
    2544             :                 }
    2545             :             }
    2546             : 
    2547             :             // active pane
    2548           0 :             ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
    2549           0 :             switch( rTabSett.meActivePane )
    2550             :             {
    2551             :                 // no horizontal split -> always use left panes
    2552             :                 // no vertical split -> always use *bottom* panes
    2553             :                 case SCEXT_PANE_TOPLEFT:
    2554           0 :                     ePos = bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
    2555           0 :                 break;
    2556             :                 case SCEXT_PANE_TOPRIGHT:
    2557             :                     ePos = bHSplit ?
    2558             :                         (bVSplit ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT) :
    2559           0 :                         (bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT);
    2560           0 :                 break;
    2561             :                 case SCEXT_PANE_BOTTOMLEFT:
    2562           0 :                     ePos = SC_SPLIT_BOTTOMLEFT;
    2563           0 :                 break;
    2564             :                 case SCEXT_PANE_BOTTOMRIGHT:
    2565           0 :                     ePos = bHSplit ? SC_SPLIT_BOTTOMRIGHT : SC_SPLIT_BOTTOMLEFT;
    2566           0 :                 break;
    2567             :             }
    2568           0 :             rViewTab.eWhichActive = ePos;
    2569             : 
    2570             :             // cursor position
    2571           0 :             const ScAddress& rCursor = rTabSett.maCursor;
    2572           0 :             if( rCursor.IsValid() )
    2573             :             {
    2574           0 :                 rViewTab.nCurX = rCursor.Col();
    2575           0 :                 rViewTab.nCurY = rCursor.Row();
    2576             :             }
    2577             : 
    2578             :             // sheet selection and selected ranges
    2579           0 :             ScMarkData& rMarkData = GetMarkData();
    2580           0 :             rMarkData.SelectTable( nTab, rTabSett.mbSelected );
    2581             : 
    2582             :             // zoom for each sheet
    2583           0 :             if( rTabSett.mnNormalZoom )
    2584           0 :                 rViewTab.aZoomX = rViewTab.aZoomY = Fraction( rTabSett.mnNormalZoom, 100L );
    2585           0 :             if( rTabSett.mnPageZoom )
    2586           0 :                 rViewTab.aPageZoomX = rViewTab.aPageZoomY = Fraction( rTabSett.mnPageZoom, 100L );
    2587             : 
    2588           0 :             rViewTab.bShowGrid = rTabSett.mbShowGrid;
    2589             : 
    2590             :             // get some settings from displayed Excel sheet, set at Calc document
    2591           0 :             if( nTab == GetTabNo() )
    2592             :             {
    2593             :                 // grid color -- #i47435# set automatic grid color explicitly
    2594           0 :                 if( pOptions )
    2595             :                 {
    2596           0 :                     Color aGridColor( rTabSett.maGridColor );
    2597           0 :                     if( aGridColor.GetColor() == COL_AUTO )
    2598           0 :                         aGridColor.SetColor( SC_STD_GRIDCOLOR );
    2599           0 :                     pOptions->SetGridColor( aGridColor, EMPTY_STRING );
    2600             :                 }
    2601             : 
    2602             :                 // view mode and default zoom (for new sheets) from current sheet
    2603           0 :                 if( rTabSett.mnNormalZoom )
    2604           0 :                     aDefZoomX = aDefZoomY = Fraction( rTabSett.mnNormalZoom, 100L );
    2605           0 :                 if( rTabSett.mnPageZoom )
    2606           0 :                     aDefPageZoomX = aDefPageZoomY = Fraction( rTabSett.mnPageZoom, 100L );
    2607             :                 /*  #i46820# set pagebreak mode via SetPagebreakMode(), this will
    2608             :                     update map modes that are needed to draw text correctly. */
    2609           0 :                 SetPagebreakMode( rTabSett.mbPageMode );
    2610             :             }
    2611             :         }
    2612             :     }
    2613             : 
    2614             :     // RecalcPixPos oder so - auch nMPos - auch bei ReadUserData ??!?!
    2615             : }
    2616             : 
    2617           0 : void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings) const
    2618             : {
    2619           0 :     rSettings.realloc(SC_VIEWSETTINGS_COUNT);
    2620             :     // + 1, because we have to put the view id in the sequence
    2621           0 :     beans::PropertyValue* pSettings = rSettings.getArray();
    2622           0 :     if (pSettings)
    2623             :     {
    2624           0 :         sal_uInt16 nViewID(pViewShell->GetViewFrame()->GetCurViewId());
    2625           0 :         pSettings[SC_VIEW_ID].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEWID));
    2626           0 :         rtl::OUStringBuffer sBuffer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEW)));
    2627             :         ::sax::Converter::convertNumber(sBuffer,
    2628           0 :                 static_cast<sal_Int32>(nViewID));
    2629           0 :         pSettings[SC_VIEW_ID].Value <<= sBuffer.makeStringAndClear();
    2630             : 
    2631             :         uno::Reference<lang::XMultiServiceFactory> xServiceFactory =
    2632           0 :                                         comphelper::getProcessServiceFactory();
    2633             :         OSL_ENSURE( xServiceFactory.is(), "got no service manager" );
    2634           0 :         if( xServiceFactory.is() )
    2635             :         {
    2636           0 :             rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.NamedPropertyValues"));
    2637           0 :             uno::Reference<container::XNameContainer> xNameContainer = uno::Reference<container::XNameContainer>(xServiceFactory->createInstance(sName), uno::UNO_QUERY);
    2638           0 :             if (xNameContainer.is())
    2639             :             {
    2640           0 :                 for (SCTAB nTab=0; nTab<static_cast<SCTAB>(maTabData.size()); nTab++)
    2641             :                 {
    2642           0 :                     if (maTabData[nTab])
    2643             :                     {
    2644           0 :                         uno::Sequence <beans::PropertyValue> aTableViewSettings;
    2645           0 :                         maTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this, nTab);
    2646           0 :                         rtl::OUString sTabName;
    2647           0 :                         GetDocument()->GetName( nTab, sTabName );
    2648           0 :                         uno::Any aAny;
    2649           0 :                         aAny <<= aTableViewSettings;
    2650             :                         try
    2651             :                         {
    2652           0 :                             xNameContainer->insertByName(sTabName, aAny);
    2653             :                         }
    2654             :                         //#101739#; two tables with the same name are possible
    2655           0 :                         catch ( container::ElementExistException& )
    2656             :                         {
    2657             :                             OSL_FAIL("seems there are two tables with the same name");
    2658             :                         }
    2659           0 :                         catch ( uno::RuntimeException& )
    2660             :                         {
    2661             :                             OSL_FAIL("something went wrong");
    2662           0 :                         }
    2663             :                     }
    2664             :                 }
    2665           0 :                 pSettings[SC_TABLE_VIEWSETTINGS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLES));
    2666           0 :                 pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer;
    2667           0 :             }
    2668             :         }
    2669             : 
    2670           0 :         rtl::OUString sName;
    2671           0 :         GetDocument()->GetName( nTabNo, sName );
    2672           0 :         pSettings[SC_ACTIVE_TABLE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE));
    2673           0 :         pSettings[SC_ACTIVE_TABLE].Value <<= sName;
    2674           0 :         pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSCROLLBARWIDTH));
    2675           0 :         pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Value <<= sal_Int32(pView->GetTabBarWidth());
    2676           0 :         sal_Int32 nZoomValue ((pThisTab->aZoomY.GetNumerator() * 100) / pThisTab->aZoomY.GetDenominator());
    2677           0 :         sal_Int32 nPageZoomValue ((pThisTab->aPageZoomY.GetNumerator() * 100) / pThisTab->aPageZoomY.GetDenominator());
    2678           0 :         pSettings[SC_ZOOM_TYPE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMTYPE));
    2679           0 :         pSettings[SC_ZOOM_TYPE].Value <<= sal_Int16(pThisTab->eZoomType);
    2680           0 :         pSettings[SC_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE));
    2681           0 :         pSettings[SC_ZOOM_VALUE].Value <<= nZoomValue;
    2682           0 :         pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE));
    2683           0 :         pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
    2684           0 :         pSettings[SC_PAGE_BREAK_PREVIEW].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_SHOWPAGEBREAKPREVIEW));
    2685           0 :         ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_PAGE_BREAK_PREVIEW].Value, bPagebreak);
    2686             : 
    2687           0 :         if (pOptions)
    2688             :         {
    2689           0 :             pSettings[SC_SHOWZERO].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWZERO));
    2690           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWZERO].Value, pOptions->GetOption( VOPT_NULLVALS ) );
    2691           0 :             pSettings[SC_SHOWNOTES].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWNOTES));
    2692           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWNOTES].Value, pOptions->GetOption( VOPT_NOTES ) );
    2693           0 :             pSettings[SC_SHOWGRID].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWGRID));
    2694           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWGRID].Value, pOptions->GetOption( VOPT_GRID ) );
    2695           0 :             pSettings[SC_GRIDCOLOR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_GRIDCOLOR));
    2696           0 :             String aColorName;
    2697           0 :             Color aColor = pOptions->GetGridColor(&aColorName);
    2698           0 :             pSettings[SC_GRIDCOLOR].Value <<= static_cast<sal_Int64>(aColor.GetColor());
    2699           0 :             pSettings[SC_SHOWPAGEBR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWPAGEBR));
    2700           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWPAGEBR].Value, pOptions->GetOption( VOPT_PAGEBREAKS ) );
    2701           0 :             pSettings[SC_COLROWHDR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_COLROWHDR));
    2702           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_COLROWHDR].Value, pOptions->GetOption( VOPT_HEADER ) );
    2703           0 :             pSettings[SC_SHEETTABS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHEETTABS));
    2704           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHEETTABS].Value, pOptions->GetOption( VOPT_TABCONTROLS ) );
    2705           0 :             pSettings[SC_OUTLSYMB].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_OUTLSYMB));
    2706           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_OUTLSYMB].Value, pOptions->GetOption( VOPT_OUTLINER ) );
    2707             : 
    2708           0 :             const ScGridOptions& aGridOpt = pOptions->GetGridOptions();
    2709           0 :             pSettings[SC_SNAPTORASTER].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SNAPTORASTER));
    2710           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SNAPTORASTER].Value, aGridOpt.GetUseGridSnap() );
    2711           0 :             pSettings[SC_RASTERVIS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERVIS));
    2712           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_RASTERVIS].Value, aGridOpt.GetGridVisible() );
    2713           0 :             pSettings[SC_RASTERRESX].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESX));
    2714           0 :             pSettings[SC_RASTERRESX].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawX() );
    2715           0 :             pSettings[SC_RASTERRESY].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESY));
    2716           0 :             pSettings[SC_RASTERRESY].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawY() );
    2717           0 :             pSettings[SC_RASTERSUBX].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBX));
    2718           0 :             pSettings[SC_RASTERSUBX].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionX() );
    2719           0 :             pSettings[SC_RASTERSUBY].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBY));
    2720           0 :             pSettings[SC_RASTERSUBY].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionY() );
    2721           0 :             pSettings[SC_RASTERSYNC].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSYNC));
    2722           0 :             ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_RASTERSYNC].Value, aGridOpt.GetSynchronize() );
    2723           0 :         }
    2724             :     }
    2725           0 : }
    2726             : 
    2727           0 : void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& rSettings)
    2728             : {
    2729           0 :     Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY;    //! evaluate (all sheets?)
    2730             : 
    2731           0 :     std::vector<bool> aHasZoomVect( GetDocument()->GetTableCount(), false );
    2732             : 
    2733           0 :     sal_Int32 nCount(rSettings.getLength());
    2734           0 :     sal_Int32 nTemp32(0);
    2735           0 :     sal_Int16 nTemp16(0);
    2736           0 :     sal_Bool bPageMode(false);
    2737             : 
    2738           0 :     EnsureTabDataSize(GetDocument()->GetTableCount()-1);
    2739             : 
    2740           0 :     for (sal_Int32 i = 0; i < nCount; i++)
    2741             :     {
    2742             :         // SC_VIEWID has to parse and use by mba
    2743           0 :         rtl::OUString sName(rSettings[i].Name);
    2744           0 :         if (sName.compareToAscii(SC_TABLES) == 0)
    2745             :         {
    2746           0 :             uno::Reference<container::XNameContainer> xNameContainer;
    2747           0 :             if ((rSettings[i].Value >>= xNameContainer) && xNameContainer->hasElements())
    2748             :             {
    2749           0 :                 uno::Sequence< rtl::OUString > aNames(xNameContainer->getElementNames());
    2750           0 :                 for (sal_Int32 nTabPos = 0; nTabPos < aNames.getLength(); nTabPos++)
    2751             :                 {
    2752           0 :                     String sTabName(aNames[nTabPos]);
    2753           0 :                     SCTAB nTab(0);
    2754           0 :                     if (GetDocument()->GetTable(sTabName, nTab))
    2755             :                     {
    2756           0 :                         uno::Any aAny = xNameContainer->getByName(aNames[nTabPos]);
    2757           0 :                         uno::Sequence<beans::PropertyValue> aTabSettings;
    2758           0 :                         if (aAny >>= aTabSettings)
    2759             :                         {
    2760           0 :                             EnsureTabDataSize(nTab + 1);
    2761           0 :                             if (!maTabData[nTab])
    2762           0 :                                 maTabData[nTab] = new ScViewDataTable;
    2763             : 
    2764           0 :                             bool bHasZoom = false;
    2765           0 :                             maTabData[nTab]->ReadUserDataSequence(aTabSettings, *this, nTab, bHasZoom);
    2766           0 :                             aHasZoomVect[nTab] = bHasZoom;
    2767           0 :                         }
    2768             :                     }
    2769           0 :                 }
    2770           0 :             }
    2771             :         }
    2772           0 :         else if (sName.compareToAscii(SC_ACTIVETABLE) == 0)
    2773             :         {
    2774           0 :             rtl::OUString sValue;
    2775           0 :             if(rSettings[i].Value >>= sValue)
    2776             :             {
    2777           0 :                 String sTabName(sValue);
    2778           0 :                 SCTAB nTab(0);
    2779           0 :                 if (GetDocument()->GetTable(sTabName, nTab))
    2780           0 :                     nTabNo = nTab;
    2781           0 :             }
    2782             :         }
    2783           0 :         else if (sName.compareToAscii(SC_HORIZONTALSCROLLBARWIDTH) == 0)
    2784             :         {
    2785           0 :             if (rSettings[i].Value >>= nTemp32)
    2786           0 :                 pView->SetTabBarWidth(nTemp32);
    2787             :         }
    2788           0 :         else if (sName.compareToAscii(SC_RELHORIZONTALTABBARWIDTH) == 0)
    2789             :         {
    2790           0 :             double fWidth = 0.0;
    2791           0 :             if (rSettings[i].Value >>= fWidth)
    2792           0 :                 pView->SetPendingRelTabBarWidth( fWidth );
    2793             :         }
    2794           0 :         else if (sName.compareToAscii(SC_ZOOMTYPE) == 0)
    2795             :         {
    2796           0 :             if (rSettings[i].Value >>= nTemp16)
    2797           0 :                 eDefZoomType = SvxZoomType(nTemp16);
    2798             :         }
    2799           0 :         else if (sName.compareToAscii(SC_ZOOMVALUE) == 0)
    2800             :         {
    2801           0 :             if (rSettings[i].Value >>= nTemp32)
    2802             :             {
    2803           0 :                 Fraction aZoom(nTemp32, 100);
    2804           0 :                 aDefZoomX = aDefZoomY = aZoom;
    2805             :             }
    2806             :         }
    2807           0 :         else if (sName.compareToAscii(SC_PAGEVIEWZOOMVALUE) == 0)
    2808             :         {
    2809           0 :             if (rSettings[i].Value >>= nTemp32)
    2810             :             {
    2811           0 :                 Fraction aZoom(nTemp32, 100);
    2812           0 :                 aDefPageZoomX = aDefPageZoomY = aZoom;
    2813             :             }
    2814             :         }
    2815           0 :         else if (sName.compareToAscii(SC_SHOWPAGEBREAKPREVIEW) == 0)
    2816           0 :             bPageMode = ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value );
    2817           0 :         else if ( sName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
    2818           0 :             pOptions->SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2819           0 :         else if ( sName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
    2820           0 :             pOptions->SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2821           0 :         else if ( sName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
    2822           0 :             pOptions->SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2823           0 :         else if ( sName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
    2824             :         {
    2825           0 :             sal_Int64 nColor = 0;
    2826           0 :             if (rSettings[i].Value >>= nColor)
    2827             :             {
    2828           0 :                 String aColorName;
    2829           0 :                 Color aColor(static_cast<sal_uInt32>(nColor));
    2830             :                 // #i47435# set automatic grid color explicitly
    2831           0 :                 if( aColor.GetColor() == COL_AUTO )
    2832           0 :                     aColor.SetColor( SC_STD_GRIDCOLOR );
    2833           0 :                 pOptions->SetGridColor(aColor, aColorName);
    2834             :             }
    2835             :         }
    2836           0 :         else if ( sName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
    2837           0 :             pOptions->SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2838           0 :         else if ( sName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
    2839           0 :             pOptions->SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2840           0 :         else if ( sName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
    2841           0 :             pOptions->SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2842           0 :         else if ( sName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
    2843           0 :             pOptions->SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2844           0 :         else if ( sName.compareToAscii( SC_UNO_SHOWOBJ ) == 0 )
    2845             :         {
    2846             :             // #i80528# placeholders not supported anymore
    2847           0 :             if ( rSettings[i].Value >>= nTemp16 )
    2848           0 :                 pOptions->SetObjMode( VOBJ_TYPE_OLE, (nTemp16 == 1) ? VOBJ_MODE_HIDE : VOBJ_MODE_SHOW );
    2849             :         }
    2850           0 :         else if ( sName.compareToAscii( SC_UNO_SHOWCHARTS ) == 0 )
    2851             :         {
    2852             :             // #i80528# placeholders not supported anymore
    2853           0 :             if ( rSettings[i].Value >>= nTemp16 )
    2854           0 :                 pOptions->SetObjMode( VOBJ_TYPE_CHART, (nTemp16 == 1) ? VOBJ_MODE_HIDE : VOBJ_MODE_SHOW );
    2855             :         }
    2856           0 :         else if ( sName.compareToAscii( SC_UNO_SHOWDRAW ) == 0 )
    2857             :         {
    2858             :             // #i80528# placeholders not supported anymore
    2859           0 :             if ( rSettings[i].Value >>= nTemp16 )
    2860           0 :                 pOptions->SetObjMode( VOBJ_TYPE_DRAW, (nTemp16 == 1) ? VOBJ_MODE_HIDE : VOBJ_MODE_SHOW );
    2861             :         }
    2862             :         else
    2863             :         {
    2864           0 :             ScGridOptions aGridOpt(pOptions->GetGridOptions());
    2865           0 :             if ( sName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
    2866           0 :                 aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2867           0 :             else if ( sName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
    2868           0 :                 aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2869           0 :             else if ( sName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
    2870           0 :                 aGridOpt.SetFldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
    2871           0 :             else if ( sName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
    2872           0 :                 aGridOpt.SetFldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
    2873           0 :             else if ( sName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
    2874           0 :                 aGridOpt.SetFldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
    2875           0 :             else if ( sName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
    2876           0 :                 aGridOpt.SetFldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
    2877           0 :             else if ( sName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
    2878           0 :                 aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
    2879           0 :             pOptions->SetGridOptions(aGridOpt);
    2880             :         }
    2881           0 :     }
    2882             : 
    2883             :     // copy default zoom to sheets where a different one wasn't specified
    2884           0 :     for (SCTAB nZoomTab=0; nZoomTab< static_cast<SCTAB>(maTabData.size()); ++nZoomTab)
    2885           0 :         if (maTabData[nZoomTab] && ( nZoomTab >= static_cast<SCTAB>(aHasZoomVect.size()) || !aHasZoomVect[nZoomTab] ))
    2886             :         {
    2887           0 :             maTabData[nZoomTab]->eZoomType  = eDefZoomType;
    2888           0 :             maTabData[nZoomTab]->aZoomX     = aDefZoomX;
    2889           0 :             maTabData[nZoomTab]->aZoomY     = aDefZoomY;
    2890           0 :             maTabData[nZoomTab]->aPageZoomX = aDefPageZoomX;
    2891           0 :             maTabData[nZoomTab]->aPageZoomY = aDefPageZoomY;
    2892             :         }
    2893             : 
    2894           0 :     if (nCount)
    2895           0 :         SetPagebreakMode( bPageMode );
    2896             : 
    2897             :     // #i47426# write view options to document, needed e.g. for Excel export
    2898           0 :     pDoc->SetViewOptions( *pOptions );
    2899           0 : }
    2900             : 
    2901           0 : void ScViewData::SetOptions( const ScViewOptions& rOpt )
    2902             : {
    2903             :     //  if visibility of horiz. ScrollBar is changed, TabBar may have to be resized...
    2904           0 :     sal_Bool bHScrollChanged = ( rOpt.GetOption(VOPT_HSCROLL) != pOptions->GetOption(VOPT_HSCROLL) );
    2905             : 
    2906             :     //  if graphics are turned on or off, animation has to be started or stopped
    2907             :     //  graphics are controlled by VOBJ_TYPE_OLE
    2908           0 :     sal_Bool bGraphicsChanged = ( pOptions->GetObjMode(VOBJ_TYPE_OLE) !=
    2909           0 :                                    rOpt.GetObjMode(VOBJ_TYPE_OLE) );
    2910             : 
    2911           0 :     *pOptions = rOpt;
    2912             :     OSL_ENSURE( pView, "No View" );
    2913             : 
    2914           0 :     if( pView )
    2915             :     {
    2916           0 :         pView->ViewOptionsHasChanged( bHScrollChanged, bGraphicsChanged );
    2917             :     }
    2918           0 : }
    2919             : 
    2920           0 : Point ScViewData::GetMousePosPixel()
    2921             : {
    2922             :     OSL_ENSURE( pView, "GetMousePosPixel() ohne View" );
    2923           0 :     return pView->GetMousePosPixel();
    2924             : }
    2925             : 
    2926           0 : void ScViewData::UpdateInputHandler( sal_Bool bForce, sal_Bool bStopEditing )
    2927             : {
    2928           0 :     if (pViewShell)
    2929           0 :         pViewShell->UpdateInputHandler( bForce, bStopEditing );
    2930           0 : }
    2931             : 
    2932           0 : sal_Bool ScViewData::IsOle()
    2933             : {
    2934           0 :     return pDocShell && pDocShell->IsOle();
    2935             : }
    2936             : 
    2937           0 : sal_Bool ScViewData::UpdateFixX( SCTAB nTab )               // sal_True = Wert geaendert
    2938             : {
    2939           0 :     if (!ValidTab(nTab))        // Default
    2940           0 :         nTab=nTabNo;        // akuelle Tabelle
    2941             : 
    2942           0 :     if (!pView || maTabData[nTab]->eHSplitMode != SC_SPLIT_FIX)
    2943           0 :         return false;
    2944             : 
    2945           0 :     ScDocument* pLocalDoc = GetDocument();
    2946           0 :     if (!pLocalDoc->HasTable(nTab))          // if called from reload, the sheet may not exist
    2947           0 :         return false;
    2948             : 
    2949           0 :     SCCOL nFix = maTabData[nTab]->nFixPosX;
    2950           0 :     long nNewPos = 0;
    2951           0 :     for (SCCOL nX=maTabData[nTab]->nPosX[SC_SPLIT_LEFT]; nX<nFix; nX++)
    2952             :     {
    2953           0 :         sal_uInt16 nTSize = pLocalDoc->GetColWidth( nX, nTab );
    2954           0 :         if (nTSize)
    2955             :         {
    2956           0 :             long nPix = ToPixel( nTSize, nPPTX );
    2957           0 :             nNewPos += nPix;
    2958             :         }
    2959             :     }
    2960           0 :     nNewPos += pView->GetGridOffset().X();
    2961           0 :     if (nNewPos != maTabData[nTab]->nHSplitPos)
    2962             :     {
    2963           0 :         maTabData[nTab]->nHSplitPos = nNewPos;
    2964           0 :         if (nTab == nTabNo)
    2965           0 :             RecalcPixPos();                 //! sollte nicht noetig sein !!!
    2966           0 :         return sal_True;
    2967             :     }
    2968             : 
    2969           0 :     return false;
    2970             : }
    2971             : 
    2972           0 : sal_Bool ScViewData::UpdateFixY( SCTAB nTab )               // sal_True = Wert geaendert
    2973             : {
    2974           0 :     if (!ValidTab(nTab))        // Default
    2975           0 :         nTab=nTabNo;        // akuelle Tabelle
    2976             : 
    2977           0 :     if (!pView || maTabData[nTab]->eVSplitMode != SC_SPLIT_FIX)
    2978           0 :         return false;
    2979             : 
    2980           0 :     ScDocument* pLocalDoc = GetDocument();
    2981           0 :     if (!pLocalDoc->HasTable(nTab))          // if called from reload, the sheet may not exist
    2982           0 :         return false;
    2983             : 
    2984           0 :     SCROW nFix = maTabData[nTab]->nFixPosY;
    2985           0 :     long nNewPos = 0;
    2986           0 :     for (SCROW nY=maTabData[nTab]->nPosY[SC_SPLIT_TOP]; nY<nFix; nY++)
    2987             :     {
    2988           0 :         sal_uInt16 nTSize = pLocalDoc->GetRowHeight( nY, nTab );
    2989           0 :         if (nTSize)
    2990             :         {
    2991           0 :             long nPix = ToPixel( nTSize, nPPTY );
    2992           0 :             nNewPos += nPix;
    2993             :         }
    2994             :     }
    2995           0 :     nNewPos += pView->GetGridOffset().Y();
    2996           0 :     if (nNewPos != maTabData[nTab]->nVSplitPos)
    2997             :     {
    2998           0 :         maTabData[nTab]->nVSplitPos = nNewPos;
    2999           0 :         if (nTab == nTabNo)
    3000           0 :             RecalcPixPos();                 //! sollte nicht noetig sein !!!
    3001           0 :         return sal_True;
    3002             :     }
    3003             : 
    3004           0 :     return false;
    3005             : }
    3006             : 
    3007           0 : void ScViewData::UpdateOutlinerFlags( Outliner& rOutl ) const
    3008             : {
    3009           0 :     ScDocument* pLocalDoc = GetDocument();
    3010           0 :     sal_Bool bOnlineSpell = pLocalDoc->GetDocOptions().IsAutoSpell();
    3011             : 
    3012           0 :     sal_uLong nCntrl = rOutl.GetControlWord();
    3013           0 :     nCntrl |= EE_CNTRL_URLSFXEXECUTE;
    3014           0 :     nCntrl |= EE_CNTRL_MARKFIELDS;
    3015           0 :     nCntrl |= EE_CNTRL_AUTOCORRECT;
    3016           0 :     if( bOnlineSpell )
    3017           0 :         nCntrl |= EE_CNTRL_ONLINESPELLING;
    3018             :     else
    3019           0 :         nCntrl &= ~EE_CNTRL_ONLINESPELLING;
    3020           0 :     rOutl.SetControlWord(nCntrl);
    3021             : 
    3022           0 :     rOutl.SetCalcFieldValueHdl( LINK( SC_MOD(), ScModule, CalcFieldValueHdl ) );
    3023             : 
    3024             :     //  don't call GetSpellChecker if online spelling isn't enabled.
    3025             :     //  The language for AutoCorrect etc. is taken from the pool defaults
    3026             :     //  (set in ScDocument::UpdateDrawLanguages)
    3027             : 
    3028           0 :     if ( bOnlineSpell )
    3029             :     {
    3030           0 :         com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() );
    3031           0 :         rOutl.SetSpeller( xXSpellChecker1 );
    3032             :     }
    3033             : 
    3034             :     rOutl.SetDefaultHorizontalTextDirection(
    3035           0 :         (EEHorizontalTextDirection)pLocalDoc->GetEditTextDirection( nTabNo ) );
    3036           0 : }
    3037             : 
    3038           0 : ScAddress ScViewData::GetCurPos() const
    3039             : {
    3040           0 :     return ScAddress( GetCurX(), GetCurY(), GetTabNo() );
    3041             : }
    3042             : 
    3043             : 
    3044           0 : void ScViewData::AddPixelsWhile( long & rScrY, long nEndPixels, SCROW & rPosY,
    3045             :         SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTabNo )
    3046             : {
    3047           0 :     SCROW nRow = rPosY;
    3048           0 :     while (rScrY <= nEndPixels && nRow <= nEndRow)
    3049             :     {
    3050             :         SCROW nHeightEndRow;
    3051           0 :         sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, NULL, &nHeightEndRow);
    3052           0 :         if (nHeightEndRow > nEndRow)
    3053           0 :             nHeightEndRow = nEndRow;
    3054           0 :         if (!nHeight)
    3055           0 :             nRow = nHeightEndRow + 1;
    3056             :         else
    3057             :         {
    3058           0 :             SCROW nRows = nHeightEndRow - nRow + 1;
    3059           0 :             sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
    3060           0 :             sal_Int64 nAdd = nPixel * nRows;
    3061           0 :             if (nAdd + rScrY > nEndPixels)
    3062             :             {
    3063           0 :                 sal_Int64 nDiff = rScrY + nAdd - nEndPixels;
    3064           0 :                 nRows -= static_cast<SCROW>(nDiff / nPixel);
    3065           0 :                 nAdd = nPixel * nRows;
    3066             :                 // We're looking for a value that satisfies loop condition.
    3067           0 :                 if (nAdd + rScrY <= nEndPixels)
    3068             :                 {
    3069           0 :                     ++nRows;
    3070           0 :                     nAdd += nPixel;
    3071             :                 }
    3072             :             }
    3073           0 :             rScrY += static_cast<long>(nAdd);
    3074           0 :             nRow += nRows;
    3075             :         }
    3076             :     }
    3077           0 :     if (nRow > rPosY)
    3078           0 :         --nRow;
    3079           0 :     rPosY = nRow;
    3080           0 : }
    3081             : 
    3082             : 
    3083           0 : void ScViewData::AddPixelsWhileBackward( long & rScrY, long nEndPixels,
    3084             :         SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc,
    3085             :         SCTAB nTabNo )
    3086             : {
    3087           0 :     SCROW nRow = rPosY;
    3088           0 :     while (rScrY <= nEndPixels && nRow >= nStartRow)
    3089             :     {
    3090             :         SCROW nHeightStartRow;
    3091           0 :         sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, &nHeightStartRow, NULL);
    3092           0 :         if (nHeightStartRow < nStartRow)
    3093           0 :             nHeightStartRow = nStartRow;
    3094           0 :         if (!nHeight)
    3095           0 :             nRow = nHeightStartRow - 1;
    3096             :         else
    3097             :         {
    3098           0 :             SCROW nRows = nRow - nHeightStartRow + 1;
    3099           0 :             sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
    3100           0 :             sal_Int64 nAdd = nPixel * nRows;
    3101           0 :             if (nAdd + rScrY > nEndPixels)
    3102             :             {
    3103           0 :                 sal_Int64 nDiff = nAdd + rScrY - nEndPixels;
    3104           0 :                 nRows -= static_cast<SCROW>(nDiff / nPixel);
    3105           0 :                 nAdd = nPixel * nRows;
    3106             :                 // We're looking for a value that satisfies loop condition.
    3107           0 :                 if (nAdd + rScrY <= nEndPixels)
    3108             :                 {
    3109           0 :                     ++nRows;
    3110           0 :                     nAdd += nPixel;
    3111             :                 }
    3112             :             }
    3113           0 :             rScrY += static_cast<long>(nAdd);
    3114           0 :             nRow -= nRows;
    3115             :         }
    3116             :     }
    3117           0 :     if (nRow < rPosY)
    3118           0 :         ++nRow;
    3119           0 :     rPosY = nRow;
    3120          15 : }
    3121             : 
    3122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10