1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sc.hxx" 26 27 // System - Includes ----------------------------------------------------- 28 29 30 31 32 #include "scitems.hxx" 33 #include <vcl/svapp.hxx> 34 #include <vcl/msgbox.hxx> 35 #include <vcl/waitobj.hxx> 36 #include <sfx2/app.hxx> 37 #include <sfx2/bindings.hxx> 38 #include <svl/smplhint.hxx> 39 40 // INCLUDE --------------------------------------------------------------- 41 42 #include "docsh.hxx" 43 #include "global.hxx" 44 #include "globstr.hrc" 45 #include "undodat.hxx" 46 #include "undotab.hxx" 47 #include "undoblk.hxx" 48 //#include "pivot.hxx" 49 #include "dpobject.hxx" 50 #include "dpshttab.hxx" 51 #include "dbdocfun.hxx" 52 #include "consoli.hxx" 53 #include "dbcolect.hxx" 54 #include "olinetab.hxx" 55 #include "patattr.hxx" 56 #include "attrib.hxx" 57 #include "docpool.hxx" 58 #include "uiitems.hxx" 59 #include "sc.hrc" 60 #include "waitoff.hxx" 61 #include "sizedev.hxx" 62 #include <basic/sbstar.hxx> 63 #include <basic/basmgr.hxx> 64 65 // defined in docfunc.cxx 66 void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sModuleSource ); 67 68 // --------------------------------------------------------------------------- 69 70 // 71 // ehemalige viewfunc/dbfunc Methoden 72 // 73 74 void ScDocShell::ErrorMessage( sal_uInt16 nGlobStrId ) 75 { 76 //! StopMarking an der (aktiven) View? 77 78 Window* pParent = GetActiveDialogParent(); 79 ScWaitCursorOff aWaitOff( pParent ); 80 sal_Bool bFocus = pParent && pParent->HasFocus(); 81 82 if(nGlobStrId==STR_PROTECTIONERR) 83 { 84 if(IsReadOnly()) 85 { 86 nGlobStrId=STR_READONLYERR; 87 } 88 } 89 90 InfoBox aBox( pParent, ScGlobal::GetRscString( nGlobStrId ) ); 91 aBox.Execute(); 92 if (bFocus) 93 pParent->GrabFocus(); 94 } 95 96 sal_Bool ScDocShell::IsEditable() const 97 { 98 // import into read-only document is possible - must be extended if other filters use api 99 // #i108547# MSOOXML filter uses "IsChangeReadOnlyEnabled" property 100 101 return !IsReadOnly() || aDocument.IsImportingXML() || aDocument.IsChangeReadOnlyEnabled(); 102 } 103 104 void ScDocShell::DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW /* nY2 */ ) 105 { 106 ScDocShellModificator aModificator( *this ); 107 aDocument.RemoveFlagsTab( nX1, nY1, nX2, nY1, nTab, SC_MF_AUTO ); 108 PostPaint( nX1, nY1, nTab, nX2, nY1, nTab, PAINT_GRID ); 109 // No SetDocumentModified, as the unnamed database range might have to be restored later. 110 // The UNO hint is broadcast directly instead, to keep UNO objects in valid state. 111 aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); 112 } 113 114 ScDBData* lcl_GetDBNearCursor( ScDBCollection* pColl, SCCOL nCol, SCROW nRow, SCTAB nTab ) 115 { 116 //! nach document/dbcolect verschieben 117 118 if (!pColl) 119 return NULL; 120 121 ScDBData* pNoNameData = NULL; 122 ScDBData* pNearData = NULL; 123 sal_uInt16 nCount = pColl->GetCount(); 124 String aNoName = ScGlobal::GetRscString( STR_DB_NONAME ); 125 SCTAB nAreaTab; 126 SCCOL nStartCol, nEndCol; 127 SCROW nStartRow, nEndRow; 128 for (sal_uInt16 i = 0; i < nCount; i++) 129 { 130 ScDBData* pDB = (*pColl)[i]; 131 pDB->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow ); 132 if ( nTab == nAreaTab && nCol+1 >= nStartCol && nCol <= nEndCol+1 && 133 nRow+1 >= nStartRow && nRow <= nEndRow+1 ) 134 { 135 if ( pDB->GetName() == aNoName ) 136 pNoNameData = pDB; 137 else if ( nCol < nStartCol || nCol > nEndCol || nRow < nStartRow || nRow > nEndRow ) 138 { 139 if (!pNearData) 140 pNearData = pDB; // ersten angrenzenden Bereich merken 141 } 142 else 143 return pDB; // nicht "unbenannt" und Cursor steht wirklich drin 144 } 145 } 146 if (pNearData) 147 return pNearData; // angrenzender, wenn nichts direkt getroffen 148 return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden 149 } 150 151 ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel ) 152 { 153 if ( eMode == SC_DB_MAKE_FILTER || eMode == SC_DB_MAKE_SORT || eMode == SC_DB_MAKE_SUBTOTAL || eMode == SC_DB_OLD_FILTER ) 154 return GetDBDataAdd(rMarked, eMode, eSel); 155 SCCOL nCol = rMarked.aStart.Col(); 156 SCROW nRow = rMarked.aStart.Row(); 157 SCTAB nTab = rMarked.aStart.Tab(); 158 159 SCCOL nStartCol = nCol; 160 SCROW nStartRow = nRow; 161 SCTAB nStartTab = nTab; 162 SCCOL nEndCol = rMarked.aEnd.Col(); 163 SCROW nEndRow = rMarked.aEnd.Row(); 164 SCTAB nEndTab = rMarked.aEnd.Tab(); 165 166 // Wegen #49655# nicht einfach GetDBAtCursor: Der zusammenhaengende Datenbereich 167 // fuer "unbenannt" (GetDataArea) kann neben dem Cursor legen, also muss auch ein 168 // benannter DB-Bereich dort gesucht werden. 169 170 ScDBData* pData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); 171 if (!pData) 172 pData = lcl_GetDBNearCursor( aDocument.GetDBCollection(), nCol, nRow, nTab ); 173 174 sal_Bool bSelected = ( eSel == SC_DBSEL_FORCE_MARK || 175 (rMarked.aStart != rMarked.aEnd && eSel != SC_DBSEL_ROW_DOWN) ); 176 bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row()); 177 178 sal_Bool bUseThis = sal_False; 179 if (pData) 180 { 181 // Bereich nehmen, wenn nichts anderes markiert 182 183 SCTAB nDummy; 184 SCCOL nOldCol1; 185 SCROW nOldRow1; 186 SCCOL nOldCol2; 187 SCROW nOldRow2; 188 pData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 ); 189 // sal_Bool bIsNoName = ( pData->GetName() == ScGlobal::GetRscString( STR_DB_NONAME ) ); 190 sal_Bool bIsNoName = pData->IsBuildin(); 191 192 if (!bSelected) 193 { 194 bUseThis = sal_True; 195 if ( bIsNoName && eMode == SC_DB_MAKE ) 196 { 197 // If nothing marked or only one row marked, adapt 198 // "unbenannt"/"unnamed" to contiguous area. 199 nStartCol = nCol; 200 nStartRow = nRow; 201 if (bOnlyDown) 202 { 203 nEndCol = rMarked.aEnd.Col(); 204 nEndRow = rMarked.aEnd.Row(); 205 } 206 else 207 { 208 nEndCol = nStartCol; 209 nEndRow = nStartRow; 210 } 211 aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown ); 212 if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow ) 213 bUseThis = sal_False; // passt gar nicht 214 else if ( nOldRow2 != nEndRow ) 215 { 216 // Bereich auf neue End-Zeile erweitern 217 pData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow ); 218 } 219 } 220 } 221 else 222 { 223 if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow && 224 nOldCol2 == nEndCol && nOldRow2 == nEndRow ) // genau markiert? 225 bUseThis = sal_True; 226 else 227 bUseThis = sal_False; // immer Markierung nehmen (Bug 11964) 228 } 229 230 // fuer Import nie "unbenannt" nehmen 231 232 if ( bUseThis && eMode == SC_DB_IMPORT && bIsNoName ) 233 bUseThis = sal_False; 234 } 235 236 if ( bUseThis ) 237 { 238 pData->GetArea( nStartTab, nStartCol,nStartRow, nEndCol,nEndRow ); 239 nEndTab = nStartTab; 240 } 241 else if ( eMode == SC_DB_OLD ) 242 { 243 pData = NULL; // nichts gefunden 244 nStartCol = nEndCol = nCol; 245 nStartRow = nEndRow = nRow; 246 nStartTab = nEndTab = nTab; 247 // bMark = sal_False; // nichts zu markieren 248 } 249 else 250 { 251 if ( bSelected ) 252 { 253 // bMark = sal_False; 254 } 255 else 256 { // zusammenhaengender Bereich 257 nStartCol = nCol; 258 nStartRow = nRow; 259 if (bOnlyDown) 260 { 261 nEndCol = rMarked.aEnd.Col(); 262 nEndRow = rMarked.aEnd.Row(); 263 } 264 else 265 { 266 nEndCol = nStartCol; 267 nEndRow = nStartRow; 268 } 269 aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown ); 270 } 271 272 sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab ); 273 274 ScDBData* pNoNameData; 275 sal_uInt16 nNoNameIndex; 276 ScDBCollection* pColl = aDocument.GetDBCollection(); 277 if ( eMode != SC_DB_IMPORT && 278 pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) 279 { 280 pNoNameData = (*pColl)[nNoNameIndex]; 281 282 if ( !pOldAutoDBRange ) 283 { 284 // store the old unnamed database range with its settings for undo 285 // (store at the first change, get the state before all changes) 286 pOldAutoDBRange = new ScDBData( *pNoNameData ); 287 } 288 289 SCCOL nOldX1; // alten Bereich sauber wegnehmen 290 SCROW nOldY1; //! (UNDO ???) 291 SCCOL nOldX2; 292 SCROW nOldY2; 293 SCTAB nOldTab; 294 pNoNameData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); 295 DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); 296 297 pNoNameData->SetSortParam( ScSortParam() ); // Parameter zuruecksetzen 298 pNoNameData->SetQueryParam( ScQueryParam() ); 299 pNoNameData->SetSubTotalParam( ScSubTotalParam() ); 300 301 pNoNameData->SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow ); // neu setzen 302 pNoNameData->SetByRow( sal_True ); 303 pNoNameData->SetHeader( bHasHeader ); 304 pNoNameData->SetAutoFilter( sal_False ); 305 } 306 else 307 { 308 ScDBCollection* pUndoColl = NULL; 309 310 String aNewName; 311 if (eMode==SC_DB_IMPORT) 312 { 313 aDocument.CompileDBFormula( sal_True ); // CreateFormulaString 314 pUndoColl = new ScDBCollection( *pColl ); // Undo fuer Import1-Bereich 315 316 String aImport = ScGlobal::GetRscString( STR_DBNAME_IMPORT ); 317 long nCount = 0; 318 sal_uInt16 nDummy; 319 do 320 { 321 ++nCount; 322 aNewName = aImport; 323 aNewName += String::CreateFromInt32( nCount ); 324 } 325 while (pColl->SearchName( aNewName, nDummy )); 326 } 327 else 328 //aNewName = ScGlobal::GetRscString( STR_DB_NONAME ); 329 aNewName = pColl->GetNewDefaultDBName(); 330 331 pNoNameData = new ScDBData( aNewName, nTab, 332 nStartCol,nStartRow, nEndCol,nEndRow, 333 sal_True, bHasHeader ); 334 pColl->Insert( pNoNameData ); 335 336 if ( pUndoColl ) 337 { 338 aDocument.CompileDBFormula( sal_False ); // CompileFormulaString 339 340 ScDBCollection* pRedoColl = new ScDBCollection( *pColl ); 341 GetUndoManager()->AddUndoAction( new ScUndoDBData( this, pUndoColl, pRedoColl ) ); 342 } 343 344 // neuen Bereich am Sba anmelden nicht mehr noetig 345 346 // "Import1" etc am Navigator bekanntmachen 347 if (eMode==SC_DB_IMPORT) 348 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) ); 349 } 350 pData = pNoNameData; 351 } 352 353 // if (bMark) 354 // MarkRange( ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ), sal_False ); 355 356 return pData; 357 } 358 359 ScDBData* ScDocShell::GetDBDataAdd( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel ) 360 { 361 SCCOL nCol = rMarked.aStart.Col(); 362 SCROW nRow = rMarked.aStart.Row(); 363 SCTAB nTab = rMarked.aStart.Tab(); 364 365 SCCOL nStartCol = nCol; 366 SCROW nStartRow = nRow; 367 SCTAB nStartTab = nTab; 368 SCCOL nEndCol = rMarked.aEnd.Col(); 369 SCROW nEndRow = rMarked.aEnd.Row(); 370 SCTAB nEndTab = rMarked.aEnd.Tab(); 371 372 ScDBData* pData = NULL; 373 ScDBData* pCursorData; 374 pCursorData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); 375 if ( !pCursorData ) 376 pCursorData = aDocument.GetDBAtCursor( nStartCol, nStartRow, nTab ); 377 378 //Get DBData at current table 379 ScDBData* pTableData = aDocument.GetDBAtTable( nTab, eMode ); 380 381 if ( eMode == SC_DB_OLD_FILTER ) 382 return pTableData; 383 384 sal_Bool bSelected = ( eSel == SC_DBSEL_FORCE_MARK || rMarked.aStart != rMarked.aEnd ); 385 bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row()); 386 387 sal_Bool bUseThis = sal_False; 388 if (pCursorData) 389 { 390 SCTAB nDummy; 391 SCCOL nOldCol1; 392 SCROW nOldRow1; 393 SCCOL nOldCol2; 394 SCROW nOldRow2; 395 pCursorData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 ); 396 if ( !bSelected ) 397 { 398 ScRange tmpRange; 399 if ( !pCursorData->IsBuildin() && pCursorData->GetAdvancedQuerySource(tmpRange)) 400 bUseThis = sal_True; 401 else 402 { 403 nStartCol = nCol; 404 nStartRow = nRow; 405 nEndCol = nStartCol; 406 nEndRow = nStartRow; 407 aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown ); 408 if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow ) 409 bUseThis = sal_False; 410 else 411 { 412 bUseThis = sal_True; 413 if ( nOldRow2 != nEndRow )// Range of new end-line expand 414 pCursorData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow ); 415 } 416 } 417 418 } 419 else 420 { 421 if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow && nOldCol2 == nEndCol && nOldRow2 == nEndRow ) 422 bUseThis = sal_True; 423 else 424 bUseThis = sal_False; // Always take mark (Bug 11964) 425 } 426 } 427 428 if ( bUseThis ) 429 { 430 pData = pCursorData; 431 if ( pTableData && eMode == SC_DB_MAKE_FILTER && !(*pTableData == *pCursorData ) ) 432 { 433 if ( !pOldAutoDBRange ) 434 pOldAutoDBRange = new ScDBData(*pTableData); 435 SCCOL nOldX1; 436 SCROW nOldY1; 437 SCCOL nOldX2; 438 SCROW nOldY2; 439 SCTAB nOldTab; 440 pTableData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); 441 442 if (pTableData->HasQueryParam()) 443 { 444 ScQueryParam aParam; 445 pTableData->GetQueryParam(aParam); 446 SCSIZE nEC = aParam.GetEntryCount(); 447 for (SCSIZE i=0; i<nEC; i++) 448 aParam.GetEntry(i).bDoQuery = sal_False; 449 aParam.bDuplicate = sal_True; 450 ScDBDocFunc aDBDocFunc( *this ); 451 aDBDocFunc.Query( nTab, aParam, NULL, sal_False, sal_False ); 452 } 453 454 DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); 455 pTableData->SetQueryParam( ScQueryParam() ); 456 pTableData->SetAutoFilter( sal_False ); 457 } 458 459 } 460 else 461 { 462 if ( bSelected ) 463 { 464 // bMark = sal_False; 465 } 466 else 467 { 468 nStartCol = nCol; 469 nStartRow = nRow; 470 nEndCol = nStartCol; 471 nEndRow = nStartRow; 472 aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, sal_False, bOnlyDown ); 473 } 474 sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab ); 475 ScDBCollection* pColl = aDocument.GetDBCollection(); 476 if ( pTableData ) 477 { 478 if ( !pOldAutoDBRange ) 479 pOldAutoDBRange = new ScDBData(*pTableData); 480 SCCOL nOldX1; 481 SCROW nOldY1; 482 SCCOL nOldX2; 483 SCROW nOldY2; 484 SCTAB nOldTab; 485 pTableData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); 486 487 if (pTableData->HasQueryParam()) 488 { 489 ScQueryParam aParam; 490 pTableData->GetQueryParam(aParam); 491 SCSIZE nEC = aParam.GetEntryCount(); 492 for (SCSIZE i=0; i<nEC; i++) 493 aParam.GetEntry(i).bDoQuery = sal_False; 494 aParam.bDuplicate = sal_True; 495 ScDBDocFunc aDBDocFunc( *this ); 496 aDBDocFunc.Query( nTab, aParam, NULL, sal_False, sal_False ); 497 } 498 499 DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 ); 500 501 pTableData->SetSortParam( ScSortParam() ); 502 pTableData->SetQueryParam( ScQueryParam() ); 503 pTableData->SetSubTotalParam( ScSubTotalParam() ); 504 505 pTableData->SetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ); 506 pTableData->SetByRow( sal_True ); 507 pTableData->SetHeader( bHasHeader ); 508 pTableData->SetAutoFilter( sal_False ); 509 } 510 else 511 { 512 String aNewName = pColl->GetNewDefaultDBName(); 513 pTableData = new ScDBData( aNewName, nTab, nStartCol,nStartRow, nEndCol,nEndRow, sal_True, bHasHeader ); 514 pColl->Insert( pTableData ); 515 } 516 pData = pTableData; 517 } 518 519 return pData; 520 } 521 522 523 ScDBData* ScDocShell::GetOldAutoDBRange() 524 { 525 ScDBData* pRet = pOldAutoDBRange; 526 pOldAutoDBRange = NULL; 527 return pRet; // has to be deleted by caller! 528 } 529 530 void ScDocShell::CancelAutoDBRange() 531 { 532 // called when dialog is cancelled 533 if ( pOldAutoDBRange ) 534 { 535 sal_uInt16 nNoNameIndex; 536 ScDBCollection* pColl = aDocument.GetDBCollection(); 537 if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) ) 538 { 539 ScDBData* pNoNameData = (*pColl)[nNoNameIndex]; 540 541 SCCOL nRangeX1; 542 SCROW nRangeY1; 543 SCCOL nRangeX2; 544 SCROW nRangeY2; 545 SCTAB nRangeTab; 546 pNoNameData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); 547 DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); 548 549 *pNoNameData = *pOldAutoDBRange; // restore old settings 550 551 if ( pOldAutoDBRange->HasAutoFilter() ) 552 { 553 // restore AutoFilter buttons 554 pOldAutoDBRange->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 ); 555 aDocument.ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO ); 556 PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PAINT_GRID ); 557 } 558 } 559 560 delete pOldAutoDBRange; 561 pOldAutoDBRange = NULL; 562 } 563 } 564 565 566 // Hoehen anpassen 567 //! mit docfunc zusammenfassen 568 569 sal_Bool ScDocShell::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) 570 { 571 ScSizeDeviceProvider aProv(this); 572 Fraction aZoom(1,1); 573 sal_Bool bChange = aDocument.SetOptimalHeight( nStartRow,nEndRow, nTab, 0, aProv.GetDevice(), 574 aProv.GetPPTX(),aProv.GetPPTY(), aZoom,aZoom, sal_False ); 575 if (bChange) 576 PostPaint( 0,nStartRow,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID|PAINT_LEFT ); 577 578 return bChange; 579 } 580 581 void ScDocShell::UpdateAllRowHeights( const ScMarkData* pTabMark ) 582 { 583 // update automatic row heights 584 585 ScSizeDeviceProvider aProv(this); 586 Fraction aZoom(1,1); 587 aDocument.UpdateAllRowHeights( aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, pTabMark ); 588 } 589 590 void ScDocShell::UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore ) 591 { 592 sal_Bool bIsUndoEnabled = aDocument.IsUndoEnabled(); 593 aDocument.EnableUndo( sal_False ); 594 aDocument.LockStreamValid( true ); // ignore draw page size (but not formula results) 595 if ( bBefore ) // check all sheets up to nUpdateTab 596 { 597 SCTAB nTabCount = aDocument.GetTableCount(); 598 if ( nUpdateTab >= nTabCount ) 599 nUpdateTab = nTabCount-1; // nUpdateTab is inclusive 600 601 ScMarkData aUpdateSheets; 602 SCTAB nTab; 603 for (nTab=0; nTab<=nUpdateTab; ++nTab) 604 if ( aDocument.IsPendingRowHeights( nTab ) ) 605 aUpdateSheets.SelectTable( nTab, sal_True ); 606 607 if (aUpdateSheets.GetSelectCount()) 608 UpdateAllRowHeights(&aUpdateSheets); // update with a single progress bar 609 610 for (nTab=0; nTab<=nUpdateTab; ++nTab) 611 if ( aUpdateSheets.GetTableSelect( nTab ) ) 612 { 613 aDocument.UpdatePageBreaks( nTab ); 614 aDocument.SetPendingRowHeights( nTab, sal_False ); 615 } 616 } 617 else // only nUpdateTab 618 { 619 if ( aDocument.IsPendingRowHeights( nUpdateTab ) ) 620 { 621 AdjustRowHeight( 0, MAXROW, nUpdateTab ); 622 aDocument.UpdatePageBreaks( nUpdateTab ); 623 aDocument.SetPendingRowHeights( nUpdateTab, sal_False ); 624 } 625 } 626 aDocument.LockStreamValid( false ); 627 aDocument.EnableUndo( bIsUndoEnabled ); 628 } 629 630 void ScDocShell::RefreshPivotTables( const ScRange& rSource ) 631 { 632 //! rename to RefreshDataPilotTables? 633 634 ScDPCollection* pColl = aDocument.GetDPCollection(); 635 if ( pColl ) 636 { 637 // DataPilotUpdate doesn't modify the collection order like PivotUpdate did, 638 // so a simple loop can be used. 639 640 sal_uInt16 nCount = pColl->GetCount(); 641 for ( sal_uInt16 i=0; i<nCount; i++ ) 642 { 643 ScDPObject* pOld = (*pColl)[i]; 644 if ( pOld ) 645 { 646 const ScSheetSourceDesc* pSheetDesc = pOld->GetSheetDesc(); 647 if ( pSheetDesc && pSheetDesc->aSourceRange.Intersects( rSource ) ) 648 { 649 ScDPObject* pNew = new ScDPObject( *pOld ); 650 ScDBDocFunc aFunc( *this ); 651 aFunc.DataPilotUpdate( pOld, pNew, sal_True, sal_False ); 652 delete pNew; // DataPilotUpdate copies settings from "new" object 653 } 654 } 655 } 656 } 657 } 658 659 String lcl_GetAreaName( ScDocument* pDoc, ScArea* pArea ) 660 { 661 String aName; 662 sal_Bool bOk = sal_False; 663 ScDBData* pData = pDoc->GetDBAtArea( pArea->nTab, pArea->nColStart, pArea->nRowStart, 664 pArea->nColEnd, pArea->nRowEnd ); 665 if (pData) 666 { 667 pData->GetName( aName ); 668 if ( aName != ScGlobal::GetRscString( STR_DB_NONAME ) ) 669 bOk = sal_True; 670 } 671 672 if (!bOk) 673 pDoc->GetName( pArea->nTab, aName ); 674 675 return aName; 676 } 677 678 void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, sal_Bool bRecord ) 679 { 680 ScConsData aData; 681 682 sal_uInt16 nPos; 683 SCCOL nColSize = 0; 684 SCROW nRowSize = 0; 685 sal_Bool bErr = sal_False; 686 for (nPos=0; nPos<rParam.nDataAreaCount; nPos++) 687 { 688 ScArea* pArea = rParam.ppDataAreas[nPos]; 689 nColSize = Max( nColSize, SCCOL( pArea->nColEnd - pArea->nColStart + 1 ) ); 690 nRowSize = Max( nRowSize, SCROW( pArea->nRowEnd - pArea->nRowStart + 1 ) ); 691 692 // Test, ob Quelldaten verschoben wuerden 693 if (rParam.bReferenceData) 694 if (pArea->nTab == rParam.nTab && pArea->nRowEnd >= rParam.nRow) 695 bErr = sal_True; 696 } 697 698 if (bErr) 699 { 700 InfoBox aBox( GetActiveDialogParent(), 701 ScGlobal::GetRscString( STR_CONSOLIDATE_ERR1 ) ); 702 aBox.Execute(); 703 return; 704 } 705 706 // ausfuehren 707 708 WaitObject aWait( GetActiveDialogParent() ); 709 ScDocShellModificator aModificator( *this ); 710 711 ScRange aOldDest; 712 ScDBData* pDestData = aDocument.GetDBAtCursor( rParam.nCol, rParam.nRow, rParam.nTab, sal_True ); 713 if (pDestData) 714 pDestData->GetArea(aOldDest); 715 716 aData.SetSize( nColSize, nRowSize ); 717 aData.SetFlags( rParam.eFunction, rParam.bByCol, rParam.bByRow, rParam.bReferenceData ); 718 if ( rParam.bByCol || rParam.bByRow ) 719 for (nPos=0; nPos<rParam.nDataAreaCount; nPos++) 720 { 721 ScArea* pArea = rParam.ppDataAreas[nPos]; 722 aData.AddFields( &aDocument, pArea->nTab, pArea->nColStart, pArea->nRowStart, 723 pArea->nColEnd, pArea->nRowEnd ); 724 } 725 aData.DoneFields(); 726 for (nPos=0; nPos<rParam.nDataAreaCount; nPos++) 727 { 728 ScArea* pArea = rParam.ppDataAreas[nPos]; 729 aData.AddData( &aDocument, pArea->nTab, pArea->nColStart, pArea->nRowStart, 730 pArea->nColEnd, pArea->nRowEnd ); 731 aData.AddName( lcl_GetAreaName(&aDocument,pArea) ); 732 } 733 734 aData.GetSize( nColSize, nRowSize ); 735 if (bRecord && nColSize > 0 && nRowSize > 0) 736 { 737 ScDBData* pUndoData = pDestData ? new ScDBData(*pDestData) : NULL; 738 739 SCTAB nDestTab = rParam.nTab; 740 ScArea aDestArea( rParam.nTab, rParam.nCol, rParam.nRow, 741 rParam.nCol+nColSize-1, rParam.nRow+nRowSize-1 ); 742 if (rParam.bByCol) ++aDestArea.nColEnd; 743 if (rParam.bByRow) ++aDestArea.nRowEnd; 744 745 if (rParam.bReferenceData) 746 { 747 SCTAB nTabCount = aDocument.GetTableCount(); 748 SCROW nInsertCount = aData.GetInsertCount(); 749 750 // alte Outlines 751 ScOutlineTable* pTable = aDocument.GetOutlineTable( nDestTab ); 752 ScOutlineTable* pUndoTab = pTable ? new ScOutlineTable( *pTable ) : NULL; 753 754 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); 755 pUndoDoc->InitUndo( &aDocument, 0, nTabCount-1, sal_False, sal_True ); 756 757 // Zeilenstatus 758 aDocument.CopyToDocument( 0,0,nDestTab, MAXCOL,MAXROW,nDestTab, 759 IDF_NONE, sal_False, pUndoDoc ); 760 761 // alle Formeln 762 aDocument.CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1, 763 IDF_FORMULA, sal_False, pUndoDoc ); 764 765 // komplette Ausgangszeilen 766 aDocument.CopyToDocument( 0,aDestArea.nRowStart,nDestTab, 767 MAXCOL,aDestArea.nRowEnd,nDestTab, 768 IDF_ALL, sal_False, pUndoDoc ); 769 770 // alten Ausgabebereich 771 if (pDestData) 772 aDocument.CopyToDocument( aOldDest, IDF_ALL, sal_False, pUndoDoc ); 773 774 GetUndoManager()->AddUndoAction( 775 new ScUndoConsolidate( this, aDestArea, rParam, pUndoDoc, 776 sal_True, nInsertCount, pUndoTab, pUndoData ) ); 777 } 778 else 779 { 780 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); 781 pUndoDoc->InitUndo( &aDocument, aDestArea.nTab, aDestArea.nTab ); 782 783 aDocument.CopyToDocument( aDestArea.nColStart, aDestArea.nRowStart, aDestArea.nTab, 784 aDestArea.nColEnd, aDestArea.nRowEnd, aDestArea.nTab, 785 IDF_ALL, sal_False, pUndoDoc ); 786 787 // alten Ausgabebereich 788 if (pDestData) 789 aDocument.CopyToDocument( aOldDest, IDF_ALL, sal_False, pUndoDoc ); 790 791 GetUndoManager()->AddUndoAction( 792 new ScUndoConsolidate( this, aDestArea, rParam, pUndoDoc, 793 sal_False, 0, NULL, pUndoData ) ); 794 } 795 } 796 797 if (pDestData) // Zielbereich loeschen / anpassen 798 { 799 aDocument.DeleteAreaTab(aOldDest, IDF_CONTENTS); 800 pDestData->SetArea( rParam.nTab, rParam.nCol, rParam.nRow, 801 rParam.nCol + nColSize - 1, rParam.nRow + nRowSize - 1 ); 802 pDestData->SetHeader( rParam.bByRow ); 803 } 804 805 aData.OutputToDocument( &aDocument, rParam.nCol, rParam.nRow, rParam.nTab ); 806 807 SCCOL nPaintStartCol = rParam.nCol; 808 SCROW nPaintStartRow = rParam.nRow; 809 SCCOL nPaintEndCol = nPaintStartCol + nColSize - 1; 810 SCROW nPaintEndRow = nPaintStartRow + nRowSize - 1; 811 sal_uInt16 nPaintFlags = PAINT_GRID; 812 if (rParam.bByCol) 813 ++nPaintEndRow; 814 if (rParam.bByRow) 815 ++nPaintEndCol; 816 if (rParam.bReferenceData) 817 { 818 nPaintStartCol = 0; 819 nPaintEndCol = MAXCOL; 820 nPaintEndRow = MAXROW; 821 nPaintFlags |= PAINT_LEFT | PAINT_SIZE; 822 } 823 if (pDestData) 824 { 825 if ( aOldDest.aEnd.Col() > nPaintEndCol ) 826 nPaintEndCol = aOldDest.aEnd.Col(); 827 if ( aOldDest.aEnd.Row() > nPaintEndRow ) 828 nPaintEndRow = aOldDest.aEnd.Row(); 829 } 830 PostPaint( nPaintStartCol, nPaintStartRow, rParam.nTab, 831 nPaintEndCol, nPaintEndRow, rParam.nTab, nPaintFlags ); 832 aModificator.SetDocumentModified(); 833 } 834 835 void ScDocShell::UseScenario( SCTAB nTab, const String& rName, sal_Bool bRecord ) 836 { 837 if (!aDocument.IsScenario(nTab)) 838 { 839 SCTAB nTabCount = aDocument.GetTableCount(); 840 SCTAB nSrcTab = SCTAB_MAX; 841 SCTAB nEndTab = nTab; 842 String aCompare; 843 while ( nEndTab+1 < nTabCount && aDocument.IsScenario(nEndTab+1) ) 844 { 845 ++nEndTab; 846 if (nSrcTab > MAXTAB) // noch auf der Suche nach dem Szenario? 847 { 848 aDocument.GetName( nEndTab, aCompare ); 849 if (aCompare == rName) 850 nSrcTab = nEndTab; // gefunden 851 } 852 } 853 if (ValidTab(nSrcTab)) 854 { 855 if ( aDocument.TestCopyScenario( nSrcTab, nTab ) ) // Zellschutz testen 856 { 857 ScDocShellModificator aModificator( *this ); 858 ScMarkData aScenMark; 859 aDocument.MarkScenario( nSrcTab, nTab, aScenMark ); 860 ScRange aMultiRange; 861 aScenMark.GetMultiMarkArea( aMultiRange ); 862 SCCOL nStartCol = aMultiRange.aStart.Col(); 863 SCROW nStartRow = aMultiRange.aStart.Row(); 864 SCCOL nEndCol = aMultiRange.aEnd.Col(); 865 SCROW nEndRow = aMultiRange.aEnd.Row(); 866 867 if (bRecord) 868 { 869 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); 870 pUndoDoc->InitUndo( &aDocument, nTab,nEndTab ); // auch alle Szenarien 871 // angezeigte Tabelle: 872 aDocument.CopyToDocument( nStartCol,nStartRow,nTab, 873 nEndCol,nEndRow,nTab, IDF_ALL,sal_True, pUndoDoc, &aScenMark ); 874 // Szenarien 875 for (SCTAB i=nTab+1; i<=nEndTab; i++) 876 { 877 pUndoDoc->SetScenario( i, sal_True ); 878 String aComment; 879 Color aColor; 880 sal_uInt16 nScenFlags; 881 aDocument.GetScenarioData( i, aComment, aColor, nScenFlags ); 882 pUndoDoc->SetScenarioData( i, aComment, aColor, nScenFlags ); 883 sal_Bool bActive = aDocument.IsActiveScenario( i ); 884 pUndoDoc->SetActiveScenario( i, bActive ); 885 // Bei Zurueckkopier-Szenarios auch Inhalte 886 if ( nScenFlags & SC_SCENARIO_TWOWAY ) 887 aDocument.CopyToDocument( 0,0,i, MAXCOL,MAXROW,i, 888 IDF_ALL,sal_False, pUndoDoc ); 889 } 890 891 GetUndoManager()->AddUndoAction( 892 new ScUndoUseScenario( this, aScenMark, 893 ScArea( nTab,nStartCol,nStartRow,nEndCol,nEndRow ), 894 pUndoDoc, rName ) ); 895 } 896 897 aDocument.CopyScenario( nSrcTab, nTab ); 898 aDocument.SetDirty(); 899 900 // alles painten, weil in anderen Bereichen das aktive Szenario 901 // geaendert sein kann 902 //! nur, wenn sichtbare Rahmen vorhanden? 903 PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); 904 aModificator.SetDocumentModified(); 905 } 906 else 907 { 908 InfoBox aBox(GetActiveDialogParent(), 909 ScGlobal::GetRscString( STR_PROTECTIONERR ) ); 910 aBox.Execute(); 911 } 912 } 913 else 914 { 915 InfoBox aBox(GetActiveDialogParent(), 916 ScGlobal::GetRscString( STR_SCENARIO_NOTFOUND ) ); 917 aBox.Execute(); 918 } 919 } 920 else 921 { 922 DBG_ERROR( "UseScenario auf Szenario-Blatt" ); 923 } 924 } 925 926 void ScDocShell::ModifyScenario( SCTAB nTab, const String& rName, const String& rComment, 927 const Color& rColor, sal_uInt16 nFlags ) 928 { 929 // Undo 930 String aOldName; 931 aDocument.GetName( nTab, aOldName ); 932 String aOldComment; 933 Color aOldColor; 934 sal_uInt16 nOldFlags; 935 aDocument.GetScenarioData( nTab, aOldComment, aOldColor, nOldFlags ); 936 GetUndoManager()->AddUndoAction( 937 new ScUndoScenarioFlags( this, nTab, 938 aOldName, rName, aOldComment, rComment, 939 aOldColor, rColor, nOldFlags, nFlags ) ); 940 941 // ausfuehren 942 ScDocShellModificator aModificator( *this ); 943 aDocument.RenameTab( nTab, rName ); 944 aDocument.SetScenarioData( nTab, rComment, rColor, nFlags ); 945 PostPaintGridAll(); 946 aModificator.SetDocumentModified(); 947 948 if ( rName != aOldName ) 949 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); 950 951 SfxBindings* pBindings = GetViewBindings(); 952 if (pBindings) 953 pBindings->Invalidate( SID_SELECT_SCENARIO ); 954 } 955 956 SCTAB ScDocShell::MakeScenario( SCTAB nTab, const String& rName, const String& rComment, 957 const Color& rColor, sal_uInt16 nFlags, 958 ScMarkData& rMark, sal_Bool bRecord ) 959 { 960 rMark.MarkToMulti(); 961 if (rMark.IsMultiMarked()) 962 { 963 SCTAB nNewTab = nTab + 1; 964 while (aDocument.IsScenario(nNewTab)) 965 ++nNewTab; 966 967 sal_Bool bCopyAll = ( (nFlags & SC_SCENARIO_COPYALL) != 0 ); 968 const ScMarkData* pCopyMark = NULL; 969 if (!bCopyAll) 970 pCopyMark = &rMark; 971 972 ScDocShellModificator aModificator( *this ); 973 974 if (bRecord) 975 aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions 976 977 if (aDocument.CopyTab( nTab, nNewTab, pCopyMark )) 978 { 979 if (bRecord) 980 { 981 GetUndoManager()->AddUndoAction( 982 new ScUndoMakeScenario( this, nTab, nNewTab, 983 rName, rComment, rColor, nFlags, rMark )); 984 } 985 986 aDocument.RenameTab( nNewTab, rName, sal_False ); // ohne Formel-Update 987 aDocument.SetScenario( nNewTab, sal_True ); 988 aDocument.SetScenarioData( nNewTab, rComment, rColor, nFlags ); 989 990 ScMarkData aDestMark = rMark; 991 aDestMark.SelectOneTable( nNewTab ); 992 993 //! auf Filter / Buttons / Merging testen ! 994 995 ScPatternAttr aProtPattern( aDocument.GetPool() ); 996 aProtPattern.GetItemSet().Put( ScProtectionAttr( sal_True ) ); 997 aDocument.ApplyPatternAreaTab( 0,0, MAXCOL,MAXROW, nNewTab, aProtPattern ); 998 999 ScPatternAttr aPattern( aDocument.GetPool() ); 1000 aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) ); 1001 aPattern.GetItemSet().Put( ScProtectionAttr( sal_True ) ); 1002 aDocument.ApplySelectionPattern( aPattern, aDestMark ); 1003 1004 if (!bCopyAll) 1005 aDocument.SetVisible( nNewTab, sal_False ); 1006 1007 // dies ist dann das aktive Szenario 1008 aDocument.CopyScenario( nNewTab, nTab, sal_True ); // sal_True - nicht aus Szenario kopieren 1009 1010 if (nFlags & SC_SCENARIO_SHOWFRAME) 1011 PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); // Rahmen painten 1012 PostPaintExtras(); // Tabellenreiter 1013 aModificator.SetDocumentModified(); 1014 1015 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); 1016 1017 return nNewTab; 1018 } 1019 } 1020 return nTab; 1021 } 1022 1023 sal_Bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, sal_Bool bCopy, sal_Bool bRecord ) 1024 { 1025 ScDocShellModificator aModificator( *this ); 1026 1027 // #i92477# be consistent with ScDocFunc::InsertTable: any index past the last sheet means "append" 1028 // #i101139# nDestTab must be the target position, not APPEND (for CopyTabProtection etc.) 1029 if ( nDestTab >= aDocument.GetTableCount() ) 1030 nDestTab = aDocument.GetTableCount(); 1031 1032 if (bCopy) 1033 { 1034 if (bRecord) 1035 aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions 1036 1037 String sSrcCodeName; 1038 aDocument.GetCodeName( nSrcTab, sSrcCodeName ); 1039 if (!aDocument.CopyTab( nSrcTab, nDestTab )) 1040 { 1041 //! EndDrawUndo? 1042 return sal_False; 1043 } 1044 else 1045 { 1046 SCTAB nAdjSource = nSrcTab; 1047 if ( nDestTab <= nSrcTab ) 1048 ++nAdjSource; // new position of source table after CopyTab 1049 1050 if ( aDocument.IsTabProtected( nAdjSource ) ) 1051 aDocument.CopyTabProtection(nAdjSource, nDestTab); 1052 1053 if (bRecord) 1054 { 1055 SvShorts aSrcList; 1056 SvShorts aDestList; 1057 aSrcList.push_front(nSrcTab); 1058 aDestList.push_front(nDestTab); 1059 GetUndoManager()->AddUndoAction( 1060 new ScUndoCopyTab( this, aSrcList, aDestList ) ); 1061 } 1062 1063 sal_Bool bVbaEnabled = aDocument.IsInVBAMode(); 1064 if ( bVbaEnabled ) 1065 { 1066 StarBASIC* pStarBASIC = GetBasic(); 1067 String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); 1068 if ( GetBasicManager()->GetName().Len() > 0 ) 1069 { 1070 aLibName = GetBasicManager()->GetName(); 1071 pStarBASIC = GetBasicManager()->GetLib( aLibName ); 1072 } 1073 SCTAB nTabToUse = nDestTab; 1074 if ( nDestTab == SC_TAB_APPEND ) 1075 nTabToUse = aDocument.GetMaxTableNumber() - 1; 1076 String sCodeName; 1077 String sSource; 1078 com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer(); 1079 com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; 1080 if( xLibContainer.is() ) 1081 { 1082 com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); 1083 aLibAny >>= xLib; 1084 } 1085 if( xLib.is() ) 1086 { 1087 rtl::OUString sRTLSource; 1088 xLib->getByName( sSrcCodeName ) >>= sRTLSource; 1089 sSource = sRTLSource; 1090 } 1091 VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource ); 1092 } 1093 } 1094 Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) ); 1095 } 1096 else 1097 { 1098 if ( aDocument.GetChangeTrack() ) 1099 return sal_False; 1100 1101 if ( nSrcTab<nDestTab && nDestTab!=SC_TAB_APPEND ) 1102 nDestTab--; 1103 1104 if ( nSrcTab == nDestTab ) 1105 { 1106 //! allow only for api calls? 1107 return sal_True; // nothing to do, but valid 1108 } 1109 1110 if (!aDocument.MoveTab( nSrcTab, nDestTab )) 1111 return sal_False; 1112 else if (bRecord) 1113 { 1114 SvShorts aSrcList; 1115 SvShorts aDestList; 1116 aSrcList.push_front(nSrcTab); 1117 aDestList.push_front(nDestTab); 1118 GetUndoManager()->AddUndoAction( 1119 new ScUndoMoveTab( this, aSrcList, aDestList ) ); 1120 } 1121 1122 Broadcast( ScTablesHint( SC_TAB_MOVED, nSrcTab, nDestTab ) ); 1123 } 1124 1125 PostPaintGridAll(); 1126 PostPaintExtras(); 1127 aModificator.SetDocumentModified(); 1128 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); 1129 1130 return sal_True; 1131 } 1132 1133 1134 IMPL_LINK( ScDocShell, RefreshDBDataHdl, ScRefreshTimer*, pRefreshTimer ) 1135 { 1136 ScDBDocFunc aFunc(*this); 1137 1138 sal_Bool bContinue = sal_True; 1139 ScDBData* pDBData = static_cast<ScDBData*>(pRefreshTimer); 1140 ScImportParam aImportParam; 1141 pDBData->GetImportParam( aImportParam ); 1142 if (aImportParam.bImport && !pDBData->HasImportSelection()) 1143 { 1144 ScRange aRange; 1145 pDBData->GetArea( aRange ); 1146 bContinue = aFunc.DoImport( aRange.aStart.Tab(), aImportParam, NULL, sal_True, sal_False ); //! Api-Flag as parameter 1147 // internal operations (sort, query, subtotal) only if no error 1148 if (bContinue) 1149 { 1150 aFunc.RepeatDB( pDBData->GetName(), sal_True, sal_True ); 1151 RefreshPivotTables(aRange); 1152 } 1153 } 1154 1155 return bContinue != 0; 1156 } 1157 1158