textsh1.cxx (512ec161) | textsh1.cxx (89358e0f) |
---|---|
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 --- 288 unchanged lines hidden (view full) --- 297 aQBox.SetButtonHelpText( RET_OK, aEmptyStr ); 298 299 return aQBox.Execute(); 300} 301 302void SwTextShell::Execute(SfxRequest &rReq) 303{ 304 sal_Bool bUseDialog = sal_True; | 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 --- 288 unchanged lines hidden (view full) --- 297 aQBox.SetButtonHelpText( RET_OK, aEmptyStr ); 298 299 return aQBox.Execute(); 300} 301 302void SwTextShell::Execute(SfxRequest &rReq) 303{ 304 sal_Bool bUseDialog = sal_True; |
305 const SfxItemSet *pArgs = rReq.GetArgs(); 306 SwWrtShell& rWrtSh = GetShell(); 307 const SfxPoolItem* pItem = 0; 308 sal_uInt16 nSlot = rReq.GetSlot(); 309 if(pArgs) 310 pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem); 311 switch( nSlot ) 312 { | 305 const SfxItemSet *pArgs = rReq.GetArgs(); 306 SwWrtShell& rWrtSh = GetShell(); 307 const SfxPoolItem* pItem = 0; 308 sal_uInt16 nSlot = rReq.GetSlot(); 309 if(pArgs) 310 pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem); 311 switch( nSlot ) 312 { |
313 case SID_LANGUAGE_STATUS: 314 { 315 // get the language 316 String aNewLangTxt; 317 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_LANGUAGE_STATUS , sal_False ); 318 if (pItem2) 319 aNewLangTxt = pItem2->GetValue(); 320 | 313 case SID_LANGUAGE_STATUS: 314 { 315 // get the language 316 String aNewLangTxt; 317 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_LANGUAGE_STATUS , sal_False ); 318 if (pItem2) 319 aNewLangTxt = pItem2->GetValue(); 320 |
321 //!! Remember the view frame right now... 322 //!! (call to GetView().GetViewFrame() will break if the 323 //!! SwTextShell got destroyed meanwhile.) 324 SfxViewFrame *pViewFrame = GetView().GetViewFrame(); | 321 //!! Remember the view frame right now... 322 //!! (call to GetView().GetViewFrame() will break if the 323 //!! SwTextShell got destroyed meanwhile.) 324 SfxViewFrame *pViewFrame = GetView().GetViewFrame(); |
325 326 if (aNewLangTxt.EqualsAscii( "*" )) | 325 326 if (aNewLangTxt.EqualsAscii( "*" )) |
327 { | 327 { |
328 // open the dialog "Tools/Options/Language Settings - Language" | 328 // open the dialog "Tools/Options/Language Settings - Language" |
329 // to set the documents default language 330 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 331 if (pFact) 332 { | 329 // to set the documents default language 330 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); 331 if (pFact) 332 { |
333 VclAbstractDialog* pDlg = pFact->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS ); | 333 VclAbstractDialog* pDlg = pFact->CreateVclDialog( GetView().GetWindow(), SID_LANGUAGE_OPTIONS ); |
334 pDlg->Execute(); 335 delete pDlg; 336 } 337 } 338 else 339 { 340 //!! We have to use StartAction / EndAction bracketing in 341 //!! order to prevent possible destruction of the SwTextShell 342 //!! due to the selection changes coming below. 343 rWrtSh.StartAction(); 344 // prevent view from jumping because of (temporary) selection changes 345 rWrtSh.LockView( sal_True ); 346 // save selection for later restoration 347 rWrtSh.Push(); | 334 pDlg->Execute(); 335 delete pDlg; 336 } 337 } 338 else 339 { 340 //!! We have to use StartAction / EndAction bracketing in 341 //!! order to prevent possible destruction of the SwTextShell 342 //!! due to the selection changes coming below. 343 rWrtSh.StartAction(); 344 // prevent view from jumping because of (temporary) selection changes 345 rWrtSh.LockView( sal_True ); |
348 | 346 |
347 // save selection for later restoration 348 rWrtSh.Push(); 349 |
|
349 // setting the new language... 350 if (aNewLangTxt.Len() > 0) | 350 // setting the new language... 351 if (aNewLangTxt.Len() > 0) |
351 { | 352 { |
352 const String aSelectionLangPrefix( String::CreateFromAscii("Current_") ); 353 const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") ); 354 const String aDocumentLangPrefix( String::CreateFromAscii("Default_") ); | 353 const String aSelectionLangPrefix( String::CreateFromAscii("Current_") ); 354 const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") ); 355 const String aDocumentLangPrefix( String::CreateFromAscii("Default_") ); |
355 const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") ); 356 const String aStrResetLangs( String::CreateFromAscii("RESET_LANGUAGES") ); | 356 const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") ); 357 const String aStrResetLangs( String::CreateFromAscii("RESET_LANGUAGES") ); |
357 | 358 |
358 SfxItemSet aCoreSet( GetPool(), | 359 SfxItemSet aCoreSet( GetPool(), |
359 RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, 360 RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, 361 RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, 362 0 ); 363 364 xub_StrLen nPos = 0; 365 bool bForSelection = true; 366 bool bForParagraph = false; 367 if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 ))) | 360 RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, 361 RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, 362 RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, 363 0 ); 364 365 xub_StrLen nPos = 0; 366 bool bForSelection = true; 367 bool bForParagraph = false; 368 if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 ))) |
368 { | 369 { |
369 // ... for the current selection 370 aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.Len() ); 371 bForSelection = true; | 370 // ... for the current selection 371 aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.Len() ); 372 bForSelection = true; |
372 } | 373 } |
373 else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 ))) 374 { 375 // ... for the current paragraph language 376 aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.Len() ); 377 bForSelection = true; 378 bForParagraph = true; 379 } 380 else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 ))) | 374 else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 ))) 375 { 376 // ... for the current paragraph language 377 aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.Len() ); 378 bForSelection = true; 379 bForParagraph = true; 380 } 381 else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 ))) |
381 { | 382 { |
382 // ... as default document language 383 aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.Len() ); 384 bForSelection = false; | 383 // ... as default document language 384 aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.Len() ); 385 bForSelection = false; |
385 } | 386 } |
386 387 if (bForParagraph) 388 SwLangHelper::SelectCurrentPara( rWrtSh ); 389 | 387 388 if (bForParagraph) 389 SwLangHelper::SelectCurrentPara( rWrtSh ); 390 |
390 if (!bForSelection) // document language to be changed... | 391 if (!bForSelection) // document language to be changed... |
391 { | 392 { |
392 rWrtSh.SelAll(); | 393 rWrtSh.SelAll(); |
393 rWrtSh.ExtendedSelectAll(); 394 } | 394 rWrtSh.ExtendedSelectAll(); 395 } |
396 397 rWrtSh.StartUndo( ( !bForParagraph && !bForSelection ) ? UNDO_SETDEFTATTR : UNDO_EMPTY ); |
|
395 if (aNewLangTxt == aStrNone) 396 SwLangHelper::SetLanguage_None( rWrtSh, bForSelection, aCoreSet ); 397 else if (aNewLangTxt == aStrResetLangs) 398 SwLangHelper::ResetLanguages( rWrtSh, bForSelection ); 399 else 400 SwLangHelper::SetLanguage( rWrtSh, aNewLangTxt, bForSelection, aCoreSet ); | 398 if (aNewLangTxt == aStrNone) 399 SwLangHelper::SetLanguage_None( rWrtSh, bForSelection, aCoreSet ); 400 else if (aNewLangTxt == aStrResetLangs) 401 SwLangHelper::ResetLanguages( rWrtSh, bForSelection ); 402 else 403 SwLangHelper::SetLanguage( rWrtSh, aNewLangTxt, bForSelection, aCoreSet ); |
401 } | 404 rWrtSh.EndUndo(); |
402 | 405 |
403 // restore selection... 404 rWrtSh.Pop( sal_False ); | 406 } |
405 | 407 |
406 rWrtSh.LockView( sal_False ); 407 rWrtSh.EndAction(); 408 } | 408 // restore selection... 409 rWrtSh.Pop( sal_False ); |
409 | 410 |
411 rWrtSh.LockView( sal_False ); 412 rWrtSh.EndAction(); 413 } 414 |
|
410 // invalidate slot to get the new language displayed | 415 // invalidate slot to get the new language displayed |
411 pViewFrame->GetBindings().Invalidate( nSlot ); | 416 pViewFrame->GetBindings().Invalidate( nSlot ); |
412 413 rReq.Done(); | 417 418 rReq.Done(); |
414 break; | 419 break; |
415 } 416 417 case SID_THES: 418 { 419 // replace word/selection with text from selected sub menu entry 420 String aReplaceText; 421 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , sal_False ); 422 if (pItem2) --- 1435 unchanged lines hidden --- | 420 } 421 422 case SID_THES: 423 { 424 // replace word/selection with text from selected sub menu entry 425 String aReplaceText; 426 SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , sal_False ); 427 if (pItem2) --- 1435 unchanged lines hidden --- |