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 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_sw.hxx" 24 25 #include <string.h> 26 27 #include <vcl/window.hxx> 28 29 #include <wrtsh.hxx> 30 31 #include <sfx2/bindings.hxx> 32 #include <sfx2/dispatch.hxx> 33 #include <sfx2/request.hxx> 34 #include <editeng/eeitem.hxx> 35 #include <editeng/editeng.hxx> 36 #include <editeng/editdata.hxx> 37 #include <editeng/outliner.hxx> 38 #include <editeng/editview.hxx> 39 #include <editeng/scripttypeitem.hxx> 40 #include <editeng/langitem.hxx> 41 42 #include <svl/languageoptions.hxx> 43 #include <svtools/langtab.hxx> 44 #include <svl/slstitm.hxx> 45 #include <svl/svstdarr.hxx> 46 #include <svl/stritem.hxx> 47 48 #include <ndtxt.hxx> 49 #include <pam.hxx> 50 #include <view.hxx> 51 #include <viewopt.hxx> 52 53 #include "swabstdlg.hxx" 54 55 #include <vcl/msgbox.hxx> 56 57 #include <langhelper.hxx> 58 59 using namespace ::com::sun::star; 60 61 namespace SwLangHelper 62 { 63 64 sal_uInt16 GetLanguageStatus( OutlinerView* pOLV, SfxItemSet& rSet ) 65 { 66 ESelection aSelection = pOLV->GetSelection(); 67 EditView& rEditView=pOLV->GetEditView(); 68 EditEngine* pEditEngine=rEditView.GetEditEngine(); 69 70 // the value of used script types 71 const sal_uInt16 nScriptType =pOLV->GetSelectedScriptType(); 72 String aScriptTypesInUse( String::CreateFromInt32( nScriptType ) );//pEditEngine->GetScriptType(aSelection) 73 74 SvtLanguageTable aLangTable; 75 76 // get keyboard language 77 String aKeyboardLang; 78 LanguageType nLang = LANGUAGE_DONTKNOW; 79 80 Window* pWin = rEditView.GetWindow(); 81 if(pWin) 82 nLang = pWin->GetInputLanguage(); 83 if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) 84 aKeyboardLang = aLangTable.GetString( nLang ); 85 86 // get the language that is in use 87 const String aMultipleLanguages = String::CreateFromAscii("*"); 88 String aCurrentLang = aMultipleLanguages; 89 SfxItemSet aSet(pOLV->GetAttribs()); 90 nLang = SwLangHelper::GetCurrentLanguage( aSet,nScriptType ); 91 if (nLang != LANGUAGE_DONTKNOW) 92 aCurrentLang = aLangTable.GetString( nLang ); 93 94 // build sequence for status value 95 uno::Sequence< ::rtl::OUString > aSeq( 4 ); 96 aSeq[0] = aCurrentLang; 97 aSeq[1] = aScriptTypesInUse; 98 aSeq[2] = aKeyboardLang; 99 aSeq[3] = SwLangHelper::GetTextForLanguageGuessing( pEditEngine, aSelection ); 100 101 // set sequence as status value 102 SfxStringListItem aItem( SID_LANGUAGE_STATUS ); 103 aItem.SetStringList( aSeq ); 104 rSet.Put( aItem, SID_LANGUAGE_STATUS ); 105 return 0; 106 } 107 108 bool SetLanguageStatus( OutlinerView* pOLV, SfxRequest &rReq, SwView &rView, SwWrtShell &rSh ) 109 { 110 bool bRestoreSelection = false; 111 SfxItemSet aEditAttr(pOLV->GetAttribs()); 112 ESelection aSelection = pOLV->GetSelection(); 113 EditView & rEditView = pOLV->GetEditView(); 114 EditEngine * pEditEngine = rEditView.GetEditEngine(); 115 116 // get the language 117 String aNewLangTxt; 118 119 SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, SID_LANGUAGE_STATUS , sal_False ); 120 if (pItem) 121 aNewLangTxt = pItem->GetValue(); 122 123 //!! Remember the view frame right now... 124 //!! (call to GetView().GetViewFrame() will break if the 125 //!! SwTextShell got destroyed meanwhile.) 126 SfxViewFrame *pViewFrame = rView.GetViewFrame(); 127 128 if (aNewLangTxt.EqualsAscii( "*" )) 129 { 130 // open the dialog "Tools/Options/Language Settings - Language" 131 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 132 if (pFact) 133 { 134 VclAbstractDialog* pDlg = pFact->CreateVclDialog( rView.GetWindow(), SID_LANGUAGE_OPTIONS ); 135 pDlg->Execute(); 136 delete pDlg; 137 } 138 } 139 else 140 { 141 // setting the new language... 142 if (aNewLangTxt.Len() > 0) 143 { 144 const String aSelectionLangPrefix( String::CreateFromAscii("Current_") ); 145 const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") ); 146 const String aDocumentLangPrefix( String::CreateFromAscii("Default_") ); 147 const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") ); 148 const String aStrResetLangs( String::CreateFromAscii("RESET_LANGUAGES") ); 149 150 xub_StrLen nPos = 0; 151 bool bForSelection = true; 152 bool bForParagraph = false; 153 if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 ))) 154 { 155 // ... for the current selection 156 aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.Len() ); 157 bForSelection = true; 158 } 159 else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 ))) 160 { 161 // ... for the current paragraph language 162 aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.Len() ); 163 bForSelection = true; 164 bForParagraph = true; 165 } 166 else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 ))) 167 { 168 // ... as default document language 169 aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.Len() ); 170 bForSelection = false; 171 } 172 173 if (bForParagraph) 174 { 175 bRestoreSelection = true; 176 SwLangHelper::SelectPara( rEditView, aSelection ); 177 aSelection = pOLV->GetSelection(); 178 } 179 if (!bForSelection) // document language to be changed... 180 { 181 rSh.StartAction(); 182 rSh.LockView( sal_True ); 183 rSh.Push(); 184 185 // prepare to apply new language to all text in document 186 rSh.SelAll(); 187 rSh.ExtendedSelectAll(); 188 } 189 190 if (aNewLangTxt == aStrNone) 191 SwLangHelper::SetLanguage_None( rSh, pOLV, aSelection, bForSelection, aEditAttr ); 192 else if (aNewLangTxt == aStrResetLangs) 193 SwLangHelper::ResetLanguages( rSh, pOLV, aSelection, bForSelection ); 194 else 195 SwLangHelper::SetLanguage( rSh, pOLV, aSelection, aNewLangTxt, bForSelection, aEditAttr ); 196 197 // ugly hack, as it seems that EditView/EditEngine does not update their spellchecking marks 198 // when setting a new language attribute 199 if (bForSelection) 200 { 201 const SwViewOption* pVOpt = rView.GetWrtShellPtr()->GetViewOptions(); 202 sal_uLong nCntrl = pEditEngine->GetControlWord(); 203 // turn off 204 if (!pVOpt->IsOnlineSpell()) 205 nCntrl &= ~EE_CNTRL_ONLINESPELLING; 206 else 207 nCntrl &= ~EE_CNTRL_ONLINESPELLING; 208 pEditEngine->SetControlWord(nCntrl); 209 210 //turn back on 211 if (pVOpt->IsOnlineSpell()) 212 nCntrl |= EE_CNTRL_ONLINESPELLING; 213 else 214 nCntrl &= ~EE_CNTRL_ONLINESPELLING; 215 pEditEngine->SetControlWord(nCntrl); 216 217 pEditEngine->CompleteOnlineSpelling(); 218 rEditView.Invalidate(); 219 } 220 221 if (!bForSelection) 222 { 223 // need to release view and restore selection... 224 rSh.Pop( sal_False ); 225 rSh.LockView( sal_False ); 226 rSh.EndAction(); 227 } 228 } 229 } 230 231 // invalidate slot to get the new language displayed 232 pViewFrame->GetBindings().Invalidate( rReq.GetSlot() ); 233 234 rReq.Done(); 235 return bRestoreSelection; 236 } 237 238 239 void SetLanguage( SwWrtShell &rWrtSh, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet ) 240 { 241 SetLanguage( rWrtSh, 0 , ESelection(), rLangText, bIsForSelection, rCoreSet ); 242 } 243 244 void SetLanguage( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet ) 245 { 246 const LanguageType nLang = SvtLanguageTable().GetType( rLangText ); 247 if (nLang != LANGUAGE_DONTKNOW) 248 { 249 sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ); 250 251 EditEngine* pEditEngine = pOLV ? pOLV->GetEditView().GetEditEngine() : NULL; 252 DBG_ASSERT( !pOLV || pEditEngine, "OutlinerView without EditEngine???" ); 253 254 //get ScriptType 255 sal_uInt16 nLangWhichId = 0; 256 bool bIsSingleScriptType = true; 257 switch (nScriptType) 258 { 259 case SCRIPTTYPE_LATIN : nLangWhichId = pEditEngine ? EE_CHAR_LANGUAGE : RES_CHRATR_LANGUAGE; break; 260 case SCRIPTTYPE_ASIAN : nLangWhichId = pEditEngine ? EE_CHAR_LANGUAGE_CJK : RES_CHRATR_CJK_LANGUAGE; break; 261 case SCRIPTTYPE_COMPLEX : nLangWhichId = pEditEngine ? EE_CHAR_LANGUAGE_CTL : RES_CHRATR_CTL_LANGUAGE; break; 262 default: 263 bIsSingleScriptType = false; 264 DBG_ERROR( "unexpected case" ); 265 } 266 if (bIsSingleScriptType) 267 { 268 // change language for selection or paragraph 269 // (for paragraph is handled by previosuly having set the selection to the 270 // whole paragraph) 271 if (bIsForSelection) 272 { 273 // apply language to current selection 274 if (pEditEngine) 275 { 276 rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId )); 277 pEditEngine->QuickSetAttribs( rCoreSet, aSelection); 278 } 279 else 280 { 281 rWrtSh.GetCurAttr( rCoreSet ); 282 rCoreSet.Put( SvxLanguageItem( nLang, nLangWhichId )); 283 rWrtSh.SetAttrSet( rCoreSet ); 284 } 285 } 286 else // change language for all text 287 { 288 // set document default language 289 switch (nLangWhichId) 290 { 291 case EE_CHAR_LANGUAGE : nLangWhichId = RES_CHRATR_LANGUAGE; break; 292 case EE_CHAR_LANGUAGE_CJK : nLangWhichId = RES_CHRATR_CJK_LANGUAGE; break; 293 case EE_CHAR_LANGUAGE_CTL : nLangWhichId = RES_CHRATR_CTL_LANGUAGE; break; 294 } 295 rWrtSh.SetDefault( SvxLanguageItem( nLang, nLangWhichId ) ); 296 297 // #i102191: hard set respective language attribute in text document 298 // (for all text in the document - which should be selected by now...) 299 rWrtSh.SetAttrItem( SvxLanguageItem( nLang, nLangWhichId ) ); 300 } 301 } 302 } 303 } 304 305 void SetLanguage_None( SwWrtShell &rWrtSh, bool bIsForSelection, SfxItemSet &rCoreSet ) 306 { 307 SetLanguage_None( rWrtSh,0,ESelection(),bIsForSelection,rCoreSet ); 308 } 309 310 void SetLanguage_None( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet ) 311 { 312 // EditEngine IDs 313 const sal_uInt16 aLangWhichId_EE[3] = 314 { 315 EE_CHAR_LANGUAGE, 316 EE_CHAR_LANGUAGE_CJK, 317 EE_CHAR_LANGUAGE_CTL 318 }; 319 320 // Writer IDs 321 const sal_uInt16 aLangWhichId_Writer[3] = 322 { 323 RES_CHRATR_LANGUAGE, 324 RES_CHRATR_CJK_LANGUAGE, 325 RES_CHRATR_CTL_LANGUAGE 326 }; 327 328 if (bIsForSelection) 329 { 330 // change language for selection or paragraph 331 // (for paragraph is handled by previously having set the selection to the 332 // whole paragraph) 333 334 EditEngine* pEditEngine = pOLV ? pOLV->GetEditView().GetEditEngine() : NULL; 335 DBG_ASSERT( !pOLV || pEditEngine, "OutlinerView without EditEngine???" ); 336 if (pEditEngine) 337 { 338 for (sal_uInt16 i = 0; i < 3; ++i) 339 rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_EE[i] )); 340 pEditEngine->QuickSetAttribs( rCoreSet, aSelection); 341 } 342 else 343 { 344 rWrtSh.GetCurAttr( rCoreSet ); 345 for (sal_uInt16 i = 0; i < 3; ++i) 346 rCoreSet.Put( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_Writer[i] )); 347 rWrtSh.SetAttrSet( rCoreSet ); 348 } 349 } 350 else // change language for all text 351 { 352 SvUShortsSort aAttribs; 353 for (sal_uInt16 i = 0; i < 3; ++i) 354 { 355 rWrtSh.SetDefault( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_Writer[i] ) ); 356 aAttribs.Insert( aLangWhichId_Writer[i] ); 357 } 358 359 // set all language attributes to default 360 // (for all text in the document - which should be selected by now...) 361 rWrtSh.ResetAttr( &aAttribs ); 362 } 363 } 364 365 void ResetLanguages( SwWrtShell &rWrtSh, bool bIsForSelection ) 366 { 367 ResetLanguages( rWrtSh, 0 , ESelection(), bIsForSelection ); 368 } 369 370 void ResetLanguages( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection ) 371 { 372 (void) bIsForSelection; 373 (void) aSelection; 374 375 // reset language for current selection. 376 // The selection should already have been expanded to the whole paragraph or 377 // to all text in the document if those are the ranges where to reset 378 // the language attributes 379 380 if (pOLV) 381 { 382 EditView &rEditView = pOLV->GetEditView(); 383 rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE ); 384 rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE_CJK ); 385 rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE_CTL ); 386 } 387 else 388 { 389 SvUShortsSort aAttribs; 390 aAttribs.Insert( RES_CHRATR_LANGUAGE ); 391 aAttribs.Insert( RES_CHRATR_CJK_LANGUAGE ); 392 aAttribs.Insert( RES_CHRATR_CTL_LANGUAGE ); 393 rWrtSh.ResetAttr( &aAttribs ); 394 } 395 } 396 397 398 // @returns : the language for the selected text that is set for the 399 // specified attribute (script type). 400 // If there are more than one languages used LANGUAGE_DONTKNOW will be returned. 401 // @param nLangWhichId : one of 402 // RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, 403 LanguageType GetLanguage( SwWrtShell &rSh, sal_uInt16 nLangWhichId ) 404 { 405 SfxItemSet aSet( rSh.GetAttrPool(), nLangWhichId, nLangWhichId ); 406 rSh.GetCurAttr( aSet ); 407 408 return GetLanguage(aSet,nLangWhichId); 409 } 410 411 LanguageType GetLanguage( SfxItemSet aSet, sal_uInt16 nLangWhichId ) 412 { 413 414 LanguageType nLang = LANGUAGE_SYSTEM; 415 416 const SfxPoolItem *pItem = 0; 417 SfxItemState nState = aSet.GetItemState( nLangWhichId, sal_True, &pItem ); 418 if (nState > SFX_ITEM_DEFAULT && pItem) 419 { 420 // the item is set and can be used 421 nLang = (dynamic_cast< const SvxLanguageItem* >(pItem))->GetLanguage(); 422 } 423 else if (nState == SFX_ITEM_DEFAULT) 424 { 425 // since the attribute is not set: retrieve the default value 426 nLang = (dynamic_cast< const SvxLanguageItem& >(aSet.GetPool()->GetDefaultItem( nLangWhichId ))).GetLanguage(); 427 } 428 else if (nState == SFX_ITEM_DONTCARE) 429 { 430 // there is more than one language... 431 nLang = LANGUAGE_DONTKNOW; 432 } 433 DBG_ASSERT( nLang != LANGUAGE_SYSTEM, "failed to get the language?" ); 434 435 return nLang; 436 } 437 438 // @returns: the language in use for the selected text. 439 // 'In use' means the language(s) matching the script type(s) of the 440 // selected text. Or in other words, the language a spell checker would use. 441 // If there is more than one language LANGUAGE_DONTKNOW will be returned. 442 LanguageType GetCurrentLanguage( SwWrtShell &rSh ) 443 { 444 // get all script types used in current selection 445 const sal_uInt16 nScriptType = rSh.GetScriptType(); 446 447 //set language attribute to use according to the script type 448 sal_uInt16 nLangWhichId = 0; 449 bool bIsSingleScriptType = true; 450 switch (nScriptType) 451 { 452 case SCRIPTTYPE_LATIN : nLangWhichId = RES_CHRATR_LANGUAGE; break; 453 case SCRIPTTYPE_ASIAN : nLangWhichId = RES_CHRATR_CJK_LANGUAGE; break; 454 case SCRIPTTYPE_COMPLEX : nLangWhichId = RES_CHRATR_CTL_LANGUAGE; break; 455 default: bIsSingleScriptType = false; break; 456 } 457 458 // get language according to the script type(s) in use 459 LanguageType nCurrentLang = LANGUAGE_SYSTEM; 460 if (bIsSingleScriptType) 461 nCurrentLang = GetLanguage( rSh, nLangWhichId ); 462 else 463 { 464 // check if all script types are set to LANGUAGE_NONE and return 465 // that if this is the case. Otherwise, having multiple script types 466 // in use always means there are several languages in use... 467 const sal_uInt16 aScriptTypes[3] = 468 { 469 RES_CHRATR_LANGUAGE, 470 RES_CHRATR_CJK_LANGUAGE, 471 RES_CHRATR_CTL_LANGUAGE 472 }; 473 nCurrentLang = LANGUAGE_NONE; 474 for (sal_uInt16 i = 0; i < 3; ++i) 475 { 476 LanguageType nTmpLang = GetLanguage( rSh, aScriptTypes[i] ); 477 if (nTmpLang != LANGUAGE_NONE) 478 { 479 nCurrentLang = LANGUAGE_DONTKNOW; 480 break; 481 } 482 } 483 } 484 DBG_ASSERT( nCurrentLang != LANGUAGE_SYSTEM, "failed to get the language?" ); 485 486 return nCurrentLang; 487 } 488 489 // @returns: the language in use for the selected text. 490 // 'In use' means the language(s) matching the script type(s) of the 491 // selected text. Or in other words, the language a spell checker would use. 492 // If there is more than one language LANGUAGE_DONTKNOW will be returned. 493 LanguageType GetCurrentLanguage( SfxItemSet aSet, sal_uInt16 nScriptType ) 494 { 495 //set language attribute to use according to the script type 496 sal_uInt16 nLangWhichId = 0; 497 bool bIsSingleScriptType = true; 498 switch (nScriptType) 499 { 500 case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE; break; 501 case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break; 502 case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break; 503 default: bIsSingleScriptType = false; 504 } 505 506 // get language according to the script type(s) in use 507 LanguageType nCurrentLang = LANGUAGE_SYSTEM; 508 if (bIsSingleScriptType) 509 nCurrentLang = GetLanguage( aSet, nLangWhichId ); 510 else 511 { 512 // check if all script types are set to LANGUAGE_NONE and return 513 // that if this is the case. Otherwise, having multiple script types 514 // in use always means there are several languages in use... 515 const sal_uInt16 aScriptTypes[3] = 516 { 517 EE_CHAR_LANGUAGE, 518 EE_CHAR_LANGUAGE_CJK, 519 EE_CHAR_LANGUAGE_CTL 520 }; 521 nCurrentLang = LANGUAGE_NONE; 522 for (sal_uInt16 i = 0; i < 3; ++i) 523 { 524 LanguageType nTmpLang = GetLanguage( aSet, aScriptTypes[i] ); 525 if (nTmpLang != LANGUAGE_NONE) 526 { 527 nCurrentLang = LANGUAGE_DONTKNOW; 528 break; 529 } 530 } 531 } 532 DBG_ASSERT( nCurrentLang != LANGUAGE_SYSTEM, "failed to get the language?" ); 533 534 return nCurrentLang; 535 } 536 537 String GetTextForLanguageGuessing( SwWrtShell &rSh ) 538 { 539 // string for guessing language 540 String aText; 541 SwPaM *pCrsr = rSh.GetCrsr(); 542 SwTxtNode *pNode = pCrsr->GetNode()->GetTxtNode(); 543 if (pNode) 544 { 545 aText = pNode->GetTxt(); 546 if (aText.Len() > 0) 547 { 548 xub_StrLen nStt = 0; 549 xub_StrLen nEnd = pCrsr->GetPoint()->nContent.GetIndex(); 550 // at most 100 chars to the left... 551 nStt = nEnd > 100 ? nEnd - 100 : 0; 552 // ... and 100 to the right of the cursor position 553 nEnd = aText.Len() - nEnd > 100 ? nEnd + 100 : aText.Len(); 554 aText = aText.Copy( nStt, nEnd - nStt ); 555 } 556 } 557 return aText; 558 } 559 560 String GetTextForLanguageGuessing( EditEngine* rEditEngine, ESelection aDocSelection ) 561 { 562 // string for guessing language 563 String aText; 564 565 aText = rEditEngine->GetText(aDocSelection); 566 if (aText.Len() > 0) 567 { 568 xub_StrLen nStt = 0; 569 xub_StrLen nEnd = aDocSelection.nEndPos; 570 // at most 100 chars to the left... 571 nStt = nEnd > 100 ? nEnd - 100 : 0; 572 // ... and 100 to the right of the cursor position 573 nEnd = aText.Len() - nEnd > 100 ? nEnd + 100 : aText.Len(); 574 aText = aText.Copy( nStt, nEnd - nStt ); 575 } 576 577 return aText; 578 } 579 580 581 void SelectPara( EditView &rEditView, const ESelection &rCurSel ) 582 { 583 ESelection aParaSel( rCurSel.nStartPara, 0, rCurSel.nStartPara, USHRT_MAX ); 584 rEditView.SetSelection( aParaSel ); 585 } 586 587 void SelectCurrentPara( SwWrtShell &rWrtSh ) 588 { 589 // select current para 590 if (!rWrtSh.IsSttPara()) 591 rWrtSh.MovePara( fnParaCurr, fnParaStart ); 592 if (!rWrtSh.HasMark()) 593 rWrtSh.SetMark(); 594 rWrtSh.SwapPam(); 595 if (!rWrtSh.IsEndPara()) 596 rWrtSh.MovePara( fnParaCurr, fnParaEnd ); 597 #if OSL_DEBUG_LEVEL > 1 598 String aSelTxt; 599 rWrtSh.GetSelectedText( aSelTxt ); 600 (void) aSelTxt; 601 #endif 602 } 603 } 604 605 /* vim: set noet sw=4 ts=4: */ 606