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 // INCLUDE --------------------------------------------------------------- 32 33 #include <com/sun/star/i18n/TransliterationModules.hpp> 34 35 #include <unotools/textsearch.hxx> 36 #include <svl/srchitem.hxx> 37 #include <editeng/editobj.hxx> 38 39 #include "table.hxx" 40 #include "collect.hxx" 41 #include "cell.hxx" 42 #include "document.hxx" 43 #include "stlpool.hxx" 44 #include "markdata.hxx" 45 #include "editutil.hxx" 46 #include "detfunc.hxx" 47 #include "postit.hxx" 48 49 //-------------------------------------------------------------------------- 50 51 52 sal_Bool lcl_GetTextWithBreaks( const ScEditCell& rCell, ScDocument* pDoc, String& rVal ) 53 { 54 // sal_True = more than 1 paragraph 55 56 const EditTextObject* pData = NULL; 57 rCell.GetData( pData ); 58 EditEngine& rEngine = pDoc->GetEditEngine(); 59 rEngine.SetText( *pData ); 60 rVal = rEngine.GetText( LINEEND_LF ); 61 return ( rEngine.GetParagraphCount() > 1 ); 62 } 63 64 sal_Bool ScTable::SearchCell(const SvxSearchItem& rSearchItem, SCCOL nCol, SCROW nRow, 65 const ScMarkData& rMark, String& rUndoStr, ScDocument* pUndoDoc) 66 { 67 sal_Bool bFound = sal_False; 68 sal_Bool bDoSearch = sal_True; 69 sal_Bool bDoBack = rSearchItem.GetBackward(); 70 71 String aString; 72 ScBaseCell* pCell; 73 if (rSearchItem.GetSelection()) 74 bDoSearch = rMark.IsCellMarked(nCol, nRow); 75 if ( bDoSearch && ((pCell = aCol[nCol].GetCell( nRow )) != NULL) ) 76 { 77 sal_Bool bMultiLine = sal_False; 78 CellType eCellType = pCell->GetCellType(); 79 switch (rSearchItem.GetCellType()) 80 { 81 case SVX_SEARCHIN_FORMULA: 82 { 83 if ( eCellType == CELLTYPE_FORMULA ) 84 ((ScFormulaCell*)pCell)->GetFormula( aString, 85 formula::FormulaGrammar::GRAM_NATIVE_UI); 86 else if ( eCellType == CELLTYPE_EDIT ) 87 bMultiLine = lcl_GetTextWithBreaks( 88 *(const ScEditCell*)pCell, pDocument, aString ); 89 else 90 aCol[nCol].GetInputString( nRow, aString ); 91 } 92 break; 93 case SVX_SEARCHIN_VALUE: 94 if ( eCellType == CELLTYPE_EDIT ) 95 bMultiLine = lcl_GetTextWithBreaks( 96 *(const ScEditCell*)pCell, pDocument, aString ); 97 else 98 aCol[nCol].GetInputString( nRow, aString ); 99 break; 100 case SVX_SEARCHIN_NOTE: 101 { 102 if(const ScPostIt* pNote = pCell->GetNote()) 103 { 104 aString = pNote->GetText(); 105 bMultiLine = pNote->HasMultiLineText(); 106 } 107 } 108 break; 109 default: 110 break; 111 } 112 xub_StrLen nStart = 0; 113 xub_StrLen nEnd = aString.Len(); 114 ::com::sun::star::util::SearchResult aSearchResult; 115 if (pSearchText) 116 { 117 if ( bDoBack ) 118 { 119 xub_StrLen nTemp=nStart; nStart=nEnd; nEnd=nTemp; 120 bFound = (sal_Bool)(pSearchText->SearchBkwrd(aString, &nStart, &nEnd, &aSearchResult)); 121 // change results to definition before 614: 122 --nEnd; 123 } 124 else 125 { 126 bFound = (sal_Bool)(pSearchText->SearchFrwrd(aString, &nStart, &nEnd, &aSearchResult)); 127 // change results to definition before 614: 128 --nEnd; 129 } 130 131 if (bFound && rSearchItem.GetWordOnly()) 132 bFound = (nStart == 0 && nEnd == aString.Len() - 1); 133 } 134 else 135 { 136 DBG_ERROR("pSearchText == NULL"); 137 return bFound; 138 } 139 140 sal_uInt8 cMatrixFlag = MM_NONE; 141 if ( bFound && 142 ( (rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE) 143 ||(rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL) ) && 144 // #60558# Matrix nicht zerreissen, nur Matrixformel ersetzen 145 !( (eCellType == CELLTYPE_FORMULA && 146 ((cMatrixFlag = ((ScFormulaCell*)pCell)->GetMatrixFlag()) == MM_REFERENCE)) 147 // kein UndoDoc => Matrix nicht wiederherstellbar => nicht ersetzen 148 || (cMatrixFlag != MM_NONE && !pUndoDoc) ) 149 ) 150 { 151 if ( cMatrixFlag == MM_NONE && rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE ) 152 rUndoStr = aString; 153 else if (pUndoDoc) 154 { 155 ScAddress aAdr( nCol, nRow, nTab ); 156 ScBaseCell* pUndoCell = pCell->CloneWithoutNote( *pUndoDoc ); 157 pUndoDoc->PutCell( aAdr, pUndoCell); 158 } 159 sal_Bool bRepeat = !rSearchItem.GetWordOnly(); 160 do 161 { 162 // wenn der gefundene Text leer ist, nicht weitersuchen, 163 // sonst wuerde man nie mehr aufhoeren (#35410#) 164 if ( nEnd < nStart || nEnd == STRING_MAXLEN ) 165 bRepeat = sal_False; 166 167 String sReplStr = rSearchItem.GetReplaceString(); 168 if (rSearchItem.GetRegExp()) 169 { 170 String sFndStr = aString.Copy(nStart, nEnd-nStart+1); 171 pSearchText->ReplaceBackReferences( sReplStr, aString, aSearchResult ); 172 aString.Erase(nStart, nEnd-nStart+1); 173 aString.Insert(sReplStr, nStart); 174 } 175 else 176 { 177 aString.Erase(nStart, nEnd - nStart + 1); 178 aString.Insert(rSearchItem.GetReplaceString(), nStart); 179 } 180 181 // Indizes anpassen 182 if (bDoBack) 183 { 184 nEnd = nStart; 185 nStart = 0; 186 } 187 else 188 { 189 nStart = sal::static_int_cast<xub_StrLen>( nStart + sReplStr.Len() ); 190 nEnd = aString.Len(); 191 } 192 193 // weitersuchen ? 194 if (bRepeat) 195 { 196 if ( rSearchItem.GetCommand() != SVX_SEARCHCMD_REPLACE_ALL || nStart >= nEnd ) 197 bRepeat = sal_False; 198 else if (bDoBack) 199 { 200 xub_StrLen nTemp=nStart; nStart=nEnd; nEnd=nTemp; 201 bRepeat = ((sal_Bool)(pSearchText->SearchBkwrd(aString, &nStart, &nEnd))); 202 // change results to definition before 614: 203 --nEnd; 204 } 205 else 206 { 207 bRepeat = ((sal_Bool)(pSearchText->SearchFrwrd(aString, &nStart, &nEnd))); 208 // change results to definition before 614: 209 --nEnd; 210 } 211 } 212 } 213 while (bRepeat); 214 if (rSearchItem.GetCellType() == SVX_SEARCHIN_NOTE) 215 { 216 // NB: rich text format is lost. 217 // This is also true of Cells. 218 if( ScPostIt* pNote = pCell->GetNote() ) 219 pNote->SetText( ScAddress( nCol, nRow, nTab ), aString ); 220 } 221 else if ( cMatrixFlag != MM_NONE ) 222 { // #60558# Matrix nicht zerreissen 223 if ( aString.Len() > 2 ) 224 { // {} raus, erst hier damit auch "{=" durch "{=..." ersetzt werden kann 225 if ( aString.GetChar( aString.Len()-1 ) == '}' ) 226 aString.Erase( aString.Len()-1, 1 ); 227 if ( aString.GetChar(0) == '{' ) 228 aString.Erase( 0, 1 ); 229 } 230 ScAddress aAdr( nCol, nRow, nTab ); 231 ScFormulaCell* pFCell = new ScFormulaCell( pDocument, aAdr, 232 aString,formula::FormulaGrammar::GRAM_NATIVE_UI, cMatrixFlag ); 233 SCCOL nMatCols; 234 SCROW nMatRows; 235 ((ScFormulaCell*)pCell)->GetMatColsRows( nMatCols, nMatRows ); 236 pFCell->SetMatColsRows( nMatCols, nMatRows ); 237 aCol[nCol].Insert( nRow, pFCell ); 238 } 239 else if ( bMultiLine && aString.Search('\n') != STRING_NOTFOUND ) 240 PutCell( nCol, nRow, new ScEditCell( aString, pDocument ) ); 241 else 242 aCol[nCol].SetString(nRow, nTab, aString); 243 // pCell is invalid now (deleted) 244 } 245 } 246 return bFound; 247 } 248 249 sal_Bool ScTable::Search(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, 250 const ScMarkData& rMark, String& rUndoStr, ScDocument* pUndoDoc) 251 { 252 sal_Bool bFound = sal_False; 253 sal_Bool bAll = (rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND_ALL) 254 ||(rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL); 255 SCCOL nCol = rCol; 256 SCROW nRow = rRow; 257 SCCOL nLastCol; 258 SCROW nLastRow; 259 GetLastDataPos(nLastCol, nLastRow); 260 if (!bAll && rSearchItem.GetBackward()) 261 { 262 nCol = Min(nCol, (SCCOL)(nLastCol + 1)); 263 nRow = Min(nRow, (SCROW)(nLastRow + 1)); 264 if (rSearchItem.GetRowDirection()) 265 { 266 nCol--; 267 while (!bFound && ((SCsROW)nRow >= 0)) 268 { 269 while (!bFound && ((SCsCOL)nCol >= 0)) 270 { 271 bFound = SearchCell(rSearchItem, nCol, nRow, rMark, rUndoStr, pUndoDoc); 272 if (!bFound) 273 { 274 sal_Bool bIsEmpty; 275 do 276 { 277 nCol--; 278 if ((SCsCOL)nCol >= 0) 279 bIsEmpty = aCol[nCol].IsEmptyData(); 280 else 281 bIsEmpty = sal_True; 282 } 283 while (((SCsCOL)nCol >= 0) && bIsEmpty); 284 } 285 } 286 if (!bFound) 287 { 288 nCol = nLastCol; 289 nRow--; 290 } 291 } 292 } 293 else 294 { 295 nRow--; 296 while (!bFound && ((SCsCOL)nCol >= 0)) 297 { 298 while (!bFound && ((SCsROW)nRow >= 0)) 299 { 300 bFound = SearchCell(rSearchItem, nCol, nRow, rMark, rUndoStr, pUndoDoc); 301 if (!bFound) 302 { 303 if (!aCol[nCol].GetPrevDataPos(nRow)) 304 nRow = -1; 305 } 306 } 307 if (!bFound) 308 { 309 sal_Bool bIsEmpty; 310 nRow = nLastRow; 311 do 312 { 313 nCol--; 314 if ((SCsCOL)nCol >= 0) 315 bIsEmpty = aCol[nCol].IsEmptyData(); 316 else 317 bIsEmpty = sal_True; 318 } 319 while (((SCsCOL)nCol >= 0) && bIsEmpty); 320 } 321 } 322 } 323 } 324 else 325 { 326 if (!bAll && rSearchItem.GetRowDirection()) 327 { 328 nCol++; 329 while (!bFound && (nRow <= nLastRow)) 330 { 331 while (!bFound && (nCol <= nLastCol)) 332 { 333 bFound = SearchCell(rSearchItem, nCol, nRow, rMark, rUndoStr, pUndoDoc); 334 if (!bFound) 335 { 336 nCol++; 337 while ((nCol <= nLastCol) && aCol[nCol].IsEmptyData()) nCol++; 338 } 339 } 340 if (!bFound) 341 { 342 nCol = 0; 343 nRow++; 344 } 345 } 346 } 347 else 348 { 349 nRow++; 350 while (!bFound && (nCol <= nLastCol)) 351 { 352 while (!bFound && (nRow <= nLastRow)) 353 { 354 bFound = SearchCell(rSearchItem, nCol, nRow, rMark, rUndoStr, pUndoDoc); 355 if (!bFound) 356 { 357 if (!aCol[nCol].GetNextDataPos(nRow)) 358 nRow = MAXROW + 1; 359 } 360 } 361 if (!bFound) 362 { 363 nRow = 0; 364 nCol++; 365 while ((nCol <= nLastCol) && aCol[nCol].IsEmptyData()) nCol++; 366 } 367 } 368 } 369 } 370 if (bFound) 371 { 372 rCol = nCol; 373 rRow = nRow; 374 } 375 return bFound; 376 } 377 378 sal_Bool ScTable::SearchAll(const SvxSearchItem& rSearchItem, ScMarkData& rMark, 379 String& rUndoStr, ScDocument* pUndoDoc) 380 { 381 sal_Bool bFound = sal_True; 382 SCCOL nCol = 0; 383 SCROW nRow = -1; 384 385 ScMarkData aNewMark( rMark ); // Tabellen-Markierungen kopieren 386 aNewMark.ResetMark(); 387 do 388 { 389 bFound = Search(rSearchItem, nCol, nRow, rMark, rUndoStr, pUndoDoc); 390 if (bFound) 391 aNewMark.SetMultiMarkArea( ScRange( nCol, nRow, nTab ) ); 392 } 393 while (bFound); 394 395 rMark = aNewMark; // Markierung kopieren 396 //! pro Tabelle 397 398 return (aNewMark.IsMultiMarked()); 399 } 400 401 sal_Bool ScTable::Replace(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, 402 const ScMarkData& rMark, String& rUndoStr, ScDocument* pUndoDoc) 403 { 404 sal_Bool bFound = sal_False; 405 SCCOL nCol = rCol; 406 SCROW nRow = rRow; 407 if (rSearchItem.GetBackward()) 408 { 409 if (rSearchItem.GetRowDirection()) 410 nCol += 1; 411 else 412 nRow += 1; 413 } 414 else 415 { 416 if (rSearchItem.GetRowDirection()) 417 nCol -= 1; 418 else 419 nRow -= 1; 420 } 421 bFound = Search(rSearchItem, nCol, nRow, rMark, rUndoStr, pUndoDoc); 422 if (bFound) 423 { 424 rCol = nCol; 425 rRow = nRow; 426 } 427 return bFound; 428 } 429 430 sal_Bool ScTable::ReplaceAll(const SvxSearchItem& rSearchItem, ScMarkData& rMark, 431 String& rUndoStr, ScDocument* pUndoDoc) 432 { 433 sal_Bool bOldDouble = ScColumn::bDoubleAlloc; // sollte immer sal_False sein? 434 DBG_ASSERT(!bOldDouble,"bDoubleAlloc ???"); 435 ScColumn::bDoubleAlloc = sal_True; // fuer Undo-Doc 436 437 sal_Bool bFound = sal_True; 438 SCCOL nCol = 0; 439 SCROW nRow = -1; 440 441 ScMarkData aNewMark( rMark ); // Tabellen-Markierungen kopieren 442 aNewMark.ResetMark(); 443 do 444 { 445 bFound = Search(rSearchItem, nCol, nRow, rMark, rUndoStr, pUndoDoc); 446 if (bFound) 447 aNewMark.SetMultiMarkArea( ScRange( nCol, nRow, nTab ) ); 448 } 449 while (bFound); 450 451 ScColumn::bDoubleAlloc = bOldDouble; 452 453 rMark = aNewMark; // Markierung kopieren 454 //! pro Tabelle 455 456 return (aNewMark.IsMultiMarked()); 457 } 458 459 sal_Bool ScTable::SearchStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, 460 ScMarkData& rMark) 461 { 462 const ScStyleSheet* pSearchStyle = (const ScStyleSheet*) 463 pDocument->GetStyleSheetPool()->Find( 464 rSearchItem.GetSearchString(), SFX_STYLE_FAMILY_PARA ); 465 466 SCsCOL nCol = rCol; 467 SCsROW nRow = rRow; 468 sal_Bool bFound = sal_False; 469 470 sal_Bool bSelect = rSearchItem.GetSelection(); 471 sal_Bool bRows = rSearchItem.GetRowDirection(); 472 sal_Bool bBack = rSearchItem.GetBackward(); 473 short nAdd = bBack ? -1 : 1; 474 475 if (bRows) // zeilenweise 476 { 477 nRow += nAdd; 478 do 479 { 480 SCsROW nNextRow = aCol[nCol].SearchStyle( nRow, pSearchStyle, bBack, bSelect, rMark ); 481 if (!ValidRow(nNextRow)) 482 { 483 nRow = bBack ? MAXROW : 0; 484 nCol = sal::static_int_cast<SCsCOL>( nCol + nAdd ); 485 } 486 else 487 { 488 nRow = nNextRow; 489 bFound = sal_True; 490 } 491 } 492 while (!bFound && ValidCol(nCol)); 493 } 494 else // spaltenweise 495 { 496 SCsROW nNextRows[MAXCOLCOUNT]; 497 SCsCOL i; 498 for (i=0; i<=MAXCOL; i++) 499 { 500 SCsROW nSRow = nRow; 501 if (bBack) { if (i>=nCol) --nSRow; } 502 else { if (i<=nCol) ++nSRow; } 503 nNextRows[i] = aCol[i].SearchStyle( nSRow, pSearchStyle, bBack, bSelect, rMark ); 504 } 505 if (bBack) // rueckwaerts 506 { 507 nRow = -1; 508 for (i=MAXCOL; i>=0; i--) 509 if (nNextRows[i]>nRow) 510 { 511 nCol = i; 512 nRow = nNextRows[i]; 513 bFound = sal_True; 514 } 515 } 516 else // vorwaerts 517 { 518 nRow = MAXROW+1; 519 for (i=0; i<=MAXCOL; i++) 520 if (nNextRows[i]<nRow) 521 { 522 nCol = i; 523 nRow = nNextRows[i]; 524 bFound = sal_True; 525 } 526 } 527 } 528 529 if (bFound) 530 { 531 rCol = (SCCOL) nCol; 532 rRow = (SCROW) nRow; 533 } 534 return bFound; 535 } 536 537 //! einzelnes Pattern fuer Undo zurueckgeben 538 539 sal_Bool ScTable::ReplaceStyle(const SvxSearchItem& rSearchItem, SCCOL& rCol, SCROW& rRow, 540 ScMarkData& rMark, sal_Bool bIsUndo) 541 { 542 sal_Bool bRet; 543 if (bIsUndo) 544 bRet = sal_True; 545 else 546 bRet = SearchStyle(rSearchItem, rCol, rRow, rMark); 547 if (bRet) 548 { 549 const ScStyleSheet* pReplaceStyle = (const ScStyleSheet*) 550 pDocument->GetStyleSheetPool()->Find( 551 rSearchItem.GetReplaceString(), SFX_STYLE_FAMILY_PARA ); 552 553 if (pReplaceStyle) 554 ApplyStyle( rCol, rRow, *pReplaceStyle ); 555 else 556 { 557 DBG_ERROR("pReplaceStyle==0"); 558 } 559 } 560 561 return bRet; 562 } 563 564 sal_Bool ScTable::SearchAllStyle(const SvxSearchItem& rSearchItem, ScMarkData& rMark) 565 { 566 const ScStyleSheet* pSearchStyle = (const ScStyleSheet*) 567 pDocument->GetStyleSheetPool()->Find( 568 rSearchItem.GetSearchString(), SFX_STYLE_FAMILY_PARA ); 569 sal_Bool bSelect = rSearchItem.GetSelection(); 570 sal_Bool bBack = rSearchItem.GetBackward(); 571 572 ScMarkData aNewMark( rMark ); // Tabellen-Markierungen kopieren 573 aNewMark.ResetMark(); 574 for (SCCOL i=0; i<=MAXCOL; i++) 575 { 576 sal_Bool bFound = sal_True; 577 SCsROW nRow = 0; 578 SCsROW nEndRow; 579 while (bFound && nRow <= MAXROW) 580 { 581 bFound = aCol[i].SearchStyleRange( nRow, nEndRow, pSearchStyle, bBack, bSelect, rMark ); 582 if (bFound) 583 { 584 if (nEndRow<nRow) 585 { 586 SCsROW nTemp = nRow; 587 nRow = nEndRow; 588 nEndRow = nTemp; 589 } 590 aNewMark.SetMultiMarkArea( ScRange( i,nRow,nTab, i,nEndRow,nTab ) ); 591 nRow = nEndRow + 1; 592 } 593 } 594 } 595 596 rMark = aNewMark; // Markierung kopieren 597 //! pro Tabelle 598 599 return (aNewMark.IsMultiMarked()); 600 } 601 602 sal_Bool ScTable::ReplaceAllStyle(const SvxSearchItem& rSearchItem, ScMarkData& rMark, 603 ScDocument* pUndoDoc) 604 { 605 sal_Bool bRet = SearchAllStyle(rSearchItem, rMark); 606 if (bRet) 607 { 608 const ScStyleSheet* pReplaceStyle = (const ScStyleSheet*) 609 pDocument->GetStyleSheetPool()->Find( 610 rSearchItem.GetReplaceString(), SFX_STYLE_FAMILY_PARA ); 611 612 if (pReplaceStyle) 613 { 614 if (pUndoDoc) 615 pDocument->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, 616 IDF_ATTRIB, sal_True, pUndoDoc, &rMark ); 617 ApplySelectionStyle( *pReplaceStyle, rMark ); 618 } 619 else 620 { 621 DBG_ERROR("pReplaceStyle==0"); 622 } 623 } 624 625 return bRet; 626 } 627 628 sal_Bool ScTable::SearchAndReplace(const SvxSearchItem& rSearchItem, 629 SCCOL& rCol, SCROW& rRow, ScMarkData& rMark, 630 String& rUndoStr, ScDocument* pUndoDoc) 631 { 632 sal_uInt16 nCommand = rSearchItem.GetCommand(); 633 sal_Bool bFound = sal_False; 634 if ( ValidColRow(rCol, rRow) || 635 ((nCommand == SVX_SEARCHCMD_FIND || nCommand == SVX_SEARCHCMD_REPLACE) && 636 (((rCol == MAXCOLCOUNT || rCol == -1) && VALIDROW(rRow)) || 637 ((rRow == MAXROWCOUNT || rRow == -1) && VALIDCOL(rCol)) 638 ) 639 ) 640 ) 641 { 642 sal_Bool bStyles = rSearchItem.GetPattern(); 643 if (bStyles) 644 { 645 if (nCommand == SVX_SEARCHCMD_FIND) 646 bFound = SearchStyle(rSearchItem, rCol, rRow, rMark); 647 else if (nCommand == SVX_SEARCHCMD_REPLACE) 648 bFound = ReplaceStyle(rSearchItem, rCol, rRow, rMark, sal_False); 649 else if (nCommand == SVX_SEARCHCMD_FIND_ALL) 650 bFound = SearchAllStyle(rSearchItem, rMark); 651 else if (nCommand == SVX_SEARCHCMD_REPLACE_ALL) 652 bFound = ReplaceAllStyle(rSearchItem, rMark, pUndoDoc); 653 } 654 else 655 { 656 // SearchParam no longer needed - SearchOptions contains all settings 657 com::sun::star::util::SearchOptions aSearchOptions = rSearchItem.GetSearchOptions(); 658 aSearchOptions.Locale = *ScGlobal::GetLocale(); 659 660 // #107259# reflect UseAsianOptions flag in SearchOptions 661 // (use only ignore case and width if asian options are disabled). 662 // This is also done in SvxSearchDialog CommandHdl, but not in API object. 663 if ( !rSearchItem.IsUseAsianOptions() ) 664 aSearchOptions.transliterateFlags &= 665 ( com::sun::star::i18n::TransliterationModules_IGNORE_CASE | 666 com::sun::star::i18n::TransliterationModules_IGNORE_WIDTH ); 667 668 pSearchText = new utl::TextSearch( aSearchOptions ); 669 670 if (nCommand == SVX_SEARCHCMD_FIND) 671 bFound = Search(rSearchItem, rCol, rRow, rMark, rUndoStr, pUndoDoc); 672 else if (nCommand == SVX_SEARCHCMD_FIND_ALL) 673 bFound = SearchAll(rSearchItem, rMark, rUndoStr, pUndoDoc); 674 else if (nCommand == SVX_SEARCHCMD_REPLACE) 675 bFound = Replace(rSearchItem, rCol, rRow, rMark, rUndoStr, pUndoDoc); 676 else if (nCommand == SVX_SEARCHCMD_REPLACE_ALL) 677 bFound = ReplaceAll(rSearchItem, rMark, rUndoStr, pUndoDoc); 678 679 delete pSearchText; 680 pSearchText = NULL; 681 } 682 } 683 return bFound; 684 } 685 686 687 688 689 690 691