diff options
Diffstat (limited to 'sw/source/ui')
39 files changed, 1131 insertions, 982 deletions
diff --git a/sw/source/ui/app/apphdl.cxx b/sw/source/ui/app/apphdl.cxx index d57e22b985..93e88b3b74 100644 --- a/sw/source/ui/app/apphdl.cxx +++ b/sw/source/ui/app/apphdl.cxx @@ -765,6 +765,7 @@ void SwModule::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) DELETEZ(pWebToolbarConfig) ; DELETEZ(pAuthorNames) ; DELETEZ(pDBConfig); + if (pColorConfig != 0) { pColorConfig->RemoveListener(this); DELETEZ(pColorConfig); diff --git a/sw/source/ui/app/swmodule.cxx b/sw/source/ui/app/swmodule.cxx index 0790eb4c4d..56252239f4 100644 --- a/sw/source/ui/app/swmodule.cxx +++ b/sw/source/ui/app/swmodule.cxx @@ -59,13 +59,13 @@ #include <svx/tbxcolor.hxx> #include <svx/clipboardctl.hxx> #include <svx/lboxctrl.hxx> -#include <svx/extrusioncontrols.hxx> #include <svx/hyprlink.hxx> #include <svx/tbxcustomshapes.hxx> -#include <svx/fontworkgallery.hxx> #include <svx/imapdlg.hxx> #include <svx/srchdlg.hxx> #include <svx/hyperdlg.hxx> +#include <svx/extrusioncolorcontrol.hxx> +#include <svx/fontworkgallery.hxx> #include <com/sun/star/scanner/XScannerManager.hpp> #include <com/sun/star/container/XSet.hpp> #include <comphelper/processfactory.hxx> @@ -138,6 +138,7 @@ #include <mailmergechildwindow.hxx> #include <modcfg.hxx> #include <fontcfg.hxx> +#include <sfx2/taskpane.hxx> #include <sfx2/evntconf.hxx> #include <sfx2/appuno.hxx> #include <swatrset.hxx> @@ -378,15 +379,8 @@ void SwDLL::RegisterControls() SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_CALLOUT, pMod ); SvxTbxCtlCustomShapes::RegisterControl( SID_DRAWTBX_CS_STAR, pMod ); - svx::ExtrusionDepthControl::RegisterControl( SID_EXTRUSION_DEPTH_FLOATER, pMod ); - svx::ExtrusionDirectionControl::RegisterControl( SID_EXTRUSION_DIRECTION_FLOATER, pMod ); - svx::ExtrusionLightingControl::RegisterControl( SID_EXTRUSION_LIGHTING_FLOATER, pMod ); - svx::ExtrusionSurfaceControl::RegisterControl( SID_EXTRUSION_SURFACE_FLOATER, pMod ); svx::ExtrusionColorControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod ); - svx::FontWorkShapeTypeControl::RegisterControl( SID_FONTWORK_SHAPE_TYPE, pMod ); - svx::FontWorkAlignmentControl::RegisterControl( SID_FONTWORK_ALIGNMENT_FLOATER, pMod ); - svx::FontWorkCharacterSpacingControl::RegisterControl( SID_FONTWORK_CHARACTER_SPACING_FLOATER, pMod ); SvxClipBoardControl::RegisterControl(SID_PASTE, pMod ); SvxUndoRedoControl::RegisterControl(SID_UNDO, pMod ); @@ -469,18 +463,13 @@ void SwDLL::RegisterControls() SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_LEFT_TO_RIGHT, pMod); SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_RIGHT_TO_LEFT, pMod); - svx::ExtrusionDepthControl::RegisterControl( SID_EXTRUSION_DEPTH_FLOATER, pMod ); - svx::ExtrusionDirectionControl::RegisterControl( SID_EXTRUSION_DIRECTION_FLOATER, pMod ); - svx::ExtrusionLightingControl::RegisterControl( SID_EXTRUSION_LIGHTING_FLOATER, pMod ); - svx::ExtrusionSurfaceControl::RegisterControl( SID_EXTRUSION_SURFACE_FLOATER, pMod ); - svx::ExtrusionColorControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod ); - GalleryChildWindow::RegisterChildWindow(0, pMod); ::avmedia::MediaToolBoxControl::RegisterControl(SID_AVMEDIA_TOOLBOX, pMod); ::avmedia::MediaPlayer::RegisterChildWindow(0, pMod); SvxSmartTagsControl::RegisterControl(SID_OPEN_SMARTTAGMENU, pMod); + ::sfx2::TaskPaneWrapper::RegisterChildWindow( FALSE, pMod ); } diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index a2573ed3c1..a2573ed3c1 100644..100755 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index 40c17f9866..8d3943834c 100644..100755 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -542,10 +542,15 @@ void SwAddPrinterTabPage::Reset( const SfxItemSet& ) aFaxLB.SelectEntry( pAddPrinterAttr->sFaxName ); } if (aProspectCB.IsChecked()) + { aProspectCB_RTL.Enable(TRUE); + aNoRB.Enable( FALSE ); + aOnlyRB.Enable( FALSE ); + aEndRB.Enable( FALSE ); + aEndPageRB.Enable( FALSE ); + } else - aProspectCB_RTL.Disable(); - + aProspectCB_RTL.Enable( FALSE ); } //----------------------------------------------------------------------- @@ -560,13 +565,14 @@ void SwAddPrinterTabPage::Init() IMPL_LINK_INLINE_START( SwAddPrinterTabPage, AutoClickHdl, CheckBox *, EMPTYARG ) { bAttrModified = TRUE; - if (aProspectCB.IsChecked()) - aProspectCB_RTL.Enable(TRUE); - else - { + bool bIsProspect = aProspectCB.IsChecked(); + if (!bIsProspect) aProspectCB_RTL.Check( FALSE ); - aProspectCB_RTL.Disable(); - } + aProspectCB_RTL.Enable( bIsProspect ); + aNoRB.Enable( !bIsProspect ); + aOnlyRB.Enable( !bIsProspect ); + aEndRB.Enable( !bIsProspect ); + aEndPageRB.Enable( !bIsProspect ); return 0; } IMPL_LINK_INLINE_END( SwAddPrinterTabPage, AutoClickHdl, CheckBox *, EMPTYARG ) diff --git a/sw/source/ui/config/viewopt.cxx b/sw/source/ui/config/viewopt.cxx index e0af7fe275..6960e56ceb 100644 --- a/sw/source/ui/config/viewopt.cxx +++ b/sw/source/ui/config/viewopt.cxx @@ -112,6 +112,7 @@ BOOL SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const && bFormView == rOpt.IsFormView() && mbViewLayoutBookMode == rOpt.mbViewLayoutBookMode && bShowPlaceHolderFields == rOpt.bShowPlaceHolderFields + && bIdle == rOpt.bIdle #ifdef DBG_UTIL // korrespondieren zu den Angaben in ui/config/cfgvw.src && bTest1 == rOpt.IsTest1() @@ -226,7 +227,7 @@ SwViewOption::SwViewOption() : { // Initialisierung ist jetzt etwas einfacher // alle Bits auf 0 - nCoreOptions = VIEWOPT_1_IDLE | VIEWOPT_1_HARDBLANK | VIEWOPT_1_SOFTHYPH | + nCoreOptions = VIEWOPT_1_HARDBLANK | VIEWOPT_1_SOFTHYPH | VIEWOPT_1_REF | VIEWOPT_1_GRAPHIC | VIEWOPT_1_TABLE | VIEWOPT_1_DRAW | VIEWOPT_1_CONTROL | @@ -243,6 +244,8 @@ SwViewOption::SwViewOption() : bSelectionInReadonly = SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly(); + bIdle = true; + #ifdef DBG_UTIL // korrespondieren zu den Angaben in ui/config/cfgvw.src bTest1 = bTest2 = bTest3 = bTest4 = @@ -277,6 +280,7 @@ SwViewOption::SwViewOption(const SwViewOption& rVOpt) bBookview = rVOpt.bBookview; mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode; bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields; + bIdle = rVOpt.bIdle; #ifdef DBG_UTIL bTest1 = rVOpt.bTest1 ; @@ -317,6 +321,7 @@ SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt ) bBookview = rVOpt.bBookview; mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode; bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields; + bIdle = rVOpt.bIdle; #ifdef DBG_UTIL bTest1 = rVOpt.bTest1 ; diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 28e2bf8e65..42d4db33f0 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -33,15 +33,10 @@ #include "dbinsdlg.hxx" -#ifndef INCLUDED_MEMORY #include <memory> -#define INCLUDED_MEMORY -#endif -#ifndef INCLUDED_FLOAT_H #include <float.h> -#define INCLUDED_FLOAT_H -#endif + #include <hintids.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameAccess.hpp> @@ -65,9 +60,7 @@ #include <svl/stritem.hxx> #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> -#ifndef __SV_MNEMONIC_HXX #include <vcl/mnemonic.hxx> -#endif #include <svl/style.hxx> #include <svl/zformat.hxx> #include <svx/htmlmode.hxx> @@ -78,24 +71,16 @@ #include <editeng/boxitem.hxx> #include <svx/rulritem.hxx> #include <swdbtoolsclient.hxx> -#ifndef _SWTABLEREP_HXX //autogen #include <tabledlg.hxx> -#endif #include <fmtclds.hxx> #include <tabcol.hxx> #include <uiitems.hxx> #include <viewopt.hxx> #include <uitool.hxx> #include <wrtsh.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef _DBMGR_HXX #include <dbmgr.hxx> -#endif #include <tblafmt.hxx> #include <cellatr.hxx> #include <swtable.hxx> @@ -108,19 +93,11 @@ #include <poolfmt.hxx> #include <crsskip.hxx> -#ifndef _DBINSDLG_HRC #include <dbinsdlg.hrc> -#endif -#ifndef _DBUI_HRC #include <dbui.hrc> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _HELPID_H #include <helpid.h> -#endif #include <cfgid.h> #include <SwStyleNameMapper.hxx> #include <comphelper/uno3.hxx> @@ -1380,8 +1357,8 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, case _DB_Column::DB_COL_FIELD: { - SwDBField* pFld = (SwDBField*)pDBCol->DB_ColumnData. - pField->Copy(); + SwDBField *const pFld = static_cast<SwDBField *>( + pDBCol->DB_ColumnData.pField->CopyField()); double nValue = DBL_MAX; Reference< XPropertySet > xColumnProps; diff --git a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx index 4ae70d26db..b7fd189741 100644 --- a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx @@ -32,13 +32,13 @@ #include <vcl/msgbox.hxx> #include <editeng/svxacorr.hxx> #include <editeng/acorrcfg.hxx> -#ifndef _SVX_SVXIDS_HRC #include <svx/svxids.hrc> -#endif #include <sfx2/app.hxx> #include <sfx2/bindings.hxx> #include <sfx2/dispatch.hxx> #include <editeng/unolingu.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editview.hxx> #include <wrtsh.hxx> #include <sfx2/printer.hxx> #include <svx/svdoutl.hxx> @@ -56,9 +56,7 @@ #include <pam.hxx> #include <drawbase.hxx> #include <unotextrange.hxx> -#ifndef _DIALOG_HXX #include <dialog.hrc> -#endif #include <cmdid.h> @@ -202,12 +200,19 @@ SfxChildWinInfo SwSpellDialogChildWindow::GetInfo (void) const -----------------------------------------------------------------------*/ -svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) +svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence(bool bRecheck) { svx::SpellPortions aRet; SwWrtShell* pWrtShell = GetWrtShell_Impl(); if(pWrtShell) { + if (!bRecheck) + { + // first set continuation point for spell/grammar check to the + // end of the current sentence + pWrtShell->MoveContinuationPosToEndOfCheckedSentence(); + } + ShellModes eSelMode = pWrtShell->GetView().GetShellMode(); bool bDrawText = SHELL_MODE_DRAWTEXT == eSelMode; bool bNormalText = @@ -239,7 +244,10 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) if(!pWrtShell->HasSelection()) pWrtShell->GoStartSentence(); else + { + pWrtShell->ExpandToSentenceBorders(); m_pSpellState->m_bStartedInSelection = true; + } //determine if the selection is outside of the body text bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY); m_pSpellState->m_SpellStartPosition = bOtherText ? SPELL_START_OTHER : SPELL_START_BODY; @@ -269,7 +277,24 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) m_pSpellState->m_SpellStartPosition = SPELL_START_DRAWTEXT; m_pSpellState->m_pStartDrawing = pSdrView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(); OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); - m_pSpellState->m_aStartDrawingSelection = pOLV->GetSelection(); + // start checking at the top of the drawing object + pOLV->SetSelection( ESelection() ); + m_pSpellState->m_aStartDrawingSelection = ESelection(); +/* +Note: spelling in a selection only, or starting in a mid of a drawing object requires +further changes elsewhere. (Especially if it should work in sc and sd as well.) +The code below would only be part of the solution. +(Keeping it a as a comment for the time being) + ESelection aCurSel( pOLV->GetSelection() ); + ESelection aSentenceSel( pOLV->GetEditView().GetEditEngine()->SelectSentence( aCurSel ) ); + if (!aCurSel.HasRange()) + { + aSentenceSel.nEndPara = aSentenceSel.nStartPara; + aSentenceSel.nEndPos = aSentenceSel.nStartPos; + } + pOLV->SetSelection( aSentenceSel ); + m_pSpellState->m_aStartDrawingSelection = aSentenceSel; +*/ } m_pSpellState->m_bInitialCall = false; @@ -316,61 +341,66 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) //spell inside of the Writer text if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) { - //find out which text has been spelled body or other - bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY); - if(bOtherText && m_pSpellState->m_bStartedInOther && m_pSpellState->pOtherCursor) + // if there is a selection (within body or header/footer text) + // then spell/grammar checking should not move outside of it. + if (!m_pSpellState->m_bStartedInSelection) { - m_pSpellState->m_bStartedInOther = false; - pWrtShell->SetSelection(*m_pSpellState->pOtherCursor); - pWrtShell->SpellEnd(); - delete m_pSpellState->pOtherCursor; - m_pSpellState->pOtherCursor = 0; - pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_CURR, DOCPOS_OTHERSTART, FALSE ); - pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn); - } - if(!aRet.size()) - { - //end spelling - pWrtShell->SpellEnd(); - if(bOtherText) + //find out which text has been spelled body or other + bOtherText = !(pWrtShell->GetFrmType(0,sal_True) & FRMTYPE_BODY); + if(bOtherText && m_pSpellState->m_bStartedInOther && m_pSpellState->pOtherCursor) { - m_pSpellState->m_bOtherSpelled = true; - //has the body been spelled? - if(!m_pSpellState->m_bBodySpelled) + m_pSpellState->m_bStartedInOther = false; + pWrtShell->SetSelection(*m_pSpellState->pOtherCursor); + pWrtShell->SpellEnd(); + delete m_pSpellState->pOtherCursor; + m_pSpellState->pOtherCursor = 0; + pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_CURR, DOCPOS_OTHERSTART, FALSE ); + pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn); + } + if(!aRet.size()) + { + //end spelling + pWrtShell->SpellEnd(); + if(bOtherText) { - pWrtShell->SpellStart(DOCPOS_START, DOCPOS_END, DOCPOS_START, FALSE ); - if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) + m_pSpellState->m_bOtherSpelled = true; + //has the body been spelled? + if(!m_pSpellState->m_bBodySpelled) { - m_pSpellState->m_bBodySpelled = true; - pWrtShell->SpellEnd(); + pWrtShell->SpellStart(DOCPOS_START, DOCPOS_END, DOCPOS_START, FALSE ); + if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) + { + m_pSpellState->m_bBodySpelled = true; + pWrtShell->SpellEnd(); + } } } + else + { + m_pSpellState->m_bBodySpelled = true; + if(!m_pSpellState->m_bOtherSpelled && pWrtShell->HasOtherCnt()) + { + pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_OTHERSTART, FALSE ); + if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) + { + pWrtShell->SpellEnd(); + m_pSpellState->m_bOtherSpelled = true; + } + } + else + m_pSpellState->m_bOtherSpelled = true; + } } - else + + //search for a draw text object that contains error and spell it + if(!aRet.size() && + (m_pSpellState->m_bDrawingsSpelled || + !FindNextDrawTextError_Impl(*pWrtShell) || !SpellDrawText_Impl(*pWrtShell, aRet))) { - m_pSpellState->m_bBodySpelled = true; - if(!m_pSpellState->m_bOtherSpelled && pWrtShell->HasOtherCnt()) - { - pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_OTHEREND, DOCPOS_OTHERSTART, FALSE ); - if(!pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn)) - { - pWrtShell->SpellEnd(); - m_pSpellState->m_bOtherSpelled = true; - } - } - else - m_pSpellState->m_bOtherSpelled = true; + lcl_LeaveDrawText(*pWrtShell); + m_pSpellState->m_bDrawingsSpelled = true; } } - - //search for a draw text object that contains error and spell it - if(!aRet.size() && - (m_pSpellState->m_bDrawingsSpelled || - !FindNextDrawTextError_Impl(*pWrtShell) || !SpellDrawText_Impl(*pWrtShell, aRet))) - { - lcl_LeaveDrawText(*pWrtShell); - m_pSpellState->m_bDrawingsSpelled = true; - } } } // now only the rest of the body text can be spelled - @@ -430,7 +460,7 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) /*-- 09.09.2003 10:39:40--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rChanged) +void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rChanged, bool bRecheck) { SwWrtShell* pWrtShell = GetWrtShell_Impl(); DBG_ASSERT(!m_pSpellState->m_bInitialCall, "ApplyChangedSentence in initial call or after resume"); @@ -443,13 +473,19 @@ void SwSpellDialogChildWindow::ApplyChangedSentence(const svx::SpellPortions& rC SHELL_MODE_LIST_TEXT == eSelMode || SHELL_MODE_TABLE_LIST_TEXT == eSelMode || SHELL_MODE_TEXT == eSelMode; + + // evaluate if the same sentence should be rechecked or not. + // Sentences that got grammar checked should always be rechecked in order + // to detect possible errors that get introduced with the changes + bRecheck |= pWrtShell->HasLastSentenceGotGrammarChecked(); + if(bNormalText) - pWrtShell->ApplyChangedSentence(rChanged, m_bIsGrammarCheckingOn); + pWrtShell->ApplyChangedSentence(rChanged, bRecheck); else if(bDrawText ) { SdrView* pDrView = pWrtShell->GetDrawView(); SdrOutliner *pOutliner = pDrView->GetTextEditOutliner(); - pOutliner->ApplyChangedSentence(pDrView->GetTextEditOutlinerView()->GetEditView(), rChanged, m_bIsGrammarCheckingOn); + pOutliner->ApplyChangedSentence(pDrView->GetTextEditOutlinerView()->GetEditView(), rChanged, bRecheck); } } } @@ -847,7 +883,7 @@ bool SwSpellDialogChildWindow::FindNextDrawTextError_Impl(SwWrtShell& rSh) Point aTmp( 0,0 ); rSh.SelectObj( aTmp, 0, pTextObj ); SdrPageView* pPV = pDrView->GetSdrPageView(); - rView.BeginTextEdit( pTextObj, pPV, &rView.GetEditWin(), FALSE ); + rView.BeginTextEdit( pTextObj, pPV, &rView.GetEditWin(), FALSE, TRUE ); rView.AttrChangedNotify(&rSh); bNextDoc = true; } diff --git a/sw/source/ui/dochdl/dochdl.src b/sw/source/ui/dochdl/dochdl.src index fb4db99410..2afd19c92b 100644..100755 --- a/sw/source/ui/dochdl/dochdl.src +++ b/sw/source/ui/dochdl/dochdl.src @@ -73,13 +73,4 @@ String STR_DDEFORMAT { Text [ en-US ] = "DDE link" ; }; -Bitmap BMP_SW_TEAM_MUGSHOT -{ - File ="writerteam.bmp"; -}; - -String STR_SW_TEAM_NAMES -{ - Text = "Back row: Aidan Butler, Hans-Peter Burow, Caolan McNamara, Michael Brauer, Martin Maher, Gunnar Timm\nFront row: Thomas Lange, Oliver-Rainer Duesterhoeft, Henning Brinkmann, Andreas Martens, Oliver Specht, Frank Meies, Daniel Vogelheim"; -}; diff --git a/sw/source/ui/dochdl/gloshdl.cxx b/sw/source/ui/dochdl/gloshdl.cxx index f51cfde701..c19fb0bd9d 100644..100755 --- a/sw/source/ui/dochdl/gloshdl.cxx +++ b/sw/source/ui/dochdl/gloshdl.cxx @@ -607,48 +607,9 @@ BOOL SwGlossaryHdl::Expand( const String& rShortName, aShortName.Erase(nMaxLen); aShortName.AppendAscii(" ..."); } - if ( aShortName.EqualsAscii ( "StarWriterTeam", 0, 14 ) ) - { - String sGraphicName ( RTL_CONSTASCII_USTRINGPARAM ( "StarWriter team photo" ) ); - String sTeamCredits ( RTL_CONSTASCII_USTRINGPARAM ( "StarWriter team credits" ) ); - pWrtShell->StartUndo ( UNDO_INSGLOSSARY ); - pWrtShell->StartAllAction(); - if(pWrtShell->HasSelection()) - pWrtShell->DelLeft(); - Bitmap aBitmap ( SW_RES ( BMP_SW_TEAM_MUGSHOT ) ); - pWrtShell->Insert ( aEmptyStr, aEmptyStr, aBitmap); - pWrtShell->SetFlyName ( sGraphicName ); - SwTxtFmtColl* pColl = pWrtShell->GetTxtCollFromPool ( RES_POOLCOLL_LABEL_ABB ); - const IDocumentFieldsAccess* pIDFA = pWrtShell->getIDocumentFieldsAccess(); - SwFieldType* pType = pIDFA->GetFldType( RES_SETEXPFLD, pColl->GetName(), false ); - sal_uInt16 nId = pIDFA->GetFldTypes()->GetPos( pType ); - pWrtShell->InsertLabel( LTYPE_OBJECT, aEmptyStr, aEmptyStr, aEmptyStr, FALSE, nId, aEmptyStr ); - pWrtShell->SwFEShell::SetFlyName( sTeamCredits ); - pWrtShell->SwFEShell::SelectObj ( Point ( ULONG_MAX, ULONG_MAX ) ); - pWrtShell->EnterStdMode(); - pWrtShell->EndPara ( TRUE ); - String aTmp ( SW_RES ( STR_SW_TEAM_NAMES ) ); - pWrtShell->Insert ( aTmp ); - SvxAdjustItem aAdjustItem( SVX_ADJUST_CENTER, RES_PARATR_ADJUST ); - pWrtShell->SetAttr( aAdjustItem ); - pWrtShell->SttPara (); - pWrtShell->SplitNode(); - pWrtShell->Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE ); - SvxWeightItem aWeightItem ( WEIGHT_BOLD, RES_CHRATR_WEIGHT ); - pWrtShell->Insert ( String ( RTL_CONSTASCII_USTRINGPARAM ( "The StarWriter team!" ) ) ); - pWrtShell->SttPara ( TRUE ); - pWrtShell->SetAttr( aWeightItem); - pWrtShell->GotoFly ( sTeamCredits); - pWrtShell->EndAllAction(); - pWrtShell->EndUndo( UNDO_INSGLOSSARY ); - } - else - { - String aTmp( SW_RES(STR_NOGLOS)); - aTmp.SearchAndReplaceAscii("%1", aShortName); - InfoBox( pWrtShell->GetView().GetWindow(), aTmp ).Execute(); - - } + String aTmp( SW_RES(STR_NOGLOS)); + aTmp.SearchAndReplaceAscii("%1", aShortName); + InfoBox( pWrtShell->GetView().GetWindow(), aTmp ).Execute(); } return FALSE; diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index c2f668c6d5..c19189a563 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -322,6 +322,19 @@ SwTransferable::~SwTransferable() // ----------------------------------------------------------------------- +static SwDoc * lcl_GetDoc(SwDocFac & rDocFac) +{ + SwDoc *const pDoc = rDocFac.GetDoc(); + ASSERT( pDoc, "Document not found" ); + if (pDoc) + { + pDoc->SetClipBoard( true ); + } + return pDoc; +} + +// ----------------------------------------------------------------------- + void SwTransferable::ObjectReleased() { SwModule *pMod = SW_MOD(); @@ -443,7 +456,7 @@ sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor ) } pClpDocFac = new SwDocFac; - SwDoc* pTmpDoc = pClpDocFac->GetDoc(); + SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac); pTmpDoc->SetRefForDocShell( boost::addressof(aDocShellRef) ); pTmpDoc->LockExpFlds(); // nie die Felder updaten - Text so belassen @@ -530,8 +543,7 @@ sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor ) case SOT_FORMATSTR_ID_DRAWING: { - SwDoc *pDoc = pClpDocFac->GetDoc(); - ASSERT( pDoc, "Document not found" ); + SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac); bOK = SetObject( pDoc->GetDrawModel(), SWTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor ); } @@ -539,21 +551,22 @@ sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor ) case SOT_FORMAT_STRING: { - SwDoc* pDoc = pClpDocFac->GetDoc(); - ASSERT( pDoc, "Document not found" ); - pDoc->SetClipBoard( true ); - bOK = SetObject( pDoc, - SWTRANSFER_OBJECTTYPE_STRING, rFlavor ); + SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac); + bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_STRING, rFlavor ); } break; case SOT_FORMAT_RTF: - bOK = SetObject( pClpDocFac->GetDoc(), - SWTRANSFER_OBJECTTYPE_RTF, rFlavor ); + { + SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac); + bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_RTF, rFlavor ); + } break; case SOT_FORMATSTR_ID_HTML: - bOK = SetObject( pClpDocFac->GetDoc(), - SWTRANSFER_OBJECTTYPE_HTML, rFlavor ); + { + SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac); + bOK = SetObject( pDoc, SWTRANSFER_OBJECTTYPE_HTML, rFlavor ); + } break; case SOT_FORMATSTR_ID_SVXB: @@ -597,7 +610,7 @@ sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor ) // default: if( !aDocShellRef.Is() ) { - SwDoc *pDoc = pClpDocFac->GetDoc(); + SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac); SwDocShell* pNewDocSh = new SwDocShell( pDoc, SFX_CREATE_MODE_EMBEDDED ); aDocShellRef = pNewDocSh; @@ -805,7 +818,8 @@ int SwTransferable::PrepareForCopy( BOOL bIsCut ) pOrigGrf = pClpBitmap; pClpDocFac = new SwDocFac; - pWrtShell->Copy( pClpDocFac->GetDoc() ); + SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac); + pWrtShell->Copy( pDoc ); if (pOrigGrf && !pOrigGrf->GetBitmap().IsEmpty()) AddFormat( SOT_FORMATSTR_ID_SVXB ); @@ -827,7 +841,7 @@ int SwTransferable::PrepareForCopy( BOOL bIsCut ) else if ( nSelection == nsSelectionType::SEL_OLE ) { pClpDocFac = new SwDocFac; - SwDoc *pDoc = pClpDocFac->GetDoc(); + SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac); aDocShellRef = new SwDocShell( pDoc, SFX_CREATE_MODE_EMBEDDED); aDocShellRef->DoInitNew( NULL ); pWrtShell->Copy( pDoc ); @@ -857,8 +871,7 @@ int SwTransferable::PrepareForCopy( BOOL bIsCut ) if( pWrtShell->IsAddMode() && pWrtShell->SwCrsrShell::HasSelection() ) pWrtShell->CreateCrsr(); - SwDoc* pTmpDoc = pClpDocFac->GetDoc(); - pTmpDoc->SetClipBoard( true ); + SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac); pTmpDoc->SetRefForDocShell( boost::addressof(aDocShellRef) ); pTmpDoc->LockExpFlds(); // nie die Felder updaten - Text so belassen @@ -1017,7 +1030,8 @@ int SwTransferable::CalculateAndCopy() String aStr( pWrtShell->Calculate() ); pClpDocFac = new SwDocFac; - pWrtShell->Copy( pClpDocFac->GetDoc(), &aStr); + SwDoc *const pDoc = lcl_GetDoc(*pClpDocFac); + pWrtShell->Copy(pDoc, & aStr); eBufferType = TRNSFR_DOCUMENT; AddFormat( FORMAT_STRING ); @@ -1037,7 +1051,7 @@ int SwTransferable::CopyGlossary( SwTextBlocks& rGlossary, SwWait aWait( *pWrtShell->GetView().GetDocShell(), TRUE ); pClpDocFac = new SwDocFac; - SwDoc* pCDoc = pClpDocFac->GetDoc(); + SwDoc *const pCDoc = lcl_GetDoc(*pClpDocFac); SwNodes& rNds = pCDoc->GetNodes(); SwNodeIndex aNodeIdx( *rNds.GetEndOfContent().StartOfSectionNode() ); diff --git a/sw/source/ui/docvw/SidebarTxtControl.cxx b/sw/source/ui/docvw/SidebarTxtControl.cxx index 61d4884157..8353511e76 100644 --- a/sw/source/ui/docvw/SidebarTxtControl.cxx +++ b/sw/source/ui/docvw/SidebarTxtControl.cxx @@ -340,26 +340,32 @@ void SidebarTxtControl::Command( const CommandEvent& rCEvt ) } else { - SfxPopupMenuManager* aMgr = mrDocView.GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel()); - ((PopupMenu*)aMgr->GetSVMenu())->SetSelectHdl( LINK(this, SidebarTxtControl, Select) ); + SfxPopupMenuManager* pMgr = mrDocView.GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel()); + ((PopupMenu*)pMgr->GetSVMenu())->SetSelectHdl( LINK(this, SidebarTxtControl, Select) ); { - XubString aText = ((PopupMenu*)aMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR ); + XubString aText = ((PopupMenu*)pMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR ); SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, mrSidebarWin.GetAuthor()); aText = aRewriter.Apply(aText); - ((PopupMenu*)aMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); + ((PopupMenu*)pMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); } + Point aPos; if (rCEvt.IsMouseEvent()) - ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,rCEvt.GetMousePosPixel()); + aPos = rCEvt.GetMousePosPixel(); else { const Size aSize = GetSizePixel(); - const Point aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 ); - ((PopupMenu*)aMgr->GetSVMenu())->Execute(this,aPos); + aPos = Point( aSize.getWidth()/2, aSize.getHeight()/2 ); } - delete aMgr; + + //!! call different Execute function to get rid of the new thesaurus sub menu + //!! pointer created in the call to Popup. + //!! Otherwise we would have a memory leak (see also #i107205#) + //((PopupMenu*)pMgr->GetSVMenu())->Execute( this, aPos ); + pMgr->Execute( aPos, this ); + delete pMgr; } } else diff --git a/sw/source/ui/docvw/SidebarWin.cxx b/sw/source/ui/docvw/SidebarWin.cxx index cce6db3a89..cce6db3a89 100644..100755 --- a/sw/source/ui/docvw/SidebarWin.cxx +++ b/sw/source/ui/docvw/SidebarWin.cxx diff --git a/sw/source/ui/docvw/edtwin2.cxx b/sw/source/ui/docvw/edtwin2.cxx index bc12058041..8aa6c2e766 100644 --- a/sw/source/ui/docvw/edtwin2.cxx +++ b/sw/source/ui/docvw/edtwin2.cxx @@ -35,9 +35,7 @@ #include <stdio.h> #endif -#ifndef _HELP_HXX //autogen #include <vcl/help.hxx> -#endif #include <svl/stritem.hxx> #include <unotools/securityoptions.hxx> #include <tools/urlobj.hxx> @@ -46,24 +44,15 @@ #include <editeng/flditem.hxx> #include <svl/urihelper.hxx> #include <svx/svdotext.hxx> -#ifndef _OUTLINER_HXX //autogen -#define _EEITEMID_HXX #include <editeng/outliner.hxx> -#endif #include <svl/itemiter.hxx> #include <svx/svdview.hxx> #include <svx/svdpagv.hxx> #include <swmodule.hxx> -#ifndef _MODCFG_HXX #include <modcfg.hxx> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <edtwin.hxx> #include <dpage.hxx> #include <shellres.hxx> @@ -80,12 +69,8 @@ #include <txttxmrk.hxx> #include <uitool.hxx> #include <viewopt.hxx> -#ifndef _DOCVW_HRC #include <docvw.hrc> -#endif -#ifndef _UTLUI_HRC #include <utlui.hrc> -#endif #include <PostItMgr.hxx> #include <fmtfld.hxx> @@ -319,7 +304,8 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) { USHORT nOldSubType = pFld->GetSubType(); ((SwField*)pFld)->SetSubType(nsSwExtendedSubType::SUB_CMD); - sTxt = pFld->Expand(); + sTxt = + pFld->ExpandField(rSh.GetDoc()->IsClipBoard()); ((SwField*)pFld)->SetSubType(nOldSubType); } break; diff --git a/sw/source/ui/fldui/fldmgr.cxx b/sw/source/ui/fldui/fldmgr.cxx index 42b9bc43e6..4e707ce6ce 100644 --- a/sw/source/ui/fldui/fldmgr.cxx +++ b/sw/source/ui/fldui/fldmgr.cxx @@ -1435,7 +1435,7 @@ void SwFldMgr::UpdateCurFld(ULONG nFormat, } else { - pTmpFld = pCurFld->Copy(); + pTmpFld = pCurFld->CopyField(); bDelete = true; } diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx index 385ed8d60f..6c9ded39aa 100644 --- a/sw/source/ui/fldui/fldpage.cxx +++ b/sw/source/ui/fldui/fldpage.cxx @@ -42,28 +42,16 @@ #include <fmtfld.hxx> #include <viewopt.hxx> #include <fldedt.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <swmodule.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <expfld.hxx> -#ifndef _FLDTDLG_HXX #include <fldtdlg.hxx> -#endif -#ifndef _FLDPAGE_HXX #include <fldpage.hxx> -#endif #include <docufld.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif #include <sfx2/bindings.hxx> using namespace ::com::sun::star; @@ -218,7 +206,7 @@ BOOL SwFldPage::InsertFld(USHORT nTypeId, USHORT nSubType, const String& rPar1, } else // Feld aendern { - SwField * pTmpFld = m_pCurFld->Copy(); + SwField *const pTmpFld = m_pCurFld->CopyField(); String sPar1(rPar1); String sPar2(rPar2); diff --git a/sw/source/ui/inc/SwSpellDialogChildWindow.hxx b/sw/source/ui/inc/SwSpellDialogChildWindow.hxx index 5628aed15b..cc7462f6d8 100644 --- a/sw/source/ui/inc/SwSpellDialogChildWindow.hxx +++ b/sw/source/ui/inc/SwSpellDialogChildWindow.hxx @@ -48,8 +48,8 @@ class SwSpellDialogChildWindow void LockFocusNotification(bool bLock); protected: - virtual svx::SpellPortions GetNextWrongSentence (void); - virtual void ApplyChangedSentence(const svx::SpellPortions& rChanged); + virtual svx::SpellPortions GetNextWrongSentence(bool bRecheck); + virtual void ApplyChangedSentence(const svx::SpellPortions& rChanged, bool bRecheck); virtual void AddAutoCorrection(const String& rOld, const String& rNew, LanguageType eLanguage); virtual bool HasAutoCorrection(); virtual bool HasGrammarChecking(); diff --git a/sw/source/ui/inc/langhelper.hxx b/sw/source/ui/inc/langhelper.hxx index 419bfb33ad..562cb52287 100755 --- a/sw/source/ui/inc/langhelper.hxx +++ b/sw/source/ui/inc/langhelper.hxx @@ -31,31 +31,37 @@ class SwWrtShell; class SwView; class EditEngine; class EditView; +class OutlinerView; class SfxItemSet; struct ESelection; namespace SwLangHelper { - extern USHORT GetLanguageStatus(OutlinerView* pOLV,SfxItemSet& rSet); - extern bool SetLanguageStatus(OutlinerView* pOLV,SfxRequest &rReq,SwView &rView,SwWrtShell &rSh); + extern USHORT GetLanguageStatus( OutlinerView* pOLV, SfxItemSet& rSet ); + extern bool SetLanguageStatus( OutlinerView* pOLV, SfxRequest &rReq, SwView &rView, SwWrtShell &rSh ); - extern void SetLanguage(SwWrtShell &rWrtSh, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet); - extern void SetLanguage(SwWrtShell &rWrtSh, EditEngine* pEditEngine,ESelection aSelection, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet); - extern void SetLanguage_None(SwWrtShell &rWrtSh, EditEngine* pEditEngine,ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet ); - extern void SetLanguage_None(SwWrtShell &rWrtSh,bool bIsForSelection, SfxItemSet &rCoreSet ); + extern void SetLanguage( SwWrtShell &rWrtSh, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet ); +// extern void SetLanguage( SwWrtShell &rWrtSh, EditEngine* pEditEngine, ESelection aSelection, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet ); + extern void SetLanguage( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet ); + extern void SetLanguage_None( SwWrtShell &rWrtSh, bool bIsForSelection, SfxItemSet &rCoreSet ); +// extern void SetLanguage_None( SwWrtShell &rWrtSh, EditEngine* pEditEngine, ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet ); + extern void SetLanguage_None( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet ); + extern void ResetLanguages( SwWrtShell &rWrtSh, bool bIsForSelection ); +// extern void ResetLanguages( SwWrtShell &rWrtSh, EditEngine* pEditEngine, ESelection aSelection, bool bIsForSelection ); + extern void ResetLanguages( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection ); // document extern void SelectCurrentPara( SwWrtShell &rWrtSh ); // EditView extern void SelectPara( EditView &rEditView, const ESelection &rCurSel ); - extern String GetTextForLanguageGuessing(EditEngine* rEditEngine, ESelection aDocSelection ); + extern String GetTextForLanguageGuessing( EditEngine* rEditEngine, ESelection aDocSelection ); extern String GetTextForLanguageGuessing( SwWrtShell &rSh ); extern LanguageType GetLanguage( SfxItemSet aSet, USHORT nLangWhichId ); extern LanguageType GetLanguage( SwWrtShell &rSh, USHORT nLangWhichId ); - extern LanguageType GetCurrentLanguage(SfxItemSet aSet,USHORT nScriptType ); + extern LanguageType GetCurrentLanguage( SfxItemSet aSet, USHORT nScriptType ); extern LanguageType GetCurrentLanguage( SwWrtShell &rSh ); } diff --git a/sw/source/ui/inc/olmenu.hxx b/sw/source/ui/inc/olmenu.hxx index 3f433c249b..e2285207e4 100644 --- a/sw/source/ui/inc/olmenu.hxx +++ b/sw/source/ui/inc/olmenu.hxx @@ -51,23 +51,22 @@ class SwSpellPopup : public PopupMenu ::com::sun::star::linguistic2::XSpellAlternatives > xSpellAlt; ::com::sun::star::uno::Sequence< rtl::OUString > aSuggestions; + LanguageType nCheckedLanguage; - LanguageType nGuessLangWord; LanguageType nGuessLangPara; - USHORT nNumLanguageTextEntries; - USHORT nNumLanguageParaEntries; - USHORT nNumLanguageDocEntries; std::map< sal_Int16, ::rtl::OUString > aLangTable_Text; std::map< sal_Int16, ::rtl::OUString > aLangTable_Paragraph; - std::map< sal_Int16, ::rtl::OUString > aLangTable_Document; +// std::map< sal_Int16, ::rtl::OUString > aLangTable_Document; bool bGrammarResults; // show grammar results? Or show spellcheck results? Image aInfo16; - USHORT fillLangPopupMenu( PopupMenu *pPopupMenu , USHORT Lang_Start, ::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq,SwWrtShell* pWrtSh, USHORT nLangTable); + void fillLangPopupMenu( PopupMenu *pPopupMenu, USHORT nLangStart, + ::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq, SwWrtShell* pWrtSh, + std::map< sal_Int16, ::rtl::OUString > &rLangTable ); using PopupMenu::Execute; diff --git a/sw/source/ui/inc/swdtflvr.hxx b/sw/source/ui/inc/swdtflvr.hxx index 3e93acb021..382188f9e3 100644 --- a/sw/source/ui/inc/swdtflvr.hxx +++ b/sw/source/ui/inc/swdtflvr.hxx @@ -26,12 +26,10 @@ ************************************************************************/ #ifndef _SWDTFLVR_HXX #define _SWDTFLVR_HXX -#ifndef _TRANSFER_HXX #include <sfx2/objsh.hxx> #include <svtools/transfer.hxx> -#endif #include <vcl/graph.hxx> #include <sfx2/lnkbase.hxx> #include <com/sun/star/embed/XEmbeddedObject.hpp> diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 4712c76e24..039f9ff32c 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -437,6 +437,12 @@ public: virtual USHORT PrepareClose( BOOL bUI = TRUE, BOOL bForBrowsing = FALSE ); virtual void MarginChanged(); + // replace word/selection with text from the thesaurus + // (this code has special handling for "in word" character) + void InsertThesaurusSynonym( const String &rSynonmText, const String &rLookUpText, bool bValidSelection ); + bool IsValidSelectionForThesaurus() const; + String GetThesaurusLookUpText( bool bSelection ) const; + // Shell sofort wechseln -> fuer GetSelectionObject void StopShellTimer(); @@ -574,7 +580,7 @@ public: BOOL HasDrwObj(SdrObject *pSdrObj) const; BOOL HasOnlyObj(SdrObject *pSdrObj, UINT32 eObjInventor) const; BOOL BeginTextEdit( SdrObject* pObj, SdrPageView* pPV=NULL, - Window* pWin=NULL, BOOL bIsNewObj=FALSE); + Window* pWin=NULL, bool bIsNewObj=false, bool bSetSelectionToStart=false ); void StateTabWin(SfxItemSet&); @@ -599,6 +605,7 @@ public: SwDocShell *GetDocShell(); inline const SwDocShell *GetDocShell() const; inline FmFormShell *GetFormShell() { return pFormShell; } + inline const FmFormShell *GetFormShell() const { return pFormShell; } //damit in DToren der SubShells ggf. pShell zurueckgesetzt werden kann void ResetSubShell() { pShell = 0; } diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx index 895ba0683d..9a1d361012 100644 --- a/sw/source/ui/lingu/olmenu.cxx +++ b/sw/source/ui/lingu/olmenu.cxx @@ -28,85 +28,84 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include <hintids.hxx> +#include "SwRewriter.hxx" +#include "chrdlg.hrc" +#include "cmdid.h" +#include "comcore.hrc" +#include "crsskip.hxx" +#include "doc.hxx" +#include "docsh.hxx" //CheckSpellChanges +#include "edtwin.hxx" +#include "helpid.h" +#include "hintids.hxx" +#include "langhelper.hxx" +#include "ndtxt.hxx" +#include "olmenu.hrc" +#include "olmenu.hxx" +#include "swabstdlg.hxx" +#include "swmodule.hxx" +#include "swtypes.hxx" +#include "swundo.hxx" +#include "uitool.hxx" +#include "undobj.hxx" +#include "unomid.h" +#include "view.hxx" +#include "viewopt.hxx" +#include "wrtsh.hxx" +#include "wview.hxx" +#include "swabstdlg.hxx" +#include "chrdlg.hrc" + #ifndef _SVSTDARR_HXX #define _SVSTDARR_STRINGSDTOR #include <svl/svstdarr.hxx> #endif -#include <unotools/lingucfg.hxx> -#include <unotools/linguprops.hxx> -#include <svtools/filter.hxx> -#include <editeng/svxacorr.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/imagemgr.hxx> -#include <osl/file.hxx> -#include <rtl/string.hxx> +#include <comphelper/processfactory.hxx> +#include <editeng/acorrcfg.hxx> +#include <editeng/svxacorr.hxx> +#include <editeng/langitem.hxx> +#include <editeng/splwrap.hxx> +#include <editeng/brshitem.hxx> +#include <editeng/unolingu.hxx> #include <i18npool/mslangid.hxx> #include <linguistic/lngprops.hxx> #include <linguistic/misc.hxx> -#include <comphelper/processfactory.hxx> -#include <editeng/unolingu.hxx> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/frame/XStorable.hpp> -#include <com/sun/star/linguistic2/XSpellChecker1.hpp> -#include <com/sun/star/linguistic2/XLanguageGuessing.hpp> -#include <com/sun/star/linguistic2/SingleProofreadingError.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/frame/XModuleManager.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/i18n/ScriptType.hpp> -#include <svx/dlgutil.hxx> +#include <osl/file.hxx> +#include <rtl/string.hxx> +#include <svtools/filter.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/imagemgr.hxx> +#include <sfx2/request.hxx> +#include <sfx2/sfxdlg.hxx> #include <svl/itemset.hxx> -#include <editeng/langitem.hxx> -#include <editeng/splwrap.hxx> -#include <vcl/svapp.hxx> -#include <vcl/settings.hxx> -#include <unotools/lingucfg.hxx> -#include <editeng/acorrcfg.hxx> -#include <swmodule.hxx> -#include <cmdid.h> -#include <helpid.h> -#include <swtypes.hxx> -#include <wrtsh.hxx> -#include <view.hxx> -#include <docsh.hxx> //CheckSpellChanges -#include <olmenu.hxx> -#include <swundo.hxx> -#include <crsskip.hxx> -#include <ndtxt.hxx> -#include <olmenu.hrc> -#include <doc.hxx> - -// -> #111827# -#include <SwRewriter.hxx> -#include <comcore.hrc> -#include <undobj.hxx> -// <- #111827# - -#include <unomid.h> #include <svl/languageoptions.hxx> -#include <map> -#include <svtools/langtab.hxx> -#include <com/sun/star/document/XDocumentLanguages.hpp> -#include <edtwin.hxx> -#include <sfx2/sfxdlg.hxx> -#include "swabstdlg.hxx" -#include "chrdlg.hrc" -#include <editeng/brshitem.hxx> #include <svl/stritem.hxx> -#include <viewopt.hxx> -#include <uitool.hxx> +#include <svtools/filter.hxx> +#include <svtools/langtab.hxx> +#include <svx/dlgutil.hxx> +#include <unotools/lingucfg.hxx> +#include <unotools/linguprops.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> -#include <wview.hxx> -#include <sfx2/request.hxx> +#include <map> -#include <vcl/msgbox.hxx> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/document/XDocumentLanguages.hpp> +#include <com/sun/star/frame/XModuleManager.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/linguistic2/SingleProofreadingError.hpp> +#include <com/sun/star/linguistic2/XLanguageGuessing.hpp> +#include <com/sun/star/linguistic2/XSpellChecker1.hpp> +#include <com/sun/star/uno/Any.hxx> -#include <langhelper.hxx> using namespace ::com::sun::star; using ::rtl::OUString; @@ -214,63 +213,59 @@ inline bool lcl_checkScriptType( sal_Int16 nScriptType, LanguageType nLang ) return 0 != (nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang )); } -USHORT SwSpellPopup::fillLangPopupMenu( +void SwSpellPopup::fillLangPopupMenu( PopupMenu *pPopupMenu, - USHORT Lang_Start, - uno::Sequence< ::rtl::OUString > aSeq, + USHORT nLangItemIdStart, + uno::Sequence< OUString > aSeq, SwWrtShell* pWrtSh, - USHORT nLangTable ) + std::map< sal_Int16, ::rtl::OUString > &rLangTable ) { if (!pPopupMenu) - return 0; - - //Reference< awt::XMenuExtended > m_xMenuExtended( m_xPopupMenu, UNO_QUERY ); - std::map< ::rtl::OUString, ::rtl::OUString > LangItems; + return; SvtLanguageTable aLanguageTable; - USHORT nItemId = Lang_Start; - rtl::OUString curLang = aSeq[0]; - USHORT nScriptType = static_cast< sal_Int16 >(aSeq[1].toInt32()); - rtl::OUString keyboardLang = aSeq[2]; - rtl::OUString guessLang = aSeq[3]; - - //1--add current language - if(curLang!=OUString::createFromAscii("")) - { - LangItems[curLang]=curLang; - } + + // set of languages to be displayed in the sub menus + std::set< OUString > aLangItems; + + OUString aCurLang( aSeq[0] ); + USHORT nScriptType = static_cast< sal_Int16 >(aSeq[1].toInt32()); + OUString aKeyboardLang( aSeq[2] ); + OUString aGuessedTextLang( aSeq[3] ); + + if (aCurLang != OUString() && + LANGUAGE_DONTKNOW != aLanguageTable.GetType( aCurLang )) + aLangItems.insert( aCurLang ); - SvtLanguageTable aLangTable; //2--System - const AllSettings& rAllSettings=Application::GetSettings(); + const AllSettings& rAllSettings = Application::GetSettings(); LanguageType rSystemLanguage = rAllSettings.GetLanguage(); - if(rSystemLanguage!=LANGUAGE_DONTKNOW) + if (rSystemLanguage != LANGUAGE_DONTKNOW) { - if (lcl_checkScriptType(nScriptType,rSystemLanguage )) - LangItems[OUString(aLangTable.GetString(rSystemLanguage))]=OUString(aLangTable.GetString(rSystemLanguage)); + if (lcl_checkScriptType( nScriptType, rSystemLanguage )) + aLangItems.insert( aLanguageTable.GetString(rSystemLanguage) ); } //3--UI LanguageType rUILanguage = rAllSettings.GetUILanguage(); - if(rUILanguage!=LANGUAGE_DONTKNOW) + if (rUILanguage != LANGUAGE_DONTKNOW) { if (lcl_checkScriptType(nScriptType, rUILanguage )) - LangItems[OUString(aLangTable.GetString(rUILanguage))]=OUString(aLangTable.GetString(rUILanguage)); + aLangItems.insert( aLanguageTable.GetString(rUILanguage) ); } //4--guessed language - if(guessLang!=OUString::createFromAscii("")) + if (aGuessedTextLang.getLength() > 0) { - if (lcl_checkScriptType(nScriptType, aLanguageTable.GetType(guessLang))) - LangItems[guessLang]=guessLang; + if (lcl_checkScriptType(nScriptType, aLanguageTable.GetType(aGuessedTextLang))) + aLangItems.insert( aGuessedTextLang ); } - //5--keyboard language - if(keyboardLang!=OUString::createFromAscii("")) + if (aKeyboardLang.getLength() > 0) { - if (lcl_checkScriptType(nScriptType, aLanguageTable.GetType(keyboardLang))) - LangItems[keyboardLang]=keyboardLang; + if (lcl_checkScriptType(nScriptType, aLanguageTable.GetType(aKeyboardLang))) + aLangItems.insert( aKeyboardLang ); } //6--all languages used in current document @@ -278,74 +273,57 @@ USHORT SwSpellPopup::fillLangPopupMenu( uno::Reference< com::sun::star::frame::XController > xController( pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface()->getController(), uno::UNO_QUERY ); if ( xController.is() ) xModel = xController->getModel(); - uno::Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, uno::UNO_QUERY ); - /*the description of nScriptType - LATIN : 1 - ASIAN : 2 - COMPLEX:4 - LATIN + ASIAN : 3 - LATIN + COMPLEX : 5 - ASIAN + COMPLEX : 6 - LATIN + ASIAN + COMPLEX : 7 + /*the description of nScriptType flags + LATIN : 0x0001 + ASIAN : 0x0002 + COMPLEX: 0x0004 */ - - sal_Int16 nCount=7; - if(xDocumentLanguages.is()) + const sal_Int16 nMaxCount = 7; + if (xDocumentLanguages.is()) { - uno::Sequence< lang::Locale > rLocales(xDocumentLanguages->getDocumentLanguages(nScriptType,nCount)); - if(rLocales.getLength()>0) + uno::Sequence< lang::Locale > rLocales( xDocumentLanguages->getDocumentLanguages( nScriptType, nMaxCount ) ); + if (rLocales.getLength() > 0) { - for(USHORT i = 0; i<rLocales.getLength();++i) + for (USHORT i = 0; i < rLocales.getLength(); ++i) { - if (LangItems.size()==7) + if (aLangItems.size() == (size_t)nMaxCount) break; - const lang::Locale& rLocale=rLocales[i]; - if(lcl_checkScriptType(nScriptType, aLanguageTable.GetType(rLocale.Language))) - LangItems[ rtl::OUString(rLocale.Language)]=OUString(rLocale.Language); + const lang::Locale& rLocale = rLocales[i]; + if (lcl_checkScriptType( nScriptType, aLanguageTable.GetType( rLocale.Language ))) + aLangItems.insert( rLocale.Language ); } } } - bool bMultipleLanguages = (nLangTable != 0) || (curLang.compareToAscii( "*" ) == 0); - bool bNothingSelected = true; - MenuItemBits nMenuItemStyle = !bMultipleLanguages ? MIB_RADIOCHECK : 0; - for (std::map< rtl::OUString, rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it) + + USHORT nItemId = nLangItemIdStart; + const OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); // multiple languages in current selection + const OUString sEmpty; // 'no language found' from language guessing + std::set< OUString >::const_iterator it; + for (it = aLangItems.begin(); it != aLangItems.end(); ++it) { - rtl::OUString aEntryTxt( it->first ); - if (aEntryTxt != rtl::OUString( aLangTable.GetString( LANGUAGE_NONE ) )&& - aEntryTxt != rtl::OUString::createFromAscii("*") && - aEntryTxt.getLength() > 0) + OUString aEntryTxt( *it ); + if (aEntryTxt != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&& + aEntryTxt != sAsterix && + aEntryTxt != sEmpty) { - ++nItemId; - if (nLangTable == 0) // language for selection - aLangTable_Text[nItemId] = aEntryTxt; - else if (nLangTable == 1) // language for paragraph - aLangTable_Paragraph[nItemId] = aEntryTxt; - else if (nLangTable == 2) // language for document - aLangTable_Document[nItemId] = aEntryTxt; - - pPopupMenu->InsertItem( nItemId, aEntryTxt, nMenuItemStyle ); - if ((nLangTable == 0) && (aEntryTxt == curLang)) + DBG_ASSERT( nLangItemIdStart <= nItemId && nItemId <= nLangItemIdStart + MN_MAX_NUM_LANG, + "nItemId outside of expected range!" ); + pPopupMenu->InsertItem( nItemId, aEntryTxt, MIB_RADIOCHECK ); + if (aEntryTxt == aCurLang) { //make a check mark for the current language pPopupMenu->CheckItem( nItemId, TRUE ); - bNothingSelected = false; } + rLangTable[ nItemId ] = aEntryTxt; + ++nItemId; } } - //7--none - nItemId++; - pPopupMenu->InsertItem( nItemId, String(SW_RES( STR_LANGSTATUS_NONE )), nMenuItemStyle ); - if (bNothingSelected && !bMultipleLanguages) - pPopupMenu->CheckItem( nItemId, TRUE ); - - //More... - nItemId++; - pPopupMenu->InsertItem( nItemId, String(SW_RES( STR_LANGSTATUS_MORE )) ); - - return nItemId - Lang_Start; // return number of inserted entries + pPopupMenu->InsertItem( nLangItemIdStart + MN_NONE_OFFSET, String(SW_RES( STR_LANGSTATUS_NONE )), MIB_RADIOCHECK ); + pPopupMenu->InsertItem( nLangItemIdStart + MN_RESET_OFFSET, String(SW_RES( STR_RESET_TO_DEFAULT_LANGUAGE )), MIB_RADIOCHECK ); + pPopupMenu->InsertItem( nLangItemIdStart + MN_MORE_OFFSET, String(SW_RES( STR_LANGSTATUS_MORE )), MIB_RADIOCHECK ); } @@ -368,22 +346,22 @@ static Image lcl_GetImageFromPngUrl( const OUString &rFileUrl ) } -::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) +OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) { - ::rtl::OUString aLabel; + OUString aLabel; if ( aCmdURL.getLength() ) { try { - uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY ); + uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( OUString::createFromAscii("com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY ); if ( xNameAccess.is() ) { uno::Reference< container::XNameAccess > xUICommandLabels; - const ::rtl::OUString aModule( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ); + const OUString aModule( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ); uno::Any a = xNameAccess->getByName( aModule ); uno::Reference< container::XNameAccess > xUICommands; a >>= xUICommandLabels; - rtl::OUString aStr; + OUString aStr; uno::Sequence< beans::PropertyValue > aPropSeq; a = xUICommandLabels->getByName( aCmdURL ); if ( a >>= aPropSeq ) @@ -448,25 +426,28 @@ bGrammarResults(false) InsertSeparator(0); bEnable = sal_True; - for( sal_uInt16 i = 0, nPos = 1, nId = MN_AUTOCORR_START + 1; - i < nStringCount; ++i, ++nPos, ++nId ) + USHORT nAutoCorrItemId = MN_AUTOCORR_START; + USHORT nItemId = MN_SUGGESTION_START; + for (USHORT i = 0; i < nStringCount; ++i) { const String aEntry = aSuggestions[ i ]; - InsertItem( nPos, aEntry, 0, i ); - SetHelpId( nPos, HID_LINGU_REPLACE); - + InsertItem( nItemId, aEntry, 0, i ); + SetHelpId( nItemId, HID_LINGU_REPLACE); if (aSuggestionImageUrl.getLength() > 0) - SetItemImage( nPos, aImage ); + SetItemImage( nItemId, aImage ); - pMenu->InsertItem( nId, aEntry ); - pMenu->SetHelpId( nPos, HID_LINGU_AUTOCORR); + pMenu->InsertItem( nAutoCorrItemId, aEntry ); + pMenu->SetHelpId( nAutoCorrItemId, HID_LINGU_AUTOCORR); + + ++nAutoCorrItemId; + ++nItemId; } } OUString aIgnoreSelection( String( SW_RES( STR_IGNORE_SELECTION ) ) ); OUString aSpellingAndGrammar = RetrieveLabelFromCommand( C2U(".uno:SpellingAndGrammarDialog") ); - SetItemText( MN_SPELLING, aSpellingAndGrammar ); - USHORT nItemPos = GetItemPos( MN_IGNORE ); + SetItemText( MN_SPELLING_DLG, aSpellingAndGrammar ); + USHORT nItemPos = GetItemPos( MN_IGNORE_WORD ); InsertItem( MN_IGNORE_SELECTION, aIgnoreSelection, 0, nItemPos ); SetHelpId( MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION); @@ -489,11 +470,9 @@ bGrammarResults(false) nGuessLangPara = nGuessLangWord; } - pMenu = GetPopupMenu(MN_INSERT); - - bEnable = FALSE; // enable MN_INSERT? - + pMenu = GetPopupMenu(MN_ADD_TO_DIC); pMenu->CreateAutoMnemonics(); + bEnable = FALSE; // enable MN_ADD_TO_DIC? uno::Reference< linguistic2::XDictionaryList > xDicList( SvxGetDictionaryList() ); if (xDicList.is()) { @@ -508,6 +487,7 @@ bGrammarResults(false) const uno::Reference< linguistic2::XDictionary > *pDic = aDics.getConstArray(); USHORT nDicCount = static_cast< USHORT >(aDics.getLength()); + USHORT nItemId = MN_DICTIONARIES_START; for( USHORT i = 0; i < nDicCount; i++ ) { uno::Reference< linguistic2::XDictionary > xDicTmp( pDic[i], uno::UNO_QUERY ); @@ -523,8 +503,7 @@ bGrammarResults(false) { // the extra 1 is because of the (possible) external // linguistic entry above - USHORT nPos = MN_INSERT_START + i + 1; - pMenu->InsertItem( nPos, xDicTmp->getName() ); + pMenu->InsertItem( nItemId, xDicTmp->getName() ); bEnable = sal_True; uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY ); @@ -535,18 +514,20 @@ bGrammarResults(false) if (aDictionaryImageUrl.getLength() > 0) { Image aImage( lcl_GetImageFromPngUrl( aDictionaryImageUrl ) ); - pMenu->SetItemImage( nPos, aImage ); + pMenu->SetItemImage( nItemId, aImage ); } } + + ++nItemId; } } } - EnableItem( MN_INSERT, bEnable ); + EnableItem( MN_ADD_TO_DIC, bEnable ); //ADD NEW LANGUAGE MENU ITEM /////////////////////////////////////////////////////////////////////////// String aScriptTypesInUse( String::CreateFromInt32( pWrtSh->GetScriptType() ) ); - SvtLanguageTable aLangTable; + SvtLanguageTable aLanguageTable; // get keyboard language String aKeyboardLang; @@ -554,41 +535,42 @@ bGrammarResults(false) SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin(); nLang = rEditWin.GetInputLanguage(); if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) - aKeyboardLang = aLangTable.GetString( nLang ); + aKeyboardLang = aLanguageTable.GetString( nLang ); // get the language that is in use const String aMultipleLanguages = String::CreateFromAscii("*"); String aCurrentLang = aMultipleLanguages; nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh ); if (nLang != LANGUAGE_DONTKNOW) - aCurrentLang = aLangTable.GetString( nLang ); + aCurrentLang = aLanguageTable.GetString( nLang ); // build sequence for status value - uno::Sequence< ::rtl::OUString > aSeq( 4 ); + uno::Sequence< OUString > aSeq( 4 ); aSeq[0] = aCurrentLang; aSeq[1] = aScriptTypesInUse; aSeq[2] = aKeyboardLang; - aSeq[3] = aLangTable.GetString(nGuessLangWord); + aSeq[3] = aLanguageTable.GetString(nGuessLangWord); - pMenu = GetPopupMenu(MN_LANGUAGE_SELECTION); - nNumLanguageTextEntries = fillLangPopupMenu( pMenu, MN_LANGUAGE_SELECTION_START, aSeq, pWrtSh, 0 ); - EnableItem( MN_LANGUAGE_SELECTION, true ); + pMenu = GetPopupMenu(MN_SET_LANGUAGE_SELECTION); + fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_SELECTION_START, aSeq, pWrtSh, aLangTable_Text ); + EnableItem( MN_SET_LANGUAGE_SELECTION, true ); - pMenu = GetPopupMenu(MN_LANGUAGE_PARAGRAPH); - nNumLanguageParaEntries = fillLangPopupMenu( pMenu, MN_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, 1 ); - EnableItem( MN_LANGUAGE_PARAGRAPH, true ); + pMenu = GetPopupMenu(MN_SET_LANGUAGE_PARAGRAPH); + fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, aLangTable_Paragraph ); + EnableItem( MN_SET_LANGUAGE_PARAGRAPH, true ); /* - pMenu = GetPopupMenu(MN_LANGUAGE_ALL_TEXT); - nNumLanguageDocEntries = fillLangPopupMenu( pMenu, MN_LANGUAGE_ALL_TEXT_START, aSeq, pWrtSh, 2 ); - EnableItem( MN_LANGUAGE_ALL_TEXT, true ); + pMenu = GetPopupMenu(MN_SET_LANGUAGE_ALL_TEXT); + fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_ALL_TEXT_START, aSeq, pWrtSh, aLangTable_Document ); + EnableItem( MN_SET_LANGUAGE_ALL_TEXT, true ); */ uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(); Image rImg = ::GetImage( xFrame, - ::rtl::OUString::createFromAscii(".uno:SpellingAndGrammarDialog"), sal_False, + OUString::createFromAscii(".uno:SpellingAndGrammarDialog"), sal_False, Application::GetSettings().GetStyleSettings().GetHighContrastMode() ); - SetItemImage( MN_SPELLING, rImg ); - ////////////////////////////////////////////////////////////////////////////////// + SetItemImage( MN_SPELLING_DLG, rImg ); + ////////////////////////////////////////////////////////////////////////////////// + RemoveDisabledEntries( TRUE, TRUE ); SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); } @@ -601,7 +583,7 @@ SwSpellPopup::SwSpellPopup( SwWrtShell *pWrtSh, const linguistic2::ProofreadingResult &rResult, sal_Int32 nErrorInResult, - const uno::Sequence< rtl::OUString > &rSuggestions, + const uno::Sequence< OUString > &rSuggestions, const String &rParaText ) : PopupMenu( SW_RES(MN_SPELL_POPUP) ), pSh( pWrtSh ), @@ -611,13 +593,11 @@ aInfo16( SW_RES(IMG_INFO_16) ) { nCheckedLanguage = SvxLocaleToLanguage( rResult.aLocale ); - sal_Int16 nItemId = 1; - sal_Int16 nPos = 0; + USHORT nPos = 0; OUString aMessageText( rResult.aErrors[ nErrorInResult ].aShortComment ); InsertSeparator( nPos++ ); - InsertItem( nItemId, aMessageText, MIB_NOSELECT, nPos++ ); - SetItemImage( nItemId, aInfo16 ); - ++nItemId; + InsertItem( MN_SHORT_COMMENT, aMessageText, MIB_NOSELECT, nPos++ ); + SetItemImage( MN_SHORT_COMMENT, aInfo16 ); CreateAutoMnemonics(); @@ -634,12 +614,12 @@ aInfo16( SW_RES(IMG_INFO_16) ) aImage = Image( lcl_GetImageFromPngUrl( aSuggestionImageUrl ) ); } + USHORT nItemId = MN_SUGGESTION_START; for (sal_uInt16 i = 0; i < nStringCount; ++i) { const String aEntry = aSuggestions[ i ]; InsertItem( nItemId, aEntry, 0, nPos++ ); SetHelpId( nItemId, HID_LINGU_REPLACE ); - if (aSuggestionImageUrl.getLength() > 0) SetItemImage( nItemId, aImage ); @@ -650,8 +630,8 @@ aInfo16( SW_RES(IMG_INFO_16) ) OUString aIgnoreSelection( String( SW_RES( STR_IGNORE_SELECTION ) ) ); OUString aSpellingAndGrammar = RetrieveLabelFromCommand( C2U(".uno:SpellingAndGrammarDialog") ); - SetItemText( MN_SPELLING, aSpellingAndGrammar ); - USHORT nItemPos = GetItemPos( MN_IGNORE ); + SetItemText( MN_SPELLING_DLG, aSpellingAndGrammar ); + USHORT nItemPos = GetItemPos( MN_IGNORE_WORD ); InsertItem( MN_IGNORE_SELECTION, aIgnoreSelection, 0, nItemPos ); SetHelpId( MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION); @@ -674,13 +654,13 @@ aInfo16( SW_RES(IMG_INFO_16) ) nGuessLangPara = nGuessLangWord; } - EnableItem( MN_IGNORE, false ); - EnableItem( MN_INSERT, false ); + EnableItem( MN_IGNORE_WORD, false ); + EnableItem( MN_ADD_TO_DIC, false ); //ADD NEW LANGUAGE MENU ITEM /////////////////////////////////////////////////////////////////////////// String aScriptTypesInUse( String::CreateFromInt32( pWrtSh->GetScriptType() ) ); - SvtLanguageTable aLangTable; + SvtLanguageTable aLanguageTable; // get keyboard language String aKeyboardLang; @@ -688,39 +668,39 @@ aInfo16( SW_RES(IMG_INFO_16) ) SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin(); nLang = rEditWin.GetInputLanguage(); if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) - aKeyboardLang = aLangTable.GetString( nLang ); + aKeyboardLang = aLanguageTable.GetString( nLang ); // get the language that is in use const String aMultipleLanguages = String::CreateFromAscii("*"); String aCurrentLang = aMultipleLanguages; nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh ); if (nLang != LANGUAGE_DONTKNOW) - aCurrentLang = aLangTable.GetString( nLang ); + aCurrentLang = aLanguageTable.GetString( nLang ); // build sequence for status value - uno::Sequence< ::rtl::OUString > aSeq( 4 ); + uno::Sequence< OUString > aSeq( 4 ); aSeq[0] = aCurrentLang; aSeq[1] = aScriptTypesInUse; aSeq[2] = aKeyboardLang; - aSeq[3] = aLangTable.GetString(nGuessLangWord); + aSeq[3] = aLanguageTable.GetString(nGuessLangWord); - PopupMenu *pMenu = GetPopupMenu(MN_LANGUAGE_SELECTION); - nNumLanguageTextEntries = fillLangPopupMenu( pMenu, MN_LANGUAGE_SELECTION_START, aSeq, pWrtSh, 0 ); - EnableItem( MN_LANGUAGE_SELECTION, true ); + PopupMenu *pMenu = GetPopupMenu(MN_SET_LANGUAGE_SELECTION); + fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_SELECTION_START, aSeq, pWrtSh, aLangTable_Text ); + EnableItem( MN_SET_LANGUAGE_SELECTION, true ); - pMenu = GetPopupMenu(MN_LANGUAGE_PARAGRAPH); - nNumLanguageParaEntries = fillLangPopupMenu( pMenu, MN_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, 1 ); - EnableItem( MN_LANGUAGE_PARAGRAPH, true ); + pMenu = GetPopupMenu(MN_SET_LANGUAGE_PARAGRAPH); + fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_PARAGRAPH_START, aSeq, pWrtSh, aLangTable_Paragraph ); + EnableItem( MN_SET_LANGUAGE_PARAGRAPH, true ); /* - pMenu = GetPopupMenu(MN_LANGUAGE_ALL_TEXT); - nNumLanguageDocEntries = fillLangPopupMenu( pMenu, MN_LANGUAGE_ALL_TEXT_START, aSeq, pWrtSh, 2 ); - EnableItem( MN_LANGUAGE_ALL_TEXT, true ); + pMenu = GetPopupMenu(MN_SET_LANGUAGE_ALL_TEXT); + fillLangPopupMenu( pMenu, MN_SET_LANGUAGE_ALL_TEXT_START, aSeq, pWrtSh, aLangTable_Document ); + EnableItem( MN_SET_LANGUAGE_ALL_TEXT, true ); */ uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(); Image rImg = ::GetImage( xFrame, - ::rtl::OUString::createFromAscii(".uno:SpellingAndGrammarDialog"), sal_False, + OUString::createFromAscii(".uno:SpellingAndGrammarDialog"), sal_False, Application::GetSettings().GetStyleSettings().GetHighContrastMode() ); - SetItemImage( MN_SPELLING, rImg ); + SetItemImage( MN_SPELLING_DLG, rImg ); ////////////////////////////////////////////////////////////////////////////////// @@ -743,25 +723,23 @@ sal_uInt16 SwSpellPopup::Execute( const Rectangle& rWordPos, Window* pWin ) -----------------------------------------------------------------------*/ void SwSpellPopup::Execute( USHORT nId ) { - if (bGrammarResults && nId == 1) - return; // nothing to do since it is the error message (short comment) + if (nId == USHRT_MAX) + return; - sal_Bool bAutoCorr = sal_False; - if( nId > MN_AUTOCORR_START && nId < MN_LANGUAGE_SELECTION_START && nId != USHRT_MAX ) - { - nId -= MN_AUTOCORR_START; - bAutoCorr = sal_True; - } + if (/*bGrammarResults && */nId == MN_SHORT_COMMENT) + return; // nothing to do since it is the error message (short comment) - if( nId && nId != USHRT_MAX) + if ((MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) || + (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)) { - int nAltIdx = bGrammarResults ? nId - 2 : nId - 1; - if ( nAltIdx >= 0 && nAltIdx < aSuggestions.getLength() && (bGrammarResults || xSpellAlt.is()) ) + sal_Int32 nAltIdx = (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ? + nId - MN_SUGGESTION_START : nId - MN_AUTOCORR_START; + DBG_ASSERT( 0 <= nAltIdx && nAltIdx < aSuggestions.getLength(), "index out of range" ); + if (0 <= nAltIdx && nAltIdx < aSuggestions.getLength() && (bGrammarResults || xSpellAlt.is())) { sal_Bool bOldIns = pSh->IsInsMode(); pSh->SetInsMode( sal_True ); - DBG_ASSERT( 0 <= nAltIdx && nAltIdx <= aSuggestions.getLength(), "index out of range"); String aTmp( aSuggestions[ nAltIdx ] ); String aOrig( bGrammarResults ? OUString() : xSpellAlt->getWord() ); @@ -780,40 +758,30 @@ void SwSpellPopup::Execute( USHORT nId ) aRewriter.AddRule(UNDO_ARG1, pSh->GetCrsrDescr()); aRewriter.AddRule(UNDO_ARG2, String(SW_RES(STR_YIELDS))); - { - String aTmpStr; - - aTmpStr += String(SW_RES(STR_START_QUOTE)); - aTmpStr += aTmp; - aTmpStr += String(SW_RES(STR_END_QUOTE)); - aRewriter.AddRule(UNDO_ARG3, aTmpStr); - } + String aTmpStr( SW_RES(STR_START_QUOTE) ); + aTmpStr += aTmp; + aTmpStr += String(SW_RES(STR_END_QUOTE)); + aRewriter.AddRule(UNDO_ARG3, aTmpStr); pSh->StartUndo(UNDO_UI_REPLACE, &aRewriter); pSh->StartAction(); pSh->DelLeft(); pSh->Insert( aTmp ); + /* #102505# EndAction/EndUndo moved down since insertion of temporary auto correction is now undoable two and must reside in the same undo group.*/ - // nur aufnehmen, wenn es NICHT schon in der Autokorrektur vorhanden ist SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get()->GetAutoCorrect(); String aOrigWord( bGrammarResults ? OUString() : xSpellAlt->getWord() ) ; - String aNewWord; - if( nId ) - aNewWord = aSuggestions[ nAltIdx ]; - else - aNewWord = aOrigWord; + String aNewWord( aSuggestions[ nAltIdx ] ); SvxPrepareAutoCorrect( aOrigWord, aNewWord ); - if( bAutoCorr ) - { + if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END) pACorr->PutText( aOrigWord, aNewWord, nCheckedLanguage ); - } /* #102505# EndAction/EndUndo moved down since insertion of temporary auto correction is now undoable two and @@ -823,181 +791,141 @@ void SwSpellPopup::Execute( USHORT nId ) pSh->SetInsMode( bOldIns ); } - else + } + else if (nId == MN_SPELLING_DLG) + { + if (bGrammarResults) + { + SvtLinguConfig().SetProperty( A2OU( UPN_IS_GRAMMAR_INTERACTIVE ), uno::makeAny( sal_True )); + } + pSh->Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE ); { - if (nId < MN_LANGUAGE_SELECTION_START) + uno::Reference<linguistic2::XDictionaryList> xDictionaryList( SvxGetDictionaryList() ); + SvxDicListChgClamp aClamp( xDictionaryList ); + pSh->GetView().GetViewFrame()->GetDispatcher()-> + Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON ); + } + } + else if (nId == MN_IGNORE_SELECTION) + { + SwPaM *pPaM = pSh->GetCrsr(); + if (pPaM) + pSh->IgnoreGrammarErrorAt( *pPaM ); + } + else if (nId == MN_IGNORE_WORD) + { + uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY ); + linguistic::AddEntryToDic( xDictionary, + xSpellAlt->getWord(), sal_False, aEmptyStr, LANGUAGE_NONE ); + } + else if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) + { + OUString aWord( xSpellAlt->getWord() ); + USHORT nDicIdx = nId - MN_DICTIONARIES_START; + DBG_ASSERT( nDicIdx < aDics.getLength(), "dictionary index out of range" ); + + if (nDicIdx < aDics.getLength()) { - switch( nId ) + uno::Reference< linguistic2::XDictionary > xDic = aDics.getConstArray()[nDicIdx]; + INT16 nAddRes = linguistic::AddEntryToDic( xDic, aWord, FALSE, aEmptyStr, LANGUAGE_NONE ); + // save modified user-dictionary if it is persistent + uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY ); + if (xSavDic.is()) + xSavDic->store(); + + if (DIC_ERR_NONE != nAddRes + && !xDic->getEntry( aWord ).is()) { - case MN_SPELLING: - { - if (bGrammarResults) - { - SvtLinguConfig().SetProperty( A2OU( UPN_IS_GRAMMAR_INTERACTIVE ), uno::makeAny( sal_True )); - } - pSh->Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE ); - { - uno::Reference<linguistic2::XDictionaryList> xDictionaryList( SvxGetDictionaryList() ); - SvxDicListChgClamp aClamp( xDictionaryList ); - pSh->GetView().GetViewFrame()->GetDispatcher()-> - Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON ); - } - } - break; - case MN_IGNORE_SELECTION : - { - SwPaM *pPaM = pSh->GetCrsr(); - if (pPaM) - pSh->IgnoreGrammarErrorAt( *pPaM ); - } - break; - case MN_IGNORE : - { - uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY ); - linguistic::AddEntryToDic( - xDictionary, - xSpellAlt->getWord(), sal_False, - aEmptyStr, LANGUAGE_NONE ); - } - break; - case MN_INSERT: - DBG_ERROR("geht noch nicht!"); - break; - case MN_LANGUAGE_WORD: - case MN_LANGUAGE_PARA: - { - pSh->StartAction(); - - if( MN_LANGUAGE_PARA == nId ) - { - if( !pSh->IsSttPara() ) - pSh->MovePara( fnParaCurr, fnParaStart ); - pSh->SwapPam(); - if( !pSh->IsEndPara() ) - pSh->MovePara( fnParaCurr, fnParaEnd ); - } - - LanguageType nLangToUse = (MN_LANGUAGE_PARA == nId) ? nGuessLangPara : nGuessLangWord; - sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLangToUse ); - USHORT nResId = 0; - switch (nScriptType) - { - case SCRIPTTYPE_COMPLEX : nResId = RES_CHRATR_CTL_LANGUAGE; break; - case SCRIPTTYPE_ASIAN : nResId = RES_CHRATR_CJK_LANGUAGE; break; - default /*SCRIPTTYPE_LATIN*/: nResId = RES_CHRATR_LANGUAGE; break; - } - SfxItemSet aSet(pSh->GetAttrPool(), nResId, nResId ); - aSet.Put( SvxLanguageItem( nLangToUse, nResId ) ); - pSh->SetAttr( aSet ); - - pSh->EndAction(); - } - break; - default: - if(nId >= MN_INSERT_START ) - { - OUString aWord( xSpellAlt->getWord() ); - INT32 nDicIdx = nId - MN_INSERT_START - 1; - DBG_ASSERT( nDicIdx < aDics.getLength(), - "dictionary index out of range" ); - uno::Reference< linguistic2::XDictionary > xDic = - aDics.getConstArray()[nDicIdx]; - INT16 nAddRes = linguistic::AddEntryToDic( xDic, - aWord, FALSE, aEmptyStr, LANGUAGE_NONE ); - // save modified user-dictionary if it is persistent - uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY ); - if (xSavDic.is()) - xSavDic->store(); - - if (DIC_ERR_NONE != nAddRes - && !xDic->getEntry( aWord ).is()) - { - SvxDicError( - &pSh->GetView().GetViewFrame()->GetWindow(), - nAddRes ); - } - } + SvxDicError( + &pSh->GetView().GetViewFrame()->GetWindow(), + nAddRes ); } } - else + } + else + { + // Set language for selection or for paragraph... + + SfxItemSet aCoreSet( pSh->GetView().GetPool(), + RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, + RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, + RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, + 0 ); + String aNewLangTxt; + + if (MN_SET_LANGUAGE_SELECTION_START <= nId && nId <= MN_SET_LANGUAGE_SELECTION_END) + { + //Set language for current selection + aNewLangTxt = aLangTable_Text[nId]; + SwLangHelper::SetLanguage( *pSh, aNewLangTxt, true, aCoreSet ); + } + else if (nId == MN_SET_SELECTION_NONE) + { + //Set Language_None for current selection + SwLangHelper::SetLanguage_None( *pSh, true, aCoreSet ); + } + else if (nId == MN_SET_SELECTION_RESET) + { + //reset languages for current selection + SwLangHelper::ResetLanguages( *pSh, true ); + } + else if (nId == MN_SET_SELECTION_MORE) + { + //Open Format/Character Dialog + lcl_CharDialog( *pSh, true, nId, 0, 0 ); + } + else if (MN_SET_LANGUAGE_PARAGRAPH_START <= nId && nId <= MN_SET_LANGUAGE_PARAGRAPH_END) + { + //Set language for current paragraph + aNewLangTxt = aLangTable_Paragraph[nId]; + pSh->Push(); // save cursor + SwLangHelper::SelectCurrentPara( *pSh ); + SwLangHelper::SetLanguage( *pSh, aNewLangTxt, true, aCoreSet ); + pSh->Pop( FALSE ); // restore cursor + } + else if (nId == MN_SET_PARA_NONE) + { + //Set Language_None for current paragraph + pSh->Push(); // save cursor + SwLangHelper::SelectCurrentPara( *pSh ); + SwLangHelper::SetLanguage_None( *pSh, true, aCoreSet ); + pSh->Pop( FALSE ); // restore cursor + } + else if (nId == MN_SET_PARA_RESET) + { + //reset languages for current paragraph + pSh->Push(); // save cursor + SwLangHelper::SelectCurrentPara( *pSh ); + SwLangHelper::ResetLanguages( *pSh, true ); + pSh->Pop( FALSE ); // restore cursor + } + else if (nId == MN_SET_PARA_MORE) + { + pSh->Push(); // save cursor + SwLangHelper::SelectCurrentPara( *pSh ); + //Open Format/Character Dialog + lcl_CharDialog( *pSh, true, nId, 0, 0 ); + pSh->Pop( FALSE ); // restore cursor + } +#if 0 + else if (nId == MN_SET_LANGUAGE_ALL_TEXT_START + nNumLanguageDocEntries - 1) + { + //Set Language_None as the default language + SwLangHelper::SetLanguage_None( *pSh, false, aCoreSet ); + } + else if (nId == MN_SET_LANGUAGE_ALL_TEXT_START + nNumLanguageDocEntries) + { + // open the dialog "Tools/Options/Language Settings - Language" + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + if (pFact) { - SfxItemSet aCoreSet( pSh->GetView().GetPool(), - RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, - RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, - RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE, - 0 ); - String aNewLangTxt; - -// pSh->StartAction(); - - if (nId >= MN_LANGUAGE_SELECTION_START && nId < MN_LANGUAGE_SELECTION_START + nNumLanguageTextEntries - 1) - { - //Set language for current selection - aNewLangTxt=aLangTable_Text[nId]; - SwLangHelper::SetLanguage( *pSh, aNewLangTxt, true, aCoreSet ); - } - else if (nId == MN_LANGUAGE_SELECTION_START + nNumLanguageTextEntries - 1) - { - //Set Language_None for current selection - SwLangHelper::SetLanguage_None( *pSh, true, aCoreSet ); - } - else if (nId == MN_LANGUAGE_SELECTION_START + nNumLanguageTextEntries) - { - //Open Format/Character Dialog - lcl_CharDialog( *pSh, true, nId, 0, 0 ); - } - else if (nId >= MN_LANGUAGE_PARAGRAPH_START && nId < MN_LANGUAGE_PARAGRAPH_START + nNumLanguageParaEntries - 1) - { - //Set language for current paragraph - aNewLangTxt=aLangTable_Paragraph[nId]; - pSh->Push(); // save cursor - SwLangHelper::SelectCurrentPara( *pSh ); - SwLangHelper::SetLanguage( *pSh, aNewLangTxt, true, aCoreSet ); - pSh->Pop( FALSE ); // restore cursor - } - else if (nId == MN_LANGUAGE_PARAGRAPH_START + nNumLanguageParaEntries - 1) - { - //Set Language_None for current paragraph - pSh->Push(); // save cursor - SwLangHelper::SelectCurrentPara( *pSh ); - SwLangHelper::SetLanguage_None( *pSh, true, aCoreSet ); - pSh->Pop( FALSE ); // restore cursor - } - else if (nId == MN_LANGUAGE_PARAGRAPH_START + nNumLanguageParaEntries) - { - pSh->Push(); // save cursor - SwLangHelper::SelectCurrentPara( *pSh ); - //Open Format/Character Dialog - lcl_CharDialog( *pSh, true, nId, 0, 0 ); - pSh->Pop( FALSE ); // restore cursor - } - else if (nId >= MN_LANGUAGE_ALL_TEXT_START && nId < MN_LANGUAGE_ALL_TEXT_START + nNumLanguageDocEntries - 1) - { - //Set selected language as the default language - aNewLangTxt=aLangTable_Document[nId]; - SwLangHelper::SetLanguage( *pSh, aNewLangTxt, false, aCoreSet ); - } - else if (nId == MN_LANGUAGE_ALL_TEXT_START + nNumLanguageDocEntries - 1) - { - //Set Language_None as the default language - SwLangHelper::SetLanguage_None( *pSh, false, aCoreSet ); - } - else if (nId == MN_LANGUAGE_ALL_TEXT_START + nNumLanguageDocEntries) - { - // open the dialog "Tools/Options/Language Settings - Language" - SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); - if (pFact) - { - VclAbstractDialog* pDlg = pFact->CreateVclDialog( pSh->GetView().GetWindow(), SID_LANGUAGE_OPTIONS ); - pDlg->Execute(); - delete pDlg; - } - } - -// pSh->EndAction(); + VclAbstractDialog* pDlg = pFact->CreateVclDialog( pSh->GetView().GetWindow(), SID_LANGUAGE_OPTIONS ); + pDlg->Execute(); + delete pDlg; } } - } +#endif + } pSh->EnterStdMode(); } diff --git a/sw/source/ui/lingu/olmenu.hrc b/sw/source/ui/lingu/olmenu.hrc index 900c470545..6afce9516b 100644 --- a/sw/source/ui/lingu/olmenu.hrc +++ b/sw/source/ui/lingu/olmenu.hrc @@ -30,35 +30,65 @@ #include "rcid.hrc" -#define MN_SPELL_POPUP (RC_LINGU_BEGIN + 1) -#define STR_SPELL_OK (RC_LINGU_BEGIN + 2) -#define STR_HYP_OK (RC_LINGU_BEGIN + 3) -#define STR_WORD (RC_LINGU_BEGIN + 4) -#define STR_PARAGRAPH (RC_LINGU_BEGIN + 5) -#define STR_LANGSTATUS_NONE (RC_LINGU_BEGIN + 6) -#define STR_LANGSTATUS_MORE (RC_LINGU_BEGIN + 7) -#define STR_IGNORE_SELECTION (RC_LINGU_BEGIN + 8) +#define MN_SPELL_POPUP (RC_LINGU_BEGIN + 1) +#define STR_SPELL_OK (RC_LINGU_BEGIN + 2) +#define STR_HYP_OK (RC_LINGU_BEGIN + 3) +#define STR_WORD (RC_LINGU_BEGIN + 4) +#define STR_PARAGRAPH (RC_LINGU_BEGIN + 5) +#define STR_LANGSTATUS_NONE (RC_LINGU_BEGIN + 6) +#define STR_LANGSTATUS_MORE (RC_LINGU_BEGIN + 7) +#define STR_IGNORE_SELECTION (RC_LINGU_BEGIN + 8) +#define STR_RESET_TO_DEFAULT_LANGUAGE (RC_LINGU_BEGIN + 9) -#define IMG_INFO_16 (RC_LINGU_BEGIN + 8) +#define IMG_INFO_16 (RC_LINGU_BEGIN + 100) //! Don't change these values. You may break context menu modifying extensions! -#define MN_SPELLING 100 -#define MN_IGNORE_SELECTION 101 -#define MN_IGNORE 102 -#define MN_INSERT 103 -#define MN_AUTOCORR 104 -#define MN_LANGUAGE_WORD 105 -#define MN_LANGUAGE_PARA 106 -#define MN_LANGUAGE_SELECTION 107 -#define MN_LANGUAGE_PARAGRAPH 108 -#define MN_LANGUAGE_ALL_TEXT 109 - -#define MN_INSERT_START 500 -#define MN_AUTOCORR_START 900 - -#define MN_LANGUAGE_SELECTION_START 1170 -#define MN_LANGUAGE_PARAGRAPH_START 1270 -#define MN_LANGUAGE_ALL_TEXT_START 1370 +#define MN_SPELLING_DLG 200 +#define MN_IGNORE_SELECTION 201 +#define MN_IGNORE_WORD 202 +#define MN_ADD_TO_DIC 203 +#define MN_AUTOCORR 204 +#define MN_SET_LANGUAGE_SELECTION 205 +#define MN_SET_LANGUAGE_PARAGRAPH 206 +#define MN_SET_LANGUAGE_ALL_TEXT 207 +#define MN_SHORT_COMMENT 208 + +// id range for dictionaries sub menu +#define MN_DICTIONARIES_START 300 +#define MN_DICTIONARIES_END (MN_DICTIONARIES_START + 99) + +// id range for suggestions from spell and grammar checker +#define MN_SUGGESTION_START 500 +#define MN_SUGGESTION_END (MN_SUGGESTION_START + MN_MAX_NUM_LANG) + +// id range for auto correction sub menu entries +#define MN_AUTOCORR_START 700 +#define MN_AUTOCORR_END (MN_AUTOCORR_START + MN_MAX_NUM_LANG) + +// max number of language entries sub menus +#define MN_MAX_NUM_LANG 99 + +#define MN_NONE_OFFSET (MN_MAX_NUM_LANG + 1) +#define MN_RESET_OFFSET (MN_MAX_NUM_LANG + 2) +#define MN_MORE_OFFSET (MN_MAX_NUM_LANG + 3) + +// id range for 'set language for selection' sub menu entries +#define MN_SET_LANGUAGE_SELECTION_START 900 +#define MN_SET_LANGUAGE_SELECTION_END (MN_SET_LANGUAGE_SELECTION_START + MN_MAX_NUM_LANG) +#define MN_SET_SELECTION_NONE (MN_SET_LANGUAGE_SELECTION_START + MN_NONE_OFFSET) +#define MN_SET_SELECTION_RESET (MN_SET_LANGUAGE_SELECTION_START + MN_RESET_OFFSET) +#define MN_SET_SELECTION_MORE (MN_SET_LANGUAGE_SELECTION_START + MN_MORE_OFFSET) + +// id range for 'set language for paragraph' sub menu entries +#define MN_SET_LANGUAGE_PARAGRAPH_START 1100 +#define MN_SET_LANGUAGE_PARAGRAPH_END (MN_SET_LANGUAGE_PARAGRAPH_START + MN_MAX_NUM_LANG) +#define MN_SET_PARA_NONE (MN_SET_LANGUAGE_PARAGRAPH_START + MN_NONE_OFFSET) +#define MN_SET_PARA_RESET (MN_SET_LANGUAGE_PARAGRAPH_START + MN_RESET_OFFSET) +#define MN_SET_PARA_MORE (MN_SET_LANGUAGE_PARAGRAPH_START + MN_MORE_OFFSET) + +// id range for 'set language for all text' sub menu entries +#define MN_SET_LANGUAGE_ALL_TEXT_START 1300 +#define MN_SET_LANGUAGE_ALL_TEXT_END (MN_SET_LANGUAGE_ALL_TEXT_START + MN_MAX_NUM_LANG) #endif diff --git a/sw/source/ui/lingu/olmenu.src b/sw/source/ui/lingu/olmenu.src index 3910c13201..9173509a69 100644 --- a/sw/source/ui/lingu/olmenu.src +++ b/sw/source/ui/lingu/olmenu.src @@ -38,13 +38,13 @@ Menu MN_SPELL_POPUP { MenuItem { - Identifier = MN_IGNORE ; + Identifier = MN_IGNORE_WORD ; HelpID = HID_LINGU_IGNORE_WORD ; Text [ en-US ] = "Ignore All" ; }; MenuItem { - Identifier = MN_INSERT ; + Identifier = MN_ADD_TO_DIC ; HelpID = HID_LINGU_ADD_WORD ; SubMenu = Menu { @@ -62,14 +62,14 @@ Menu MN_SPELL_POPUP }; MenuItem { - Identifier = MN_SPELLING ; + Identifier = MN_SPELLING_DLG ; HelpID = HID_LINGU_SPELLING_DLG ; Text [ en-US ] = "~Spellcheck..." ; }; SEPARATOR MenuItem { - Identifier = MN_LANGUAGE_SELECTION ; + Identifier = MN_SET_LANGUAGE_SELECTION ; SubMenu = Menu { }; @@ -77,7 +77,7 @@ Menu MN_SPELL_POPUP }; MenuItem { - Identifier = MN_LANGUAGE_PARAGRAPH ; + Identifier = MN_SET_LANGUAGE_PARAGRAPH ; SubMenu = Menu { }; @@ -86,7 +86,7 @@ Menu MN_SPELL_POPUP /* MenuItem { - Identifier = MN_LANGUAGE_ALL_TEXT ; + Identifier = MN_SET_LANGUAGE_ALL_TEXT ; SubMenu = Menu { }; @@ -115,6 +115,11 @@ String STR_LANGSTATUS_NONE { Text [ en-US ] = "None (Do not check spelling)" ; }; +String STR_RESET_TO_DEFAULT_LANGUAGE +{ + Text [ en-US ] = "Reset to Default Language" ; + Text [ x-comment ] = " "; +}; String STR_LANGSTATUS_MORE { Text [ en-US ] = "More..." ; diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index 91527760f9..3486fd06a8 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -27,13 +27,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> -#include <tools/shl.hxx> #include <com/sun/star/i18n/TransliterationModules.hpp> +#include <com/sun/star/i18n/TransliterationModulesExtra.hpp> #include <com/sun/star/i18n/TextConversionOption.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/lang/XInitialization.hpp> + +#include <tools/shl.hxx> +#include <i18npool/mslangid.hxx> #include <sfx2/objface.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/bindings.hxx> @@ -117,8 +121,8 @@ #include <docsh.hxx> #include <svl/undo.hxx> -#include "swabstdlg.hxx" //CHINA001 -#include "chrdlg.hrc" //CHINA001 +#include "swabstdlg.hxx" +#include "chrdlg.hrc" #include "misc.hrc" #include <app.hrc> @@ -1138,7 +1142,17 @@ void SwAnnotationShell::ExecLingu(SfxRequest &rReq) bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,rView,rSh); break; } - case FN_THESAURUS_DLG: + case SID_THES: + { + String aReplaceText; + SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False ); + if (pItem2) + aReplaceText = pItem2->GetValue(); + if (aReplaceText.Len() > 0) + ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText ); + break; + } + case SID_THESAURUS: { pOLV->StartThesaurus(); break; @@ -1246,8 +1260,25 @@ void SwAnnotationShell::GetLinguState(SfxItemSet &rSet) SwLangHelper::GetLanguageStatus(pOLV,rSet); break; } + + case SID_THES: + { + String aStatusVal; + LanguageType nLang = LANGUAGE_NONE; + bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() ); + rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); + + // disable "Thesaurus" context menu entry if there is nothing to look up + uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); + lang::Locale aLocale( SvxCreateLocale( nLang ) ); + if (!bIsLookUpWord || + !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale )) + rSet.DisableItem( SID_THES ); + break; + } + // disable "Thesaurus" if the language is not supported - case FN_THESAURUS_DLG: + case SID_THESAURUS: { const SfxPoolItem &rItem = rView.GetWrtShell().GetDoc()->GetDefault( GetWhichOfScript( RES_CHRATR_LANGUAGE, @@ -1257,7 +1288,7 @@ void SwAnnotationShell::GetLinguState(SfxItemSet &rSet) uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); if (!xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( SvxCreateLocale( nLang ) )) - rSet.DisableItem( FN_THESAURUS_DLG ); + rSet.DisableItem( SID_THESAURUS ); } break; case SID_HANGUL_HANJA_CONVERSION: @@ -1295,6 +1326,15 @@ void SwAnnotationShell::ExecTransliteration(SfxRequest &rReq) switch( rReq.GetSlot() ) { + case SID_TRANSLITERATE_SENTENCE_CASE: + nMode = TransliterationModulesExtra::SENTENCE_CASE; + break; + case SID_TRANSLITERATE_TITLE_CASE: + nMode = TransliterationModulesExtra::TITLE_CASE; + break; + case SID_TRANSLITERATE_TOGGLE_CASE: + nMode = TransliterationModulesExtra::TOGGLE_CASE; + break; case SID_TRANSLITERATE_UPPER: nMode = TransliterationModules_LOWERCASE_UPPERCASE; break; diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx index e1e0c3b9da..3004ebd4d4 100644 --- a/sw/source/ui/shells/drwtxtex.cxx +++ b/sw/source/ui/shells/drwtxtex.cxx @@ -27,8 +27,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include <hintids.hxx> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> + +#include <comphelper/processfactory.hxx> +#include <i18npool/mslangid.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/request.hxx> #include <tools/shl.hxx> #include <svx/svdview.hxx> #include <editeng/spltitem.hxx> @@ -37,9 +43,7 @@ #include <editeng/widwitem.hxx> #include <editeng/kernitem.hxx> #include <editeng/escpitem.hxx> -#ifndef _SVX_PARAITEM_HXX //autogen #include <editeng/lspcitem.hxx> -#endif #include <editeng/adjitem.hxx> #include <editeng/crsditem.hxx> #include <editeng/shdditem.hxx> @@ -49,9 +53,7 @@ #include <editeng/fhgtitem.hxx> #include <editeng/colritem.hxx> #include <editeng/wghtitem.hxx> -#ifndef _SVX_CNTRITEM_HXX //autogen #include <editeng/cntritem.hxx> -#endif #include <editeng/postitem.hxx> #include <editeng/frmdiritem.hxx> #include <svx/svdoutl.hxx> @@ -59,6 +61,8 @@ #include <svl/whiter.hxx> #include <svl/cjkoptions.hxx> #include <svl/ctloptions.hxx> +#include <svtools/langtab.hxx> +#include <svl/languageoptions.hxx> #include <sfx2/bindings.hxx> #include <vcl/msgbox.hxx> #include <sfx2/dispatch.hxx> @@ -67,48 +71,66 @@ #include <editeng/editstat.hxx> #include <svx/hlnkitem.hxx> #include <svx/htmlmode.hxx> +#include <svl/languageoptions.hxx> +#include <svl/slstitm.hxx> #include <editeng/langitem.hxx> +#include <svtools/langtab.hxx> #include <editeng/unolingu.hxx> #include <editeng/scripttypeitem.hxx> #include <editeng/writingmodeitem.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/editeng.hxx> +#include <editeng/editdata.hxx> +#include <editeng/outliner.hxx> +#include <vcl/window.hxx> +#include <editeng/editview.hxx> +#include <vcl/outdev.hxx> +#include <editeng/hyznitem.hxx> +#include <editeng/kernitem.hxx> +#include <editeng/langitem.hxx> +#include <editeng/lspcitem.hxx> +#include <editeng/orphitem.hxx> +#include <editeng/outliner.hxx> +#include <editeng/postitem.hxx> +#include <editeng/scripttypeitem.hxx> +#include <editeng/shdditem.hxx> +#include <editeng/spltitem.hxx> +#include <svx/svdoutl.hxx> +#include <svx/svdview.hxx> +#include <editeng/udlnitem.hxx> +#include <editeng/unolingu.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/widwitem.hxx> +#include <editeng/writingmodeitem.hxx> +#include <tools/shl.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/outdev.hxx> +#include <vcl/window.hxx> + +#include <cmdid.h> #include <doc.hxx> -#include <wview.hxx> -#include <viewopt.hxx> -#include <wrtsh.hxx> -#include <uitool.hxx> +#include <docstat.hxx> +#include <drwtxtsh.hxx> +#include <edtwin.hxx> +#include <globals.hrc> +#include <hintids.hxx> +#include <initui.hxx> // fuer SpellPointer +#include <langhelper.hxx> #include <pardlg.hxx> +#include <shells.hrc> +#include <string.h> #include <swdtflvr.hxx> -#include <drwtxtsh.hxx> #include <swmodule.hxx> -#include <initui.hxx> // fuer SpellPointer -#include <edtwin.hxx> #include <swwait.hxx> -#include <docstat.hxx> - -#include <comphelper/processfactory.hxx> -#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <uitool.hxx> +#include <viewopt.hxx> +#include <wrtsh.hxx> +#include <wview.hxx> -#include <cmdid.h> -#include <globals.hrc> -#include <shells.hrc> #include "swabstdlg.hxx" #include "chrdlg.hrc" #include "misc.hrc" -//modified on Jul. 30th -#include <svl/languageoptions.hxx> -#include <editeng/langitem.hxx> -#include <svtools/langtab.hxx> -#include <svl/slstitm.hxx> -#include <string.h> - -#include <editeng/eeitem.hxx> -#include <editeng/editeng.hxx> -#include <editeng/editdata.hxx> -#include <editeng/outliner.hxx> -#include <vcl/window.hxx> -#include <editeng/editview.hxx> -#include <vcl/outdev.hxx> #include <langhelper.hxx> @@ -148,6 +170,18 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) bRestoreSelection = SwLangHelper::SetLanguageStatus(pOLV,rReq,GetView(),rSh); break; } + + case SID_THES: + { + String aReplaceText; + SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False ); + if (pItem2) + aReplaceText = pItem2->GetValue(); + if (aReplaceText.Len() > 0) + ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText ); + break; + } + case SID_ATTR_CHAR_FONT: case SID_ATTR_CHAR_FONTHEIGHT: case SID_ATTR_CHAR_WEIGHT: @@ -569,7 +603,27 @@ void SwDrawTextShell::GetState(SfxItemSet& rSet) nSlotId = SwLangHelper::GetLanguageStatus(pOLV,rSet);; break; } - case SID_ATTR_PARA_ADJUST_LEFT: eAdjust = SVX_ADJUST_LEFT; goto ASK_ADJUST; + + case SID_THES: + { + String aStatusVal; + LanguageType nLang = LANGUAGE_NONE; + bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, pOLV->GetEditView() ); + rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); + + // disable "Thesaurus" context menu entry if there is nothing to look up + uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); + lang::Locale aLocale( SvxCreateLocale( nLang ) ); + if (!bIsLookUpWord || + !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale )) + rSet.DisableItem( SID_THES ); + + //! avoid puting the same item as SfxBoolItem at the end of this function + nSlotId = 0; + break; + } + + case SID_ATTR_PARA_ADJUST_LEFT: eAdjust = SVX_ADJUST_LEFT; goto ASK_ADJUST; case SID_ATTR_PARA_ADJUST_RIGHT: eAdjust = SVX_ADJUST_RIGHT; goto ASK_ADJUST; case SID_ATTR_PARA_ADJUST_CENTER: eAdjust = SVX_ADJUST_CENTER; goto ASK_ADJUST; case SID_ATTR_PARA_ADJUST_BLOCK: eAdjust = SVX_ADJUST_BLOCK; goto ASK_ADJUST; @@ -620,19 +674,17 @@ ASK_ESCAPE: } break; - case FN_THESAURUS_DLG: + case SID_THESAURUS: { // disable "Thesaurus" if the language is not supported const SfxPoolItem &rItem = GetShell().GetDoc()->GetDefault( GetWhichOfScript( RES_CHRATR_LANGUAGE, GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage())) ); - LanguageType nLang = ((const SvxLanguageItem &) - rItem).GetLanguage(); - // + LanguageType nLang = ((const SvxLanguageItem &) rItem).GetLanguage(); + uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); - if (!xThes.is() || nLang == LANGUAGE_NONE || - !xThes->hasLocale( SvxCreateLocale( nLang ) )) - rSet.DisableItem( FN_THESAURUS_DLG ); + if (!xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( SvxCreateLocale( nLang ) )) + rSet.DisableItem( SID_THESAURUS ); nSlotId = 0; } break; diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index e780143cb8..a46210639a 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -52,6 +52,7 @@ #include <editeng/editstat.hxx> #include <svx/svdoutl.hxx> #include <com/sun/star/i18n/TransliterationModules.hpp> +#include <com/sun/star/i18n/TransliterationModulesExtra.hpp> #include <com/sun/star/i18n/TextConversionOption.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/lang/XInitialization.hpp> @@ -392,7 +393,7 @@ void SwDrawTextShell::ExecDrawLingu(SfxRequest &rReq) { switch(rReq.GetSlot()) { - case FN_THESAURUS_DLG: + case SID_THESAURUS: pOLV->StartThesaurus(); break; @@ -717,6 +718,15 @@ void SwDrawTextShell::ExecTransliteration( SfxRequest & rReq ) switch( rReq.GetSlot() ) { + case SID_TRANSLITERATE_SENTENCE_CASE: + nMode = TransliterationModulesExtra::SENTENCE_CASE; + break; + case SID_TRANSLITERATE_TITLE_CASE: + nMode = TransliterationModulesExtra::TITLE_CASE; + break; + case SID_TRANSLITERATE_TOGGLE_CASE: + nMode = TransliterationModulesExtra::TOGGLE_CASE; + break; case SID_TRANSLITERATE_UPPER: nMode = TransliterationModules_LOWERCASE_UPPERCASE; break; diff --git a/sw/source/ui/shells/langhelper.cxx b/sw/source/ui/shells/langhelper.cxx index e32a959850..878d18fc42 100755..100644 --- a/sw/source/ui/shells/langhelper.cxx +++ b/sw/source/ui/shells/langhelper.cxx @@ -66,7 +66,8 @@ using namespace ::com::sun::star; namespace SwLangHelper { - USHORT GetLanguageStatus(OutlinerView* pOLV,SfxItemSet& rSet) + + USHORT GetLanguageStatus( OutlinerView* pOLV, SfxItemSet& rSet ) { ESelection aSelection = pOLV->GetSelection(); EditView& rEditView=pOLV->GetEditView(); @@ -110,7 +111,7 @@ namespace SwLangHelper return 0; } - bool SetLanguageStatus(OutlinerView* pOLV,SfxRequest &rReq,SwView &rView,SwWrtShell &rSh) + bool SetLanguageStatus( OutlinerView* pOLV, SfxRequest &rReq, SwView &rView, SwWrtShell &rSh ) { bool bRestoreSelection = false; SfxItemSet aEditAttr(pOLV->GetAttribs()); @@ -130,126 +131,132 @@ namespace SwLangHelper //!! SwTextShell got destroyed meanwhile.) SfxViewFrame *pViewFrame = rView.GetViewFrame(); - if (aNewLangTxt.EqualsAscii( "*" )) - { - // open the dialog "Tools/Options/Language Settings - Language" - SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); - if (pFact) - { - VclAbstractDialog* pDlg = pFact->CreateVclDialog( rView.GetWindow(), SID_LANGUAGE_OPTIONS ); - pDlg->Execute(); - delete pDlg; - } + if (aNewLangTxt.EqualsAscii( "*" )) + { + // open the dialog "Tools/Options/Language Settings - Language" + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + if (pFact) + { + VclAbstractDialog* pDlg = pFact->CreateVclDialog( rView.GetWindow(), SID_LANGUAGE_OPTIONS ); + pDlg->Execute(); + delete pDlg; } - else + } + else + { + // setting the new language... + if (aNewLangTxt.Len() > 0) { - // setting the new language... - if (aNewLangTxt.Len() > 0) + const String aSelectionLangPrefix( String::CreateFromAscii("Current_") ); + const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") ); + const String aDocumentLangPrefix( String::CreateFromAscii("Default_") ); + const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") ); + const String aStrResetLangs( String::CreateFromAscii("RESET_LANGUAGES") ); + + xub_StrLen nPos = 0; + bool bForSelection = true; + bool bForParagraph = false; + if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 ))) { - const String aSelectionLangPrefix( String::CreateFromAscii("Current_") ); - const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") ); - const String aDocumentLangPrefix( String::CreateFromAscii("Default_") ); - const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") ); - - xub_StrLen nPos = 0; - bool bForSelection = true; - bool bForParagraph = false; - if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aSelectionLangPrefix, 0 ))) - { - // ... for the current selection - aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.Len() ); - bForSelection = true; - } - else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 ))) - { - // ... for the current paragraph language - aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.Len() ); - bForSelection = true; - bForParagraph = true; - } - else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 ))) - { - // ... as default document language - aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.Len() ); - bForSelection = false; - } + // ... for the current selection + aNewLangTxt = aNewLangTxt.Erase( nPos, aSelectionLangPrefix.Len() ); + bForSelection = true; + } + else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aParagraphLangPrefix , 0 ))) + { + // ... for the current paragraph language + aNewLangTxt = aNewLangTxt.Erase( nPos, aParagraphLangPrefix.Len() ); + bForSelection = true; + bForParagraph = true; + } + else if (STRING_NOTFOUND != (nPos = aNewLangTxt.Search( aDocumentLangPrefix , 0 ))) + { + // ... as default document language + aNewLangTxt = aNewLangTxt.Erase( nPos, aDocumentLangPrefix.Len() ); + bForSelection = false; + } - if (bForParagraph) - { - bRestoreSelection = true; - SwLangHelper::SelectPara( rEditView, aSelection ); - aSelection = pOLV->GetSelection(); - } - if (!bForSelection) // document language to be changed... - { - rSh.StartAction(); - rSh.LockView( TRUE ); - rSh.Push(); - - // prepare to apply new language to all text in document - rSh.SelAll(); - rSh.ExtendedSelectAll(); - } + if (bForParagraph) + { + bRestoreSelection = true; + SwLangHelper::SelectPara( rEditView, aSelection ); + aSelection = pOLV->GetSelection(); + } + if (!bForSelection) // document language to be changed... + { + rSh.StartAction(); + rSh.LockView( TRUE ); + rSh.Push(); - if (aNewLangTxt != aStrNone) - SwLangHelper::SetLanguage( rSh, pEditEngine, aSelection, aNewLangTxt, bForSelection, aEditAttr ); + // prepare to apply new language to all text in document + rSh.SelAll(); + rSh.ExtendedSelectAll(); + } + + if (aNewLangTxt == aStrNone) + SwLangHelper::SetLanguage_None( rSh, pOLV, aSelection, bForSelection, aEditAttr ); + else if (aNewLangTxt == aStrResetLangs) + SwLangHelper::ResetLanguages( rSh, pOLV, aSelection, bForSelection ); + else + SwLangHelper::SetLanguage( rSh, pOLV, aSelection, aNewLangTxt, bForSelection, aEditAttr ); + + // ugly hack, as it seems that EditView/EditEngine does not update their spellchecking marks + // when setting a new language attribute + if (bForSelection) + { + const SwViewOption* pVOpt = rView.GetWrtShellPtr()->GetViewOptions(); + ULONG nCntrl = pEditEngine->GetControlWord(); + // turn off + if (!pVOpt->IsOnlineSpell()) + nCntrl &= ~EE_CNTRL_ONLINESPELLING; else - SwLangHelper::SetLanguage_None( rSh, pEditEngine, aSelection, bForSelection, aEditAttr ); - - // ugly hack, as it seems that EditView/EditEngine does not update their spellchecking marks - // when setting a new language attribute - if (bForSelection) - { - const SwViewOption* pVOpt = rView.GetWrtShellPtr()->GetViewOptions(); - ULONG nCntrl = pEditEngine->GetControlWord(); - // turn off - if (!pVOpt->IsOnlineSpell()) - nCntrl &= ~EE_CNTRL_ONLINESPELLING; - else - nCntrl &= ~EE_CNTRL_ONLINESPELLING; - pEditEngine->SetControlWord(nCntrl); - - //turn back on - if (pVOpt->IsOnlineSpell()) - nCntrl |= EE_CNTRL_ONLINESPELLING; - else - nCntrl &= ~EE_CNTRL_ONLINESPELLING; - pEditEngine->SetControlWord(nCntrl); - - pEditEngine->CompleteOnlineSpelling(); - rEditView.Invalidate(); - } + nCntrl &= ~EE_CNTRL_ONLINESPELLING; + pEditEngine->SetControlWord(nCntrl); - if (!bForSelection) - { - // need to release view and restore selection... - rSh.Pop( FALSE ); - rSh.LockView( FALSE ); - rSh.EndAction(); - } + //turn back on + if (pVOpt->IsOnlineSpell()) + nCntrl |= EE_CNTRL_ONLINESPELLING; + else + nCntrl &= ~EE_CNTRL_ONLINESPELLING; + pEditEngine->SetControlWord(nCntrl); + + pEditEngine->CompleteOnlineSpelling(); + rEditView.Invalidate(); + } + + if (!bForSelection) + { + // need to release view and restore selection... + rSh.Pop( FALSE ); + rSh.LockView( FALSE ); + rSh.EndAction(); } } - - // invalidate slot to get the new language displayed - pViewFrame->GetBindings().Invalidate( rReq.GetSlot() ); - - rReq.Done(); - return bRestoreSelection; + } + + // invalidate slot to get the new language displayed + pViewFrame->GetBindings().Invalidate( rReq.GetSlot() ); + + rReq.Done(); + return bRestoreSelection; } - void SetLanguage(SwWrtShell &rWrtSh, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet) + void SetLanguage( SwWrtShell &rWrtSh, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet ) { - SetLanguage(rWrtSh,0,ESelection(),rLangText,bIsForSelection,rCoreSet); + SetLanguage( rWrtSh, 0 , ESelection(), rLangText, bIsForSelection, rCoreSet ); } - void SetLanguage(SwWrtShell &rWrtSh, EditEngine* pEditEngine,ESelection aSelection, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet) + void SetLanguage( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, const String &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet ) { const LanguageType nLang = SvtLanguageTable().GetType( rLangText ); if (nLang != LANGUAGE_DONTKNOW) { USHORT nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ); + EditEngine* pEditEngine = pOLV ? pOLV->GetEditView().GetEditEngine() : NULL; + DBG_ASSERT( !pOLV || pEditEngine, "OutlinerView without EditEngine???" ); + //get ScriptType USHORT nLangWhichId = 0; bool bIsSingleScriptType = true; @@ -264,6 +271,9 @@ namespace SwLangHelper } if (bIsSingleScriptType) { + // change language for selection or paragraph + // (for paragraph is handled by previosuly having set the selection to the + // whole paragraph) if (bIsForSelection) { // apply language to current selection @@ -279,7 +289,7 @@ namespace SwLangHelper rWrtSh.SetAttr( rCoreSet ); } } - else // change document language + else // change language for all text { // set document default language switch (nLangWhichId) @@ -300,12 +310,12 @@ namespace SwLangHelper } } - void SetLanguage_None(SwWrtShell &rWrtSh,bool bIsForSelection, SfxItemSet &rCoreSet ) + void SetLanguage_None( SwWrtShell &rWrtSh, bool bIsForSelection, SfxItemSet &rCoreSet ) { - SetLanguage_None(rWrtSh,0,ESelection(),bIsForSelection,rCoreSet); + SetLanguage_None( rWrtSh,0,ESelection(),bIsForSelection,rCoreSet ); } - void SetLanguage_None(SwWrtShell &rWrtSh, EditEngine* pEditEngine,ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet ) + void SetLanguage_None( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection, SfxItemSet &rCoreSet ) { // EditEngine IDs const USHORT aLangWhichId_EE[3] = @@ -322,10 +332,15 @@ namespace SwLangHelper RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE }; - + if (bIsForSelection) { - // apply language to current selection + // change language for selection or paragraph + // (for paragraph is handled by previosuly having set the selection to the + // whole paragraph) + + EditEngine* pEditEngine = pOLV ? pOLV->GetEditView().GetEditEngine() : NULL; + DBG_ASSERT( !pOLV || pEditEngine, "OutlinerView without EditEngine???" ); if (pEditEngine) { for (sal_uInt16 i = 0; i < 3; ++i) @@ -340,7 +355,7 @@ namespace SwLangHelper rWrtSh.SetAttr( rCoreSet ); } } - else // change document language + else // change language for all text { SvUShortsSort aAttribs; for (sal_uInt16 i = 0; i < 3; ++i) @@ -355,6 +370,39 @@ namespace SwLangHelper } } + void ResetLanguages( SwWrtShell &rWrtSh, bool bIsForSelection ) + { + ResetLanguages( rWrtSh, 0 , ESelection(), bIsForSelection ); + } + + void ResetLanguages( SwWrtShell &rWrtSh, OutlinerView* pOLV, ESelection aSelection, bool bIsForSelection ) + { + (void) bIsForSelection; + (void) aSelection; + + // reset language for current selection. + // The selection should already have been expanded to the whole paragraph or + // to all text in the document if those are the ranges where to reset + // the language attributes + + if (pOLV) + { + EditView &rEditView = pOLV->GetEditView(); + rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE ); + rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE_CJK ); + rEditView.RemoveAttribs( true, EE_CHAR_LANGUAGE_CTL ); + } + else + { + SvUShortsSort aAttribs; + aAttribs.Insert( RES_CHRATR_LANGUAGE ); + aAttribs.Insert( RES_CHRATR_CJK_LANGUAGE ); + aAttribs.Insert( RES_CHRATR_CTL_LANGUAGE ); + rWrtSh.ResetAttr( &aAttribs ); + } + } + + /// @returns : the language for the selected text that is set for the /// specified attribute (script type). /// If there are more than one languages used LANGUAGE_DONTKNOW will be returned. @@ -450,7 +498,7 @@ namespace SwLangHelper /// 'In use' means the language(s) matching the script type(s) of the /// selected text. Or in other words, the language a spell checker would use. /// If there is more than one language LANGUAGE_DONTKNOW will be returned. - LanguageType GetCurrentLanguage(SfxItemSet aSet,USHORT nScriptType ) + LanguageType GetCurrentLanguage( SfxItemSet aSet, USHORT nScriptType ) { //set language attribute to use according to the script type USHORT nLangWhichId = 0; @@ -517,7 +565,7 @@ namespace SwLangHelper return aText; } - String GetTextForLanguageGuessing(EditEngine* rEditEngine, ESelection aDocSelection ) + String GetTextForLanguageGuessing( EditEngine* rEditEngine, ESelection aDocSelection ) { // string for guessing language String aText; diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index 60c02e5f0b..e437de58d4 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -62,7 +62,8 @@ #include <svx/htmlmode.hxx> #include <svx/pfiledlg.hxx> #include <svtools/htmlcfg.hxx> -#include <com/sun/star/i18n/TransliterationModules.hdl> +#include <com/sun/star/i18n/TransliterationModules.hpp> +#include <com/sun/star/i18n/TransliterationModulesExtra.hpp> #include <sot/clsids.hxx> #include <editeng/acorrcfg.hxx> @@ -1027,6 +1028,15 @@ void SwTextShell::ExecTransliteration( SfxRequest & rReq ) switch( rReq.GetSlot() ) { + case SID_TRANSLITERATE_SENTENCE_CASE: + nMode = TransliterationModulesExtra::SENTENCE_CASE; + break; + case SID_TRANSLITERATE_TITLE_CASE: + nMode = TransliterationModulesExtra::TITLE_CASE; + break; + case SID_TRANSLITERATE_TOGGLE_CASE: + nMode = TransliterationModulesExtra::TOGGLE_CASE; + break; case SID_TRANSLITERATE_UPPER: nMode = TransliterationModules_LOWERCASE_UPPERCASE; break; diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx index 195f8228f9..8a02ce6395 100644 --- a/sw/source/ui/shells/textsh1.cxx +++ b/sw/source/ui/shells/textsh1.cxx @@ -27,7 +27,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + +#include <com/sun/star/i18n/WordType.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> + #include <comphelper/processfactory.hxx> #include <svx/dialogs.hrc> #include <hintids.hxx> @@ -338,6 +341,7 @@ void SwTextShell::Execute(SfxRequest &rReq) const String aParagraphLangPrefix( String::CreateFromAscii("Paragraph_") ); const String aDocumentLangPrefix( String::CreateFromAscii("Default_") ); const String aStrNone( String::CreateFromAscii("LANGUAGE_NONE") ); + const String aStrResetLangs( String::CreateFromAscii("RESET_LANGUAGES") ); SfxItemSet aCoreSet( GetPool(), RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE, @@ -376,10 +380,12 @@ void SwTextShell::Execute(SfxRequest &rReq) rWrtSh.SelAll(); rWrtSh.ExtendedSelectAll(); } - if (aNewLangTxt != aStrNone) - SwLangHelper::SetLanguage( rWrtSh, aNewLangTxt, bForSelection, aCoreSet ); - else + if (aNewLangTxt == aStrNone) SwLangHelper::SetLanguage_None( rWrtSh, bForSelection, aCoreSet ); + else if (aNewLangTxt == aStrResetLangs) + SwLangHelper::ResetLanguages( rWrtSh, bForSelection ); + else + SwLangHelper::SetLanguage( rWrtSh, aNewLangTxt, bForSelection, aCoreSet ); } // restore selection... @@ -396,6 +402,23 @@ void SwTextShell::Execute(SfxRequest &rReq) break; } + case SID_THES: + { + // replace word/selection with text from selected sub menu entry + String aReplaceText; + SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , sal_False ); + if (pItem2) + aReplaceText = pItem2->GetValue(); + if (aReplaceText.Len() > 0) + { + SwView &rView2 = rWrtSh.GetView(); + const bool bSelection = rWrtSh.HasSelection(); + const String aLookUpText = rView2.GetThesaurusLookUpText( bSelection ); + rView2.InsertThesaurusSynonym( aReplaceText, aLookUpText, bSelection ); + } + } + break; + case SID_CHARMAP: { InsertSymbol( rReq ); @@ -1375,6 +1398,38 @@ void SwTextShell::GetState( SfxItemSet &rSet ) } break; + case SID_THES: + { + // is there a valid selection to get text from? + String aText; + sal_Bool bValid = !rSh.HasSelection() || + (rSh.IsSelOnePara() && !rSh.IsMultiSelection()); + // prevent context menu from showing when cursor is not in or at the end of a word + // (GetCurWord will return the next word if there is none at the current position...) + const sal_Int16 nWordType = ::i18n::WordType::DICTIONARY_WORD; + bool bWord = rSh.IsInWord( nWordType ) || rSh.IsStartWord( nWordType ) || rSh.IsEndWord( nWordType ); + if (bValid && bWord) + aText = rSh.HasSelection()? rSh.GetSelTxt() : rSh.GetCurWord(); + + LanguageType nLang = rSh.GetCurLang(); + lang::Locale aLocale = SvxCreateLocale( nLang ); + String aLangText( MsLangId::convertLanguageToIsoString( nLang ) ); + + // set word and locale to look up as status value + String aStatusVal( aText ); + aStatusVal.AppendAscii( "#" ); + aStatusVal += aLangText; + + rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); + + // disable "Thesaurus" context menu entry if there is nothing to look up + uno::Reference< linguistic2::XThesaurus > xThes( ::GetThesaurus() ); + if (aText.Len() == 0 || + !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale )) + rSet.DisableItem( SID_THES ); + } + break; + case FN_NUMBER_NEWSTART : if(!rSh.GetCurNumRule()) rSet.DisableItem(nWhich); diff --git a/sw/source/ui/shells/txtcrsr.cxx b/sw/source/ui/shells/txtcrsr.cxx index 08d5f1be56..cf0a5f99ac 100644 --- a/sw/source/ui/shells/txtcrsr.cxx +++ b/sw/source/ui/shells/txtcrsr.cxx @@ -47,6 +47,8 @@ #include <num.hxx> #include <edtwin.hxx> #include <crsskip.hxx> +#include <doc.hxx> +#include <docsh.hxx> #ifndef _CMDID_H #include <cmdid.h> @@ -56,6 +58,10 @@ #include <globals.hrc> #endif +#include <svx/svdouno.hxx> +#include <svx/fmshell.hxx> +#include <svx/sdrobjectfilter.hxx> + using namespace ::com::sun::star; void SwTextShell::ExecBasicMove(SfxRequest &rReq) @@ -246,6 +252,36 @@ void SwTextShell::ExecMoveMisc(SfxRequest &rReq) BOOL bSetRetVal = TRUE, bRet = TRUE; switch ( nSlot ) { + case SID_FM_TOGGLECONTROLFOCUS: + { + const SwDoc* pDoc = rSh.GetDoc(); + const SwDocShell* pDocShell = pDoc ? pDoc->GetDocShell() : NULL; + const SwView* pView = pDocShell ? pDocShell->GetView() : NULL; + const FmFormShell* pFormShell = pView ? pView->GetFormShell() : NULL; + SdrView* pDrawView = pView ? pView->GetDrawView() : NULL; + Window* pWindow = pView ? pView->GetWrtShell().GetWin() : NULL; + + OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::ExecMoveMisc: no chance!" ); + if ( !pFormShell || !pDrawView || !pWindow ) + break; + + ::std::auto_ptr< ::svx::ISdrObjectFilter > pFilter( pFormShell->CreateFocusableControlFilter( + *pDrawView, *pWindow ) ); + if ( !pFilter.get() ) + break; + + const SdrObject* pNearestControl = rSh.GetBestObject( TRUE, GOTOOBJ_DRAW_CONTROL, FALSE, pFilter.get() ); + if ( !pNearestControl ) + break; + + const SdrUnoObj* pUnoObject = dynamic_cast< const SdrUnoObj* >( pNearestControl ); + OSL_ENSURE( pUnoObject, "SwTextShell::ExecMoveMisc: GetBestObject returned nonsense!" ); + if ( !pUnoObject ) + break; + + pFormShell->ToggleControlFocus( *pUnoObject, *pDrawView, *pWindow ); + } + break; case FN_CNTNT_TO_NEXT_FRAME: bRet = rSh.GotoObj(TRUE, GOTOOBJ_GOTO_ANY); if(bRet) diff --git a/sw/source/ui/uiview/view.src b/sw/source/ui/uiview/view.src index 0667bf5c35..233664b509 100644 --- a/sw/source/ui/uiview/view.src +++ b/sw/source/ui/uiview/view.src @@ -299,8 +299,8 @@ ToolBox RID_TOOLS_TOOLBOX }; ToolBoxItem { - Identifier = FN_THESAURUS_DLG; - HelpID = FN_THESAURUS_DLG; + Identifier = SID_THESAURUS; + HelpID = SID_THESAURUS; Hide = TRUE; }; ToolBoxItem diff --git a/sw/source/ui/uiview/view0.cxx b/sw/source/ui/uiview/view0.cxx index 568fab8cd6..f3e1253572 100644 --- a/sw/source/ui/uiview/view0.cxx +++ b/sw/source/ui/uiview/view0.cxx @@ -117,6 +117,7 @@ SFX_IMPL_VIEWFACTORY(SwView, SW_RES(STR_NONAME)) SFX_IMPL_INTERFACE( SwView, SfxViewShell, SW_RES(RID_TOOLS_TOOLBOX) ) { SFX_CHILDWINDOW_CONTEXT_REGISTRATION(SID_NAVIGATOR); + SFX_CHILDWINDOW_REGISTRATION(SID_TASKPANE); SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId()); SFX_CHILDWINDOW_REGISTRATION(SvxSearchDialogWrapper::GetChildWindowId()); SFX_CHILDWINDOW_REGISTRATION(SwSpellDialogChildWindow::GetChildWindowId()); diff --git a/sw/source/ui/uiview/viewdraw.cxx b/sw/source/ui/uiview/viewdraw.cxx index f35e5570f1..49889a3daf 100644 --- a/sw/source/ui/uiview/viewdraw.cxx +++ b/sw/source/ui/uiview/viewdraw.cxx @@ -520,7 +520,8 @@ sal_Bool SwView::EnterDrawTextMode(const Point& aDocPos) /****************************************************************************** * Beschreibung: DrawTextEditMode einschalten ******************************************************************************/ -sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin, sal_Bool bIsNewObj) +sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin, + bool bIsNewObj, bool bSetSelectionToStart) { SwWrtShell *pSh = &GetWrtShell(); SdrView *pSdrView = pSh->GetDrawView(); @@ -606,7 +607,11 @@ sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin, Color aBackground(pSh->GetShapeBackgrd()); pView->SetBackgroundColor(aBackground); } + + // editing should start at the end of text, spell checking at the beginning ... ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND); + if (bSetSelectionToStart) + aNewSelection = ESelection(); pView->SetSelection(aNewSelection); } diff --git a/sw/source/ui/uiview/viewling.cxx b/sw/source/ui/uiview/viewling.cxx index 5ccb5f8093..25daf5609a 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 ); - } /*-------------------------------------------------------------------- diff --git a/sw/source/ui/uiview/viewstat.cxx b/sw/source/ui/uiview/viewstat.cxx index 4022042cf9..ff452ef209 100644 --- a/sw/source/ui/uiview/viewstat.cxx +++ b/sw/source/ui/uiview/viewstat.cxx @@ -303,7 +303,7 @@ void SwView::GetState(SfxItemSet &rSet) rSet.DisableItem( nWhich ); } break; - case FN_THESAURUS_DLG: + case SID_THESAURUS: { SwWrtShell &rSh = GetWrtShell(); if (2 <= rSh.GetCrsrCnt()) // multi selection? diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index e3f1322bed..e3f1322bed 100755..100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index 84b6e86e70..8ba286f926 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -710,7 +710,7 @@ uno::Reference< form::runtime::XFormController > SAL_CALL SwXTextView::getFormCo FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL; SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL; Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL; - DBG_ASSERT( pFormShell && pDrawView && pWindow, "SwXTextView::GetControl: how could I?" ); + DBG_ASSERT( pFormShell && pDrawView && pWindow, "SwXTextView::getFormController: how could I?" ); uno::Reference< form::runtime::XFormController > xController; if ( pFormShell && pDrawView && pWindow ) diff --git a/sw/source/ui/web/web.src b/sw/source/ui/web/web.src index 8485ae0e80..08b6707962 100644 --- a/sw/source/ui/web/web.src +++ b/sw/source/ui/web/web.src @@ -138,8 +138,8 @@ ToolBox RID_WEBTOOLS_TOOLBOX }; ToolBoxItem { - Identifier = FN_THESAURUS_DLG; - HelpID = FN_THESAURUS_DLG; + Identifier = SID_THESAURUS; + HelpID = SID_THESAURUS; Hide = TRUE; }; ToolBoxItem diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index cf7aa90faa..b3087f78fb 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -1387,7 +1387,20 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) // <-- if ( ( nTxtNodeIndent + nWidthOfTabs ) != 0 ) { - const SwTwips nIndentChange = nTxtNodeIndent + nWidthOfTabs; + // --> OD 2010-05-05 #i111172# + // If text node is already inside a list, assure that the indents + // are the same. Thus, adjust the indent change value by subtracting + // indents of to be applied list style. + SwTwips nIndentChange = nTxtNodeIndent + nWidthOfTabs; + if ( pTxtNode->GetNumRule() ) + { + const SwNumFmt aFmt( aNumRule.Get( 0 ) ); + if ( aFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) + { + nIndentChange -= aFmt.GetIndentAt() + aFmt.GetFirstLineIndent(); + } + } + // <-- aNumRule.ChangeIndent( nIndentChange ); } } |