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