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 <sfx2/docfile.hxx> 36 #include <sfx2/objsh.hxx> 37 #include <unotools/textsearch.hxx> 38 #include <unotools/pathoptions.hxx> 39 #include <unotools/useroptions.hxx> 40 #include <tools/urlobj.hxx> 41 #include <unotools/charclass.hxx> 42 #include <stdlib.h> 43 #include <ctype.h> 44 #include <unotools/syslocale.hxx> 45 46 #include "global.hxx" 47 #include "rangeutl.hxx" 48 #include "rechead.hxx" 49 #include "compiler.hxx" 50 #include "paramisc.hxx" 51 52 #include "sc.hrc" 53 #include "globstr.hrc" 54 55 using ::std::vector; 56 57 // ----------------------------------------------------------------------- 58 59 60 61 62 //------------------------------------------------------------------------ 63 // struct ScImportParam: 64 65 ScImportParam::ScImportParam() : 66 nCol1(0), 67 nRow1(0), 68 nCol2(0), 69 nRow2(0), 70 bImport(sal_False), 71 bNative(sal_False), 72 bSql(sal_True), 73 nType(ScDbTable) 74 { 75 } 76 77 ScImportParam::ScImportParam( const ScImportParam& r ) : 78 nCol1 (r.nCol1), 79 nRow1 (r.nRow1), 80 nCol2 (r.nCol2), 81 nRow2 (r.nRow2), 82 bImport (r.bImport), 83 aDBName (r.aDBName), 84 aStatement (r.aStatement), 85 bNative (r.bNative), 86 bSql (r.bSql), 87 nType (r.nType) 88 { 89 } 90 91 ScImportParam::~ScImportParam() 92 { 93 } 94 95 //UNUSED2009-05 void ScImportParam::Clear() 96 //UNUSED2009-05 { 97 //UNUSED2009-05 nCol1 = nCol2 = 0; 98 //UNUSED2009-05 nRow1 = nRow2 = 0; 99 //UNUSED2009-05 bImport = sal_False; 100 //UNUSED2009-05 bNative = sal_False; 101 //UNUSED2009-05 bSql = sal_True; 102 //UNUSED2009-05 nType = ScDbTable; 103 //UNUSED2009-05 aDBName.Erase(); 104 //UNUSED2009-05 aStatement.Erase(); 105 //UNUSED2009-05 } 106 107 ScImportParam& ScImportParam::operator=( const ScImportParam& r ) 108 { 109 nCol1 = r.nCol1; 110 nRow1 = r.nRow1; 111 nCol2 = r.nCol2; 112 nRow2 = r.nRow2; 113 bImport = r.bImport; 114 aDBName = r.aDBName; 115 aStatement = r.aStatement; 116 bNative = r.bNative; 117 bSql = r.bSql; 118 nType = r.nType; 119 120 return *this; 121 } 122 123 sal_Bool ScImportParam::operator==( const ScImportParam& rOther ) const 124 { 125 return( nCol1 == rOther.nCol1 && 126 nRow1 == rOther.nRow1 && 127 nCol2 == rOther.nCol2 && 128 nRow2 == rOther.nRow2 && 129 bImport == rOther.bImport && 130 aDBName == rOther.aDBName && 131 aStatement == rOther.aStatement && 132 bNative == rOther.bNative && 133 bSql == rOther.bSql && 134 nType == rOther.nType ); 135 136 //! nQuerySh und pConnection sind gleich ? 137 } 138 139 140 //------------------------------------------------------------------------ 141 // struct ScQueryParam: 142 143 ScQueryEntry::ScQueryEntry() : 144 bDoQuery(sal_False), 145 bQueryByString(sal_False), 146 bQueryByDate(false), 147 nField(0), 148 eOp(SC_EQUAL), 149 eConnect(SC_AND), 150 pStr(new String), 151 nVal(0.0), 152 pSearchParam(NULL), 153 pSearchText(NULL) 154 { 155 } 156 157 ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) : 158 bDoQuery(r.bDoQuery), 159 bQueryByString(r.bQueryByString), 160 bQueryByDate(r.bQueryByDate), 161 nField(r.nField), 162 eOp(r.eOp), 163 eConnect(r.eConnect), 164 pStr(new String(*r.pStr)), 165 nVal(r.nVal), 166 pSearchParam(NULL), 167 pSearchText(NULL) 168 { 169 } 170 171 ScQueryEntry::~ScQueryEntry() 172 { 173 delete pStr; 174 if ( pSearchParam ) 175 { 176 delete pSearchParam; 177 delete pSearchText; 178 } 179 } 180 181 ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r ) 182 { 183 bDoQuery = r.bDoQuery; 184 bQueryByString = r.bQueryByString; 185 bQueryByDate = r.bQueryByDate; 186 eOp = r.eOp; 187 eConnect = r.eConnect; 188 nField = r.nField; 189 nVal = r.nVal; 190 *pStr = *r.pStr; 191 if ( pSearchParam ) 192 { 193 delete pSearchParam; 194 delete pSearchText; 195 } 196 pSearchParam = NULL; 197 pSearchText = NULL; 198 199 return *this; 200 } 201 202 void ScQueryEntry::Clear() 203 { 204 bDoQuery = sal_False; 205 bQueryByString = sal_False; 206 bQueryByDate = false; 207 eOp = SC_EQUAL; 208 eConnect = SC_AND; 209 nField = 0; 210 nVal = 0.0; 211 pStr->Erase(); 212 if ( pSearchParam ) 213 { 214 delete pSearchParam; 215 delete pSearchText; 216 } 217 pSearchParam = NULL; 218 pSearchText = NULL; 219 } 220 221 sal_Bool ScQueryEntry::operator==( const ScQueryEntry& r ) const 222 { 223 return bDoQuery == r.bDoQuery 224 && bQueryByString == r.bQueryByString 225 && bQueryByDate == r.bQueryByDate 226 && eOp == r.eOp 227 && eConnect == r.eConnect 228 && nField == r.nField 229 && nVal == r.nVal 230 && *pStr == *r.pStr; 231 //! pSearchParam und pSearchText nicht vergleichen 232 } 233 234 utl::TextSearch* ScQueryEntry::GetSearchTextPtr( sal_Bool bCaseSens ) 235 { 236 if ( !pSearchParam ) 237 { 238 pSearchParam = new utl::SearchParam( *pStr, utl::SearchParam::SRCH_REGEXP, 239 bCaseSens, sal_False, sal_False ); 240 pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass ); 241 } 242 return pSearchText; 243 } 244 245 //------------------------------------------------------------------------ 246 // struct ScSubTotalParam: 247 248 ScSubTotalParam::ScSubTotalParam() 249 { 250 for ( sal_uInt16 i=0; i<MAXSUBTOTAL; i++ ) 251 { 252 nSubTotals[i] = 0; 253 pSubTotals[i] = NULL; 254 pFunctions[i] = NULL; 255 } 256 257 Clear(); 258 } 259 260 //------------------------------------------------------------------------ 261 262 ScSubTotalParam::ScSubTotalParam( const ScSubTotalParam& r ) : 263 nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2), 264 bRemoveOnly(r.bRemoveOnly),bReplace(r.bReplace),bPagebreak(r.bPagebreak),bCaseSens(r.bCaseSens), 265 bDoSort(r.bDoSort),bAscending(r.bAscending),bUserDef(r.bUserDef),nUserIndex(r.nUserIndex), 266 bIncludePattern(r.bIncludePattern) 267 { 268 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++) 269 { 270 bGroupActive[i] = r.bGroupActive[i]; 271 nField[i] = r.nField[i]; 272 273 if ( (r.nSubTotals[i] > 0) && r.pSubTotals[i] && r.pFunctions[i] ) 274 { 275 nSubTotals[i] = r.nSubTotals[i]; 276 pSubTotals[i] = new SCCOL [r.nSubTotals[i]]; 277 pFunctions[i] = new ScSubTotalFunc [r.nSubTotals[i]]; 278 279 for (SCCOL j=0; j<r.nSubTotals[i]; j++) 280 { 281 pSubTotals[i][j] = r.pSubTotals[i][j]; 282 pFunctions[i][j] = r.pFunctions[i][j]; 283 } 284 } 285 else 286 { 287 nSubTotals[i] = 0; 288 pSubTotals[i] = NULL; 289 pFunctions[i] = NULL; 290 } 291 } 292 } 293 294 //------------------------------------------------------------------------ 295 296 void ScSubTotalParam::Clear() 297 { 298 nCol1=nCol2= 0; 299 nRow1=nRow2 = 0; 300 nUserIndex = 0; 301 bPagebreak=bCaseSens=bUserDef=bIncludePattern=bRemoveOnly = sal_False; 302 bAscending=bReplace=bDoSort = sal_True; 303 304 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++) 305 { 306 bGroupActive[i] = sal_False; 307 nField[i] = 0; 308 309 if ( (nSubTotals[i] > 0) && pSubTotals[i] && pFunctions[i] ) 310 { 311 for ( SCCOL j=0; j<nSubTotals[i]; j++ ) { 312 pSubTotals[i][j] = 0; 313 pFunctions[i][j] = SUBTOTAL_FUNC_NONE; 314 } 315 } 316 } 317 } 318 319 //------------------------------------------------------------------------ 320 321 ScSubTotalParam& ScSubTotalParam::operator=( const ScSubTotalParam& r ) 322 { 323 nCol1 = r.nCol1; 324 nRow1 = r.nRow1; 325 nCol2 = r.nCol2; 326 nRow2 = r.nRow2; 327 bRemoveOnly = r.bRemoveOnly; 328 bReplace = r.bReplace; 329 bPagebreak = r.bPagebreak; 330 bCaseSens = r.bCaseSens; 331 bDoSort = r.bDoSort; 332 bAscending = r.bAscending; 333 bUserDef = r.bUserDef; 334 nUserIndex = r.nUserIndex; 335 bIncludePattern = r.bIncludePattern; 336 337 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++) 338 { 339 bGroupActive[i] = r.bGroupActive[i]; 340 nField[i] = r.nField[i]; 341 nSubTotals[i] = r.nSubTotals[i]; 342 343 if ( pSubTotals[i] ) delete [] pSubTotals[i]; 344 if ( pFunctions[i] ) delete [] pFunctions[i]; 345 346 if ( r.nSubTotals[i] > 0 ) 347 { 348 pSubTotals[i] = new SCCOL [r.nSubTotals[i]]; 349 pFunctions[i] = new ScSubTotalFunc [r.nSubTotals[i]]; 350 351 for (SCCOL j=0; j<r.nSubTotals[i]; j++) 352 { 353 pSubTotals[i][j] = r.pSubTotals[i][j]; 354 pFunctions[i][j] = r.pFunctions[i][j]; 355 } 356 } 357 else 358 { 359 nSubTotals[i] = 0; 360 pSubTotals[i] = NULL; 361 pFunctions[i] = NULL; 362 } 363 } 364 365 return *this; 366 } 367 368 //------------------------------------------------------------------------ 369 370 sal_Bool ScSubTotalParam::operator==( const ScSubTotalParam& rOther ) const 371 { 372 sal_Bool bEqual = (nCol1 == rOther.nCol1) 373 && (nRow1 == rOther.nRow1) 374 && (nCol2 == rOther.nCol2) 375 && (nRow2 == rOther.nRow2) 376 && (bRemoveOnly == rOther.bRemoveOnly) 377 && (bReplace == rOther.bReplace) 378 && (bPagebreak == rOther.bPagebreak) 379 && (bDoSort == rOther.bDoSort) 380 && (bCaseSens == rOther.bCaseSens) 381 && (bAscending == rOther.bAscending) 382 && (bUserDef == rOther.bUserDef) 383 && (nUserIndex == rOther.nUserIndex) 384 && (bIncludePattern== rOther.bIncludePattern); 385 386 if ( bEqual ) 387 { 388 bEqual = sal_True; 389 for ( sal_uInt16 i=0; i<MAXSUBTOTAL && bEqual; i++ ) 390 { 391 bEqual = (bGroupActive[i] == rOther.bGroupActive[i]) 392 && (nField[i] == rOther.nField[i]) 393 && (nSubTotals[i] == rOther.nSubTotals[i]); 394 395 if ( bEqual && (nSubTotals[i] > 0) ) 396 { 397 bEqual = (pSubTotals != NULL) && (pFunctions != NULL); 398 399 for (SCCOL j=0; (j<nSubTotals[i]) && bEqual; j++) 400 { 401 bEqual = bEqual 402 && (pSubTotals[i][j] == rOther.pSubTotals[i][j]) 403 && (pFunctions[i][j] == rOther.pFunctions[i][j]); 404 } 405 } 406 } 407 } 408 409 return bEqual; 410 } 411 412 //------------------------------------------------------------------------ 413 414 void ScSubTotalParam::SetSubTotals( sal_uInt16 nGroup, 415 const SCCOL* ptrSubTotals, 416 const ScSubTotalFunc* ptrFunctions, 417 sal_uInt16 nCount ) 418 { 419 DBG_ASSERT( (nGroup <= MAXSUBTOTAL), 420 "ScSubTotalParam::SetSubTotals(): nGroup > MAXSUBTOTAL!" ); 421 DBG_ASSERT( ptrSubTotals, 422 "ScSubTotalParam::SetSubTotals(): ptrSubTotals == NULL!" ); 423 DBG_ASSERT( ptrFunctions, 424 "ScSubTotalParam::SetSubTotals(): ptrFunctions == NULL!" ); 425 DBG_ASSERT( (nCount > 0), 426 "ScSubTotalParam::SetSubTotals(): nCount <= 0!" ); 427 428 if ( ptrSubTotals && ptrFunctions && (nCount > 0) && (nGroup <= MAXSUBTOTAL) ) 429 { 430 // 0 wird als 1 aufgefasst, sonst zum Array-Index dekrementieren 431 if (nGroup != 0) 432 nGroup--; 433 434 delete [] pSubTotals[nGroup]; 435 delete [] pFunctions[nGroup]; 436 437 pSubTotals[nGroup] = new SCCOL [nCount]; 438 pFunctions[nGroup] = new ScSubTotalFunc [nCount]; 439 nSubTotals[nGroup] = static_cast<SCCOL>(nCount); 440 441 for ( sal_uInt16 i=0; i<nCount; i++ ) 442 { 443 pSubTotals[nGroup][i] = ptrSubTotals[i]; 444 pFunctions[nGroup][i] = ptrFunctions[i]; 445 } 446 } 447 } 448 449 //------------------------------------------------------------------------ 450 // struct ScConsolidateParam: 451 452 ScConsolidateParam::ScConsolidateParam() : 453 ppDataAreas( NULL ) 454 { 455 Clear(); 456 } 457 458 //------------------------------------------------------------------------ 459 460 ScConsolidateParam::ScConsolidateParam( const ScConsolidateParam& r ) : 461 nCol(r.nCol),nRow(r.nRow),nTab(r.nTab), 462 eFunction(r.eFunction),nDataAreaCount(0), 463 ppDataAreas( NULL ), 464 bByCol(r.bByCol),bByRow(r.bByRow),bReferenceData(r.bReferenceData) 465 { 466 if ( r.nDataAreaCount > 0 ) 467 { 468 nDataAreaCount = r.nDataAreaCount; 469 ppDataAreas = new ScArea*[nDataAreaCount]; 470 for ( sal_uInt16 i=0; i<nDataAreaCount; i++ ) 471 ppDataAreas[i] = new ScArea( *(r.ppDataAreas[i]) ); 472 } 473 } 474 475 //------------------------------------------------------------------------ 476 477 __EXPORT ScConsolidateParam::~ScConsolidateParam() 478 { 479 ClearDataAreas(); 480 } 481 482 //------------------------------------------------------------------------ 483 484 void __EXPORT ScConsolidateParam::ClearDataAreas() 485 { 486 if ( ppDataAreas ) 487 { 488 for ( sal_uInt16 i=0; i<nDataAreaCount; i++ ) 489 delete ppDataAreas[i]; 490 delete [] ppDataAreas; 491 ppDataAreas = NULL; 492 } 493 nDataAreaCount = 0; 494 } 495 496 //------------------------------------------------------------------------ 497 498 void __EXPORT ScConsolidateParam::Clear() 499 { 500 ClearDataAreas(); 501 502 nCol = 0; 503 nRow = 0; 504 nTab = 0; 505 bByCol = bByRow = bReferenceData = sal_False; 506 eFunction = SUBTOTAL_FUNC_SUM; 507 } 508 509 //------------------------------------------------------------------------ 510 511 ScConsolidateParam& __EXPORT ScConsolidateParam::operator=( const ScConsolidateParam& r ) 512 { 513 nCol = r.nCol; 514 nRow = r.nRow; 515 nTab = r.nTab; 516 bByCol = r.bByCol; 517 bByRow = r.bByRow; 518 bReferenceData = r.bReferenceData; 519 eFunction = r.eFunction; 520 SetAreas( r.ppDataAreas, r.nDataAreaCount ); 521 522 return *this; 523 } 524 525 //------------------------------------------------------------------------ 526 527 sal_Bool __EXPORT ScConsolidateParam::operator==( const ScConsolidateParam& r ) const 528 { 529 sal_Bool bEqual = (nCol == r.nCol) 530 && (nRow == r.nRow) 531 && (nTab == r.nTab) 532 && (bByCol == r.bByCol) 533 && (bByRow == r.bByRow) 534 && (bReferenceData == r.bReferenceData) 535 && (nDataAreaCount == r.nDataAreaCount) 536 && (eFunction == r.eFunction); 537 538 if ( nDataAreaCount == 0 ) 539 bEqual = bEqual && (ppDataAreas == NULL) && (r.ppDataAreas == NULL); 540 else 541 bEqual = bEqual && (ppDataAreas != NULL) && (r.ppDataAreas != NULL); 542 543 if ( bEqual && (nDataAreaCount > 0) ) 544 for ( sal_uInt16 i=0; i<nDataAreaCount && bEqual; i++ ) 545 bEqual = *(ppDataAreas[i]) == *(r.ppDataAreas[i]); 546 547 return bEqual; 548 } 549 550 //------------------------------------------------------------------------ 551 552 void __EXPORT ScConsolidateParam::SetAreas( ScArea* const* ppAreas, sal_uInt16 nCount ) 553 { 554 ClearDataAreas(); 555 if ( ppAreas && nCount > 0 ) 556 { 557 ppDataAreas = new ScArea*[nCount]; 558 for ( sal_uInt16 i=0; i<nCount; i++ ) 559 ppDataAreas[i] = new ScArea( *(ppAreas[i]) ); 560 nDataAreaCount = nCount; 561 } 562 } 563 564 //------------------------------------------------------------------------ 565 // struct ScSolveParam 566 567 ScSolveParam::ScSolveParam() 568 : pStrTargetVal( NULL ) 569 { 570 } 571 572 //------------------------------------------------------------------------ 573 574 ScSolveParam::ScSolveParam( const ScSolveParam& r ) 575 : aRefFormulaCell ( r.aRefFormulaCell ), 576 aRefVariableCell( r.aRefVariableCell ), 577 pStrTargetVal ( r.pStrTargetVal 578 ? new String(*r.pStrTargetVal) 579 : NULL ) 580 { 581 } 582 583 //------------------------------------------------------------------------ 584 585 ScSolveParam::ScSolveParam( const ScAddress& rFormulaCell, 586 const ScAddress& rVariableCell, 587 const String& rTargetValStr ) 588 : aRefFormulaCell ( rFormulaCell ), 589 aRefVariableCell( rVariableCell ), 590 pStrTargetVal ( new String(rTargetValStr) ) 591 { 592 } 593 594 //------------------------------------------------------------------------ 595 596 ScSolveParam::~ScSolveParam() 597 { 598 delete pStrTargetVal; 599 } 600 601 //------------------------------------------------------------------------ 602 603 ScSolveParam& __EXPORT ScSolveParam::operator=( const ScSolveParam& r ) 604 { 605 delete pStrTargetVal; 606 607 aRefFormulaCell = r.aRefFormulaCell; 608 aRefVariableCell = r.aRefVariableCell; 609 pStrTargetVal = r.pStrTargetVal 610 ? new String(*r.pStrTargetVal) 611 : NULL; 612 return *this; 613 } 614 615 //------------------------------------------------------------------------ 616 617 sal_Bool ScSolveParam::operator==( const ScSolveParam& r ) const 618 { 619 sal_Bool bEqual = (aRefFormulaCell == r.aRefFormulaCell) 620 && (aRefVariableCell == r.aRefVariableCell); 621 622 if ( bEqual ) 623 { 624 if ( !pStrTargetVal && !r.pStrTargetVal ) 625 bEqual = sal_True; 626 else if ( !pStrTargetVal || !r.pStrTargetVal ) 627 bEqual = sal_False; 628 else if ( pStrTargetVal && r.pStrTargetVal ) 629 bEqual = ( *pStrTargetVal == *(r.pStrTargetVal) ); 630 } 631 632 return bEqual; 633 } 634 635 636 //------------------------------------------------------------------------ 637 // struct ScTabOpParam 638 639 ScTabOpParam::ScTabOpParam( const ScTabOpParam& r ) 640 : aRefFormulaCell ( r.aRefFormulaCell ), 641 aRefFormulaEnd ( r.aRefFormulaEnd ), 642 aRefRowCell ( r.aRefRowCell ), 643 aRefColCell ( r.aRefColCell ), 644 nMode ( r.nMode ) 645 { 646 } 647 648 //------------------------------------------------------------------------ 649 650 ScTabOpParam::ScTabOpParam( const ScRefAddress& rFormulaCell, 651 const ScRefAddress& rFormulaEnd, 652 const ScRefAddress& rRowCell, 653 const ScRefAddress& rColCell, 654 sal_uInt8 nMd) 655 : aRefFormulaCell ( rFormulaCell ), 656 aRefFormulaEnd ( rFormulaEnd ), 657 aRefRowCell ( rRowCell ), 658 aRefColCell ( rColCell ), 659 nMode ( nMd ) 660 { 661 } 662 663 //------------------------------------------------------------------------ 664 665 ScTabOpParam& ScTabOpParam::operator=( const ScTabOpParam& r ) 666 { 667 aRefFormulaCell = r.aRefFormulaCell; 668 aRefFormulaEnd = r.aRefFormulaEnd; 669 aRefRowCell = r.aRefRowCell; 670 aRefColCell = r.aRefColCell; 671 nMode = r.nMode; 672 return *this; 673 } 674 675 //------------------------------------------------------------------------ 676 677 sal_Bool __EXPORT ScTabOpParam::operator==( const ScTabOpParam& r ) const 678 { 679 return ( (aRefFormulaCell == r.aRefFormulaCell) 680 && (aRefFormulaEnd == r.aRefFormulaEnd) 681 && (aRefRowCell == r.aRefRowCell) 682 && (aRefColCell == r.aRefColCell) 683 && (nMode == r.nMode) ); 684 } 685 686 String ScGlobal::GetAbsDocName( const String& rFileName, 687 SfxObjectShell* pShell ) 688 { 689 String aAbsName; 690 if ( !pShell->HasName() ) 691 { // maybe relative to document path working directory 692 INetURLObject aObj; 693 SvtPathOptions aPathOpt; 694 aObj.SetSmartURL( aPathOpt.GetWorkPath() ); 695 aObj.setFinalSlash(); // it IS a path 696 bool bWasAbs = true; 697 aAbsName = aObj.smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::NO_DECODE); 698 // returned string must be encoded because it's used directly to create SfxMedium 699 } 700 else 701 { 702 const SfxMedium* pMedium = pShell->GetMedium(); 703 if ( pMedium ) 704 { 705 bool bWasAbs = true; 706 aAbsName = pMedium->GetURLObject().smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::NO_DECODE); 707 } 708 else 709 { // This can't happen, but ... 710 // just to be sure to have the same encoding 711 INetURLObject aObj; 712 aObj.SetSmartURL( aAbsName ); 713 aAbsName = aObj.GetMainURL(INetURLObject::NO_DECODE); 714 } 715 } 716 return aAbsName; 717 } 718 719 720 String ScGlobal::GetDocTabName( const String& rFileName, 721 const String& rTabName ) 722 { 723 String aDocTab( '\'' ); 724 aDocTab += rFileName; 725 xub_StrLen nPos = 1; 726 while( (nPos = aDocTab.Search( '\'', nPos )) 727 != STRING_NOTFOUND ) 728 { // escape Quotes 729 aDocTab.Insert( '\\', nPos ); 730 nPos += 2; 731 } 732 aDocTab += '\''; 733 aDocTab += SC_COMPILER_FILE_TAB_SEP; 734 aDocTab += rTabName; // "'Doc'#Tab" 735 return aDocTab; 736 } 737 738