summaryrefslogtreecommitdiff
path: root/sw/source/ui/uiview/viewling.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/ui/uiview/viewling.cxx')
-rwxr-xr-x[-rw-r--r--]sw/source/ui/uiview/viewling.cxx222
1 files changed, 84 insertions, 138 deletions
diff --git a/sw/source/ui/uiview/viewling.cxx b/sw/source/ui/uiview/viewling.cxx
index 04414b5d83db..b3f73f7c38e4 100644..100755
--- a/sw/source/ui/uiview/viewling.cxx
+++ b/sw/source/ui/uiview/viewling.cxx
@@ -120,7 +120,7 @@ void SwView::ExecLingu(SfxRequest &rReq)
{
switch(rReq.GetSlot())
{
- case FN_THESAURUS_DLG:
+ case SID_THESAURUS:
StartThesaurus();
rReq.Ignore();
break;
@@ -252,64 +252,31 @@ void SwView::StartTextConversion(
// do not do text conversion if it is active elsewhere
if (GetWrtShell().HasConvIter())
{
-// MessBox( 0, WB_OK, String( SW_RES( STR_SPELL_TITLE ) ),
-// String( SW_RES( STR_MULT_INTERACT_SPELL_WARN ) ) ).Execute();
return;
}
-/*
- SfxErrorContext aContext( ERRCTX_SVX_LINGU_SPELLING, aEmptyStr, pEditWin,
- RID_SVXERRCTX, DIALOG_MGR() );
- Reference< XSpellChecker1 > xSpell = ::GetSpellChecker();
- if(!xSpell.is())
- { // keine Arme keine Kekse
- ErrorHandler::HandleError( ERRCODE_SVX_LINGU_LINGUNOTEXISTS );
- return;
- }
-*/
SpellKontext(sal_True);
- SwViewOption* pVOpt = (SwViewOption*)pWrtShell->GetViewOptions();
- sal_Bool bOldIdle = pVOpt->IsIdle();
+ const SwViewOption* pVOpt = pWrtShell->GetViewOptions();
+ const sal_Bool bOldIdle = pVOpt->IsIdle();
pVOpt->SetIdle( sal_False );
sal_Bool bOldIns = pWrtShell->IsInsMode();
pWrtShell->SetInsMode( sal_True );
+ sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection() ||
+ pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext();
- {
- sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection() ||
- pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext();
-
-// sal_Bool bIsSpellSpecial = sal_True;
-
- sal_Bool bStart = bSelection || pWrtShell->IsStartOfDoc();
- sal_Bool bOther = !bSelection && !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY);
+ sal_Bool bStart = bSelection || pWrtShell->IsStartOfDoc();
+ sal_Bool bOther = !bSelection && !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY);
-/*
- if( bOther && !bIsSpellSpecial )
- // kein Sonderbereich eingeschaltet
- {
- // Ich will auch in Sonderbereichen trennen
- QueryBox aBox( &GetEditWin(), SW_RES( DLG_SPECIAL_FORCED ) );
- if( aBox.Execute() == RET_YES && xProp.is())
- {
- sal_Bool bTrue = sal_True;
- Any aTmp(&bTrue, ::getBooleanCppuType());
- xProp->setPropertyValue( C2U(UPN_IS_SPELL_SPECIAL), aTmp );
- }
- else
- return; // Nein Es wird nicht gespellt
- }
-*/
- {
- const uno::Reference< lang::XMultiServiceFactory > xMgr(
- comphelper::getProcessServiceFactory() );
- SwHHCWrapper aWrap( this, xMgr, nSourceLang, nTargetLang, pTargetFont,
- nOptions, bIsInteractive,
- bStart, bOther, bSelection );
- aWrap.Convert();
- }
+ {
+ const uno::Reference< lang::XMultiServiceFactory > xMgr(
+ comphelper::getProcessServiceFactory() );
+ SwHHCWrapper aWrap( this, xMgr, nSourceLang, nTargetLang, pTargetFont,
+ nOptions, bIsInteractive,
+ bStart, bOther, bSelection );
+ aWrap.Convert();
}
pWrtShell->SetInsMode( bOldIns );
@@ -557,16 +524,77 @@ void SwView::HyphenateDocument()
}
/*--------------------------------------------------------------------
+ --------------------------------------------------------------------*/
+
+bool SwView::IsValidSelectionForThesaurus() const
+{
+ // must not be a multi-selection, and if it is a selection it needs
+ // to be within a single paragraph
+
+ const bool bMultiSel = pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext();
+ const sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection();
+ return !bMultiSel && (!bSelection || pWrtShell->IsSelOnePara() );
+}
+
+
+String SwView::GetThesaurusLookUpText( bool bSelection ) const
+{
+ return bSelection ? pWrtShell->GetSelTxt() : pWrtShell->GetCurWord();
+}
+
+
+void SwView::InsertThesaurusSynonym( const String &rSynonmText, const String &rLookUpText, bool bSelection )
+{
+ sal_Bool bOldIns = pWrtShell->IsInsMode();
+ pWrtShell->SetInsMode( sal_True );
+
+ pWrtShell->StartAllAction();
+ pWrtShell->StartUndo(UNDO_DELETE);
+
+ if( !bSelection )
+ {
+ if(pWrtShell->IsEndWrd())
+ pWrtShell->Left(CRSR_SKIP_CELLS, FALSE, 1, FALSE );
+
+ pWrtShell->SelWrd();
+
+ // make sure the selection build later from the
+ // data below does not include footnotes and other
+ // "in word" character to the left and right in order
+ // to preserve those. Therefore count those "in words"
+ // in order to modify the selection accordingly.
+ const sal_Unicode* pChar = rLookUpText.GetBuffer();
+ xub_StrLen nLeft = 0;
+ while (pChar && *pChar++ == CH_TXTATR_INWORD)
+ ++nLeft;
+ pChar = rLookUpText.Len() ? rLookUpText.GetBuffer() + rLookUpText.Len() - 1 : 0;
+ xub_StrLen nRight = 0;
+ while (pChar && *pChar-- == CH_TXTATR_INWORD)
+ ++nRight;
+
+ // adjust existing selection
+ SwPaM *pCrsr = pWrtShell->GetCrsr();
+ pCrsr->GetPoint()->nContent/*.nIndex*/ -= nRight;
+ pCrsr->GetMark()->nContent/*.nIndex*/ += nLeft;
+ }
+
+ pWrtShell->Insert( rSynonmText );
+
+ pWrtShell->EndUndo(UNDO_DELETE);
+ pWrtShell->EndAllAction();
+
+ pWrtShell->SetInsMode( bOldIns );
+}
+
+
+/*--------------------------------------------------------------------
Beschreibung: Thesaurus starten
--------------------------------------------------------------------*/
void SwView::StartThesaurus()
{
- if( pWrtShell->GetCrsr() != pWrtShell->GetCrsr()->GetNext() )
- return;
- sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection();
- if( bSelection && !pWrtShell->IsSelOnePara() )
+ if (!IsValidSelectionForThesaurus())
return;
SfxErrorContext aContext( ERRCTX_SVX_LINGU_THESAURUS, aEmptyStr, pEditWin,
@@ -589,114 +617,32 @@ void SwView::StartThesaurus()
sal_Bool bOldIdle = pVOpt->IsIdle();
pVOpt->SetIdle( sal_False );
-#ifdef TL_NEVER
-//!!! hier mu� noch was getan werden... (Umsetzung der Funktionalitaet)
- // ErrorLink setzen, alten merken
- Link aOldLnk = pSpell->ChgErrorLink(LINK(this, SwView, SpellError));
-#endif
-
-
// get initial LookUp text
- String aTmp = bSelection ?
- pWrtShell->GetSelTxt() : pWrtShell->GetCurWord();
+ const sal_Bool bSelection = ((SwCrsrShell*)pWrtShell)->HasSelection();
+ String aTmp = GetThesaurusLookUpText( bSelection );
Reference< XThesaurus > xThes( ::GetThesaurus() );
AbstractThesaurusDialog *pDlg = NULL;
if ( !xThes.is() || !xThes->hasLocale( SvxCreateLocale( eLang ) ) )
- {
SpellError( &eLang );
- }
else
{
// create dialog
{ //Scope for SwWait-Object
SwWait aWait( *GetDocShell(), sal_True );
+ // load library with dialog only on demand ...
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- pDlg = pFact->CreateThesaurusDialog( &GetEditWin(),
- xThes, aTmp, eLang );
- }
-
- {
- // Hier wird der Thesaurus-Dialog im Applikationsfenster zentriert,
- // und zwar oberhalb oder unterhalb der Cursorposition, je nachdem,
- // wo mehr Platz ist.
-
- // Current Word:
- SwRect aRect( pWrtShell->GetCharRect() );
- Point aTopPos = aRect.Pos();
- Point aBtmPos( aTopPos.X(), aRect.Bottom() );
- aTopPos = GetEditWin().LogicToPixel( aTopPos );
- aTopPos = GetEditWin().OutputToScreenPixel( aTopPos );
- aBtmPos = GetEditWin().LogicToPixel( aBtmPos );
- aBtmPos = GetEditWin().OutputToScreenPixel( aBtmPos );
- // ::frame::Desktop:
- Rectangle aRct = GetEditWin().GetDesktopRectPixel();
- Point aWinTop( aRct.TopLeft() );
- Point aWinBtm( aRct.BottomRight() );
- if ( aTopPos.Y() - aWinTop.Y() > aWinBtm.Y() - aBtmPos.Y() )
- aWinBtm.Y() = aTopPos.Y();
- else
- aWinTop.Y() = aBtmPos.Y();
-
- Size aSz = pDlg->GetWindow()->GetSizePixel();
- if ( aWinBtm.Y() - aWinTop.Y() > aSz.Height() )
- {
- aWinTop.X() = ( aWinTop.X() + aWinBtm.X() - aSz.Width() ) / 2;
- aWinTop.Y() = ( aWinTop.Y() + aWinBtm.Y() - aSz.Height() ) / 2;
- pDlg->GetWindow()->SetPosPixel( aWinTop );
- }
+ pDlg = pFact->CreateThesaurusDialog( &GetEditWin(), xThes, aTmp, eLang );
}
if ( pDlg->Execute()== RET_OK )
- {
- sal_Bool bOldIns = pWrtShell->IsInsMode();
- pWrtShell->SetInsMode( sal_True );
-
- pWrtShell->StartAllAction();
- pWrtShell->StartUndo(UNDO_DELETE);
-
- if( !bSelection )
- {
- if(pWrtShell->IsEndWrd())
- pWrtShell->Left(CRSR_SKIP_CELLS, FALSE, 1, FALSE );
-
- pWrtShell->SelWrd();
-
- // make sure the selection build later from the
- // data below does not include footnotes and other
- // "in word" character to the left and right in order
- // to preserve those. Therefore count those "in words"
- // in order to modify the selection accordingly.
- const sal_Unicode* pChar = aTmp.GetBuffer();
- xub_StrLen nLeft = 0;
- while (pChar && *pChar++ == CH_TXTATR_INWORD)
- ++nLeft;
- pChar = aTmp.Len() ? aTmp.GetBuffer() + aTmp.Len() - 1 : 0;
- xub_StrLen nRight = 0;
- while (pChar && *pChar-- == CH_TXTATR_INWORD)
- ++nRight;
-
- // adjust existing selection
- SwPaM *pCrsr = pWrtShell->GetCrsr();
- pCrsr->GetPoint()->nContent/*.nIndex*/ -= nRight;
- pCrsr->GetMark()->nContent/*.nIndex*/ += nLeft;
- }
-
- pWrtShell->Insert( pDlg->GetWord() );
-
- pWrtShell->EndUndo(UNDO_DELETE);
- pWrtShell->EndAllAction();
-
- pWrtShell->SetInsMode( bOldIns );
-
- }
+ InsertThesaurusSynonym( pDlg->GetWord(), aTmp, bSelection );
}
delete pDlg;
pVOpt->SetIdle( bOldIdle );
-
}
/*--------------------------------------------------------------------