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