diff options
Diffstat (limited to 'sw/source/ui')
28 files changed, 378 insertions, 362 deletions
diff --git a/sw/source/ui/app/appopt.cxx b/sw/source/ui/app/appopt.cxx index e500fcc63449..5f2285a2bce9 100644 --- a/sw/source/ui/app/appopt.cxx +++ b/sw/source/ui/app/appopt.cxx @@ -91,8 +91,6 @@ #include <globals.hrc> #endif #include <globals.h> // globale Konstanten z.B. -// #107253# -#include <swlinguconfig.hxx> #include <svtools/slstitm.hxx> #include "swabstdlg.hxx" #include <swwrtshitem.hxx> @@ -192,8 +190,7 @@ SfxItemSet* SwModule::CreateItemSet( USHORT nId ) pPrt = new SfxPrinter(pSet); pRet->Put(SwPtrItem(FN_PARAM_PRINTER, pPrt));*/ - // #107253# Replaced SvtLinguConfig with SwLinguConfig wrapper with UsageCount - SwLinguConfig aLinguCfg; + SvtLinguConfig aLinguCfg; Any aLang = aLinguCfg.GetProperty(C2U("DefaultLocale")); Locale aLocale; diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 781d60332376..dd163a3216eb 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -1201,7 +1201,6 @@ void SwDocShell::Execute(SfxRequest& rReq) SID_HTML_MODE, SID_RULER_PROTECT, SID_AUTOSPELL_CHECK, - SID_AUTOSPELL_MARKOFF, FN_RULER, /*20211*/ FN_VIEW_GRAPHIC, /*20213*/ FN_VIEW_BOUNDS, /**/ diff --git a/sw/source/ui/app/docshini.cxx b/sw/source/ui/app/docshini.cxx index 5ccbe67a58c7..900a1f7fd060 100644 --- a/sw/source/ui/app/docshini.cxx +++ b/sw/source/ui/app/docshini.cxx @@ -116,8 +116,6 @@ #include <globals.hrc> #endif -// #107253# -#include <swlinguconfig.hxx> // #i18732# #include <fmtfollowtextflow.hxx> @@ -791,8 +789,7 @@ void SwDocShell::SubInitNew() //! get lingu options without loading lingu DLL SvtLinguOptions aLinguOpt; - // #107253# Replaced SvtLinguConfig with SwLinguConfig wrapper with UsageCount - SwLinguConfig().GetOptions( aLinguOpt ); + SvtLinguConfig().GetOptions( aLinguOpt ); sal_Int16 nVal = aLinguOpt.nDefaultLanguage, eCJK = aLinguOpt.nDefaultLanguage_CJK, diff --git a/sw/source/ui/config/fontcfg.cxx b/sw/source/ui/config/fontcfg.cxx index c096d148f2c3..14793b511c6f 100644 --- a/sw/source/ui/config/fontcfg.cxx +++ b/sw/source/ui/config/fontcfg.cxx @@ -39,9 +39,6 @@ #include <com/sun/star/uno/Sequence.hxx> #include <swtypes.hxx> -// #107253# -#include <swlinguconfig.hxx> - #include <unomid.h> using namespace utl; @@ -117,8 +114,7 @@ SwStdFontConfig::SwStdFontConfig() : { SvtLinguOptions aLinguOpt; - // #107253# Replaced SvtLinguConfig with SwLinguConfig wrapper with UsageCount - SwLinguConfig().GetOptions( aLinguOpt ); + SvtLinguConfig().GetOptions( aLinguOpt ); sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, eCJK = aLinguOpt.nDefaultLanguage_CJK, @@ -165,8 +161,7 @@ void SwStdFontConfig::Commit() Any* pValues = aValues.getArray(); SvtLinguOptions aLinguOpt; - // #107253# Replaced SvtLinguConfig with SwLinguConfig wrapper with UsageCount - SwLinguConfig().GetOptions( aLinguOpt ); + SvtLinguConfig().GetOptions( aLinguOpt ); sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, eCJK = aLinguOpt.nDefaultLanguage_CJK, @@ -201,8 +196,7 @@ BOOL SwStdFontConfig::IsFontDefault(USHORT nFontType) const BOOL bSame = sal_False; SvtLinguOptions aLinguOpt; - // #107253# Replaced SvtLinguConfig with SwLinguConfig wrapper with UsageCount - SwLinguConfig().GetOptions( aLinguOpt ); + SvtLinguConfig().GetOptions( aLinguOpt ); sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, eCJK = aLinguOpt.nDefaultLanguage_CJK, @@ -325,7 +319,7 @@ void SwStdFontConfig::ChangeInt( USHORT nFontType, sal_Int32 nHeight ) if( nFontType < DEF_FONT_COUNT && nDefaultFontHeight[nFontType] != nHeight) { SvtLinguOptions aLinguOpt; - SwLinguConfig().GetOptions( aLinguOpt ); + SvtLinguConfig().GetOptions( aLinguOpt ); sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, eCJK = aLinguOpt.nDefaultLanguage_CJK, eCTL = aLinguOpt.nDefaultLanguage_CTL; diff --git a/sw/source/ui/config/makefile.mk b/sw/source/ui/config/makefile.mk index 2a5d53fa97ba..02ed4d075995 100644 --- a/sw/source/ui/config/makefile.mk +++ b/sw/source/ui/config/makefile.mk @@ -69,8 +69,7 @@ SLOFILES = \ $(SLO)$/prtopt.obj \ $(SLO)$/uinums.obj \ $(SLO)$/usrpref.obj \ - $(SLO)$/viewopt.obj \ - $(SLO)$/swlinguconfig.obj + $(SLO)$/viewopt.obj LIB1TARGET= $(SLB)$/$(TARGET).lib @@ -84,8 +83,8 @@ LIB1OBJFILES = \ $(SLO)$/prtopt.obj \ $(SLO)$/uinums.obj \ $(SLO)$/usrpref.obj \ - $(SLO)$/viewopt.obj \ - $(SLO)$/swlinguconfig.obj + $(SLO)$/viewopt.obj + # --- Targets ------------------------------------------------------- .INCLUDE : target.mk diff --git a/sw/source/ui/config/swlinguconfig.cxx b/sw/source/ui/config/swlinguconfig.cxx deleted file mode 100644 index 3bac33fe16ad..000000000000 --- a/sw/source/ui/config/swlinguconfig.cxx +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: swlinguconfig.cxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sw.hxx" - -// #107253# -#include <swlinguconfig.hxx> -#include <svtools/lingucfg.hxx> - -using namespace ::com::sun::star; - -// init static member -static SvtLinguConfig* mpImplLinguConfig = 0L; -static sal_uInt32 mnImplUseCount = 0L; - -void ImplCreateOnDemand() -{ - if(!mpImplLinguConfig && mnImplUseCount) - { - mpImplLinguConfig = new SvtLinguConfig(); - } -} - -SwLinguConfig::SwLinguConfig() -{ - mnImplUseCount++; -} - -SwLinguConfig::~SwLinguConfig() -{ - mnImplUseCount--; - - if(!mnImplUseCount && mpImplLinguConfig) - { - delete mpImplLinguConfig; - mpImplLinguConfig = 0L; - } -} - -sal_Bool SwLinguConfig::SetProperty(const rtl::OUString &rPropertyName, const uno::Any &rValue) -{ - ImplCreateOnDemand(); - return mpImplLinguConfig->SetProperty(rPropertyName, rValue); -} - -sal_Bool SwLinguConfig::GetOptions(SvtLinguOptions &rOptions) const -{ - ImplCreateOnDemand(); - return mpImplLinguConfig->GetOptions(rOptions); -} - -uno::Any SwLinguConfig::GetProperty(const rtl::OUString &rPropertyName) const -{ - ImplCreateOnDemand(); - return mpImplLinguConfig->GetProperty(rPropertyName); -} - -// eof diff --git a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx index 4e1c60c67a1d..635abef2fb3b 100644 --- a/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx +++ b/sw/source/ui/dialog/SwSpellDialogChildWindow.cxx @@ -49,7 +49,6 @@ #include <svx/svdogrp.hxx> #include <svtools/linguprops.hxx> #include <svtools/lingucfg.hxx> -#include <swlinguconfig.hxx> #include <doc.hxx> #ifndef _DOCSH_HXX #include <docsh.hxx> @@ -180,7 +179,7 @@ SwSpellDialogChildWindow::SwSpellDialogChildWindow ( { String aPropName( String::CreateFromAscii(UPN_IS_GRAMMAR_INTERACTIVE ) ); - SwLinguConfig().GetProperty( aPropName ) >>= m_bIsGrammarCheckingOn; + SvtLinguConfig().GetProperty( aPropName ) >>= m_bIsGrammarCheckingOn; } /*-- 09.09.2003 10:39:22--------------------------------------------------- @@ -323,8 +322,8 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence (void) if(bOtherText && m_pSpellState->m_bStartedInOther && m_pSpellState->pOtherCursor) { m_pSpellState->m_bStartedInOther = false; - pWrtShell->SpellEnd(); pWrtShell->SetSelection(*m_pSpellState->pOtherCursor); + pWrtShell->SpellEnd(); delete m_pSpellState->pOtherCursor; m_pSpellState->pOtherCursor = 0; pWrtShell->SpellStart(DOCPOS_OTHERSTART, DOCPOS_CURR, DOCPOS_OTHERSTART, FALSE ); @@ -493,40 +492,33 @@ void SwSpellDialogChildWindow::SetGrammarChecking(bool bOn) aVal <<= bOn; m_bIsGrammarCheckingOn = bOn; String aPropName( C2S(UPN_IS_GRAMMAR_INTERACTIVE ) ); - SwLinguConfig().SetProperty( aPropName, aVal ); -} -/*-- 16.06.2008 12:00:03--------------------------------------------------- - - -----------------------------------------------------------------------*/ -bool SwSpellDialogChildWindow::HasAnyVendor() -{ -#if DEBUG - return true; -#else - return false; -#endif -} -/*-- 16.06.2008 12:00:09--------------------------------------------------- - - -----------------------------------------------------------------------*/ -String SwSpellDialogChildWindow::GetVendorForLanguage( LanguageType eLanguage ) -{ - String sRet; -#if DEBUG - if( eLanguage == LANGUAGE_GERMAN_SWISS ) - sRet = String::CreateFromAscii( "SwissGrammar" ); -#endif - (void) eLanguage; - return sRet; -} -/*-- 19.06.2008 15:55:33--------------------------------------------------- - - -----------------------------------------------------------------------*/ -Image SwSpellDialogChildWindow::GetVendorLogoForLanguage( LanguageType /*eLanguage*/ ) -{ - return Image(); + SvtLinguConfig().SetProperty( aPropName, aVal ); + // set current spell position to the start of the current sentence to + // continue with this sentence after grammar checking state has been changed + SwWrtShell* pWrtShell = GetWrtShell_Impl(); + if(pWrtShell) + { + ShellModes eSelMode = pWrtShell->GetView().GetShellMode(); + bool bDrawText = SHELL_MODE_DRAWTEXT == eSelMode; + bool bNormalText = + SHELL_MODE_TABLE_TEXT == eSelMode || + SHELL_MODE_LIST_TEXT == eSelMode || + SHELL_MODE_TABLE_LIST_TEXT == eSelMode || + SHELL_MODE_TEXT == eSelMode; + if( bNormalText ) + pWrtShell->PutSpellingToSentenceStart(); + else if( bDrawText ) + { + SdrView* pSdrView = pWrtShell->GetDrawView(); + SdrOutliner* pOutliner = pSdrView ? pSdrView->GetTextEditOutliner() : 0; + DBG_ASSERT(pOutliner, "No Outliner in SwSpellDialogChildWindow::SetGrammarChecking") + if(pOutliner) + { + pOutliner->PutSpellingToSentenceStart( pSdrView->GetTextEditOutlinerView()->GetEditView() ); + } + } + } } - /*-- 28.10.2003 08:41:09--------------------------------------------------- -----------------------------------------------------------------------*/ diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx index c119f367e02c..1e978dbdac4c 100644 --- a/sw/source/ui/dialog/ascfldlg.cxx +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -59,8 +59,6 @@ #include <ascfldlg.hrc> #endif -// #107253# -#include <swlinguconfig.hxx> using namespace ::com::sun::star; @@ -232,9 +230,7 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh, else { SvtLinguOptions aLinguOpt; - - // #107253# Replaced SvtLinguConfig with SwLinguConfig wrapper with UsageCount - SwLinguConfig().GetOptions( aLinguOpt ); + SvtLinguConfig().GetOptions( aLinguOpt ); switch(nAppScriptType) { case SCRIPTTYPE_ASIAN: diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index e205182620a4..d600a7e21ea0 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -4758,7 +4758,9 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) aEvent.ExecutePosition.X = aPixPos.X(); aEvent.ExecutePosition.Y = aPixPos.Y(); Menu* pMenu = 0; - if( GetView().TryContextMenuInterception( *pROPopup, pMenu, aEvent ) ) + ::rtl::OUString sMenuName = + ::rtl::OUString::createFromAscii( "private:resource/ReadonlyContextMenu"); + if( GetView().TryContextMenuInterception( *pROPopup, sMenuName, pMenu, aEvent ) ) { if ( pMenu ) { diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index 8d644e94a663..08cba6066892 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -757,10 +757,6 @@ void SwPostIt::InitControls() nCntrl |= EE_CNTRL_MARKFIELDS; else nCntrl &= ~EE_CNTRL_MARKFIELDS; - if (pVOpt->IsHideSpell()) - nCntrl |= EE_CNTRL_NOREDLINES; - else - nCntrl &= ~EE_CNTRL_NOREDLINES; if (pVOpt->IsOnlineSpell()) nCntrl |= EE_CNTRL_ONLINESPELLING; else @@ -1435,10 +1431,6 @@ void SwPostIt::SetSpellChecking() { const SwViewOption* pVOpt = mpView->GetWrtShellPtr()->GetViewOptions(); ULONG nCntrl = mpOutliner->GetControlWord(); - if (pVOpt->IsHideSpell()) - nCntrl |= EE_CNTRL_NOREDLINES; - else - nCntrl &= ~EE_CNTRL_NOREDLINES; if (pVOpt->IsOnlineSpell()) nCntrl |= EE_CNTRL_ONLINESPELLING; else diff --git a/sw/source/ui/inc/SwSpellDialogChildWindow.hxx b/sw/source/ui/inc/SwSpellDialogChildWindow.hxx index ec595030237b..ae79a41343fe 100644 --- a/sw/source/ui/inc/SwSpellDialogChildWindow.hxx +++ b/sw/source/ui/inc/SwSpellDialogChildWindow.hxx @@ -58,9 +58,6 @@ protected: virtual bool HasGrammarChecking(); virtual bool IsGrammarChecking(); virtual void SetGrammarChecking(bool bOn); - virtual bool HasAnyVendor(); - virtual String GetVendorForLanguage( LanguageType eLanguage ); - virtual Image GetVendorLogoForLanguage( LanguageType eLanguage ); virtual void GetFocus(); virtual void LoseFocus(); diff --git a/sw/source/ui/inc/olmenu.hxx b/sw/source/ui/inc/olmenu.hxx index fdfa9ab6308c..0985c3bdc4da 100644 --- a/sw/source/ui/inc/olmenu.hxx +++ b/sw/source/ui/inc/olmenu.hxx @@ -32,10 +32,11 @@ #include <com/sun/star/linguistic2/XDictionary.hpp> #include <com/sun/star/linguistic2/XSpellAlternatives.hpp> -#include <com/sun/star/linguistic2/GrammarCheckingResult.hpp> +#include <com/sun/star/linguistic2/ProofreadingResult.hpp> #include <com/sun/star/uno/Sequence.h> #include <rtl/ustring.hxx> +#include <vcl/image.hxx> #include <vcl/menu.hxx> #include <map> @@ -67,6 +68,8 @@ class SwSpellPopup : public PopupMenu 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); using PopupMenu::Execute; @@ -78,7 +81,7 @@ public: const String & rParaText ); SwSpellPopup( SwWrtShell *pWrtSh, - const ::com::sun::star::linguistic2::GrammarCheckingResult &rResult, + const ::com::sun::star::linguistic2::ProofreadingResult &rResult, sal_Int32 nErrorInResult, const ::com::sun::star::uno::Sequence< rtl::OUString > &rSuggestions, const String & rParaText ); diff --git a/sw/source/ui/inc/swlinguconfig.hxx b/sw/source/ui/inc/swlinguconfig.hxx deleted file mode 100644 index 5987779c0459..000000000000 --- a/sw/source/ui/inc/swlinguconfig.hxx +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: swlinguconfig.hxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SWLINGUCONFIG_HXX -#define _SWLINGUCONFIG_HXX -#include <com/sun/star/uno/Any.h> -#include <rtl/ustring.hxx> -#include "swdllapi.h" - -// predeclarations -struct SvtLinguOptions; - -// #107253# -class SW_DLLPUBLIC SwLinguConfig -{ -public: - SwLinguConfig(); - ~SwLinguConfig(); - - sal_Bool SetProperty(const rtl::OUString &rPropertyName, const com::sun::star::uno::Any &rValue); - sal_Bool GetOptions(SvtLinguOptions &rOptions) const; - com::sun::star::uno::Any GetProperty(const rtl::OUString &rPropertyName) const; -}; - -#endif // _SWLINGUCONFIG_HXX diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx index 5bc9a657b6ae..5c91287a84e1 100644 --- a/sw/source/ui/lingu/olmenu.cxx +++ b/sw/source/ui/lingu/olmenu.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <hintids.hxx> #ifndef _SVSTDARR_HXX @@ -40,30 +39,34 @@ #endif #include <svtools/lingucfg.hxx> #include <svtools/linguprops.hxx> -#include <sfx2/dispatch.hxx> +#include <svtools/filter.hxx> +#include <svx/impgrf.hxx> #include <svx/svxacorr.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/imagemgr.hxx> +#include <osl/file.hxx> +#include <rtl/string.hxx> #include <i18npool/mslangid.hxx> #include <linguistic/lngprops.hxx> -#ifndef _LINGUISTIC_MISC_HHX_ #include <linguistic/misc.hxx> -#endif #include <comphelper/processfactory.hxx> #include <svx/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/SingleGrammarError.hpp> +#include <com/sun/star/linguistic2/SingleProofreadingError.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <svx/dlgutil.hxx> #include <svtools/itemset.hxx> #include <svx/langitem.hxx> #include <svx/splwrap.hxx> #include <vcl/svapp.hxx> +#include <vcl/settings.hxx> #include <svtools/lingucfg.hxx> #include <svx/acorrcfg.hxx> #include <swmodule.hxx> -#include <swlinguconfig.hxx> #include <cmdid.h> #include <helpid.h> #include <swtypes.hxx> @@ -339,6 +342,25 @@ USHORT SwSpellPopup::fillLangPopupMenu( } +static Image lcl_GetImageFromPngUrl( const OUString &rFileUrl ) +{ + Image aRes; + OUString aTmp; + osl::FileBase::getSystemPathFromFileURL( rFileUrl, aTmp ); +// ::rtl::OString aPath = OString( aTmp.getStr(), aTmp.getLength(), osl_getThreadTextEncoding() ); +#if defined(WNT) +// aTmp = lcl_Win_GetShortPathName( aTmp ); +#endif + Graphic aGraphic; + const String aFilterName( RTL_CONSTASCII_USTRINGPARAM( IMP_PNG ) ); + if( GRFILTER_OK == LoadGraphic( aTmp, aFilterName, aGraphic ) ) + { + aRes = Image( aGraphic.GetBitmapEx() ); + } + return aRes; +} + + SwSpellPopup::SwSpellPopup( SwWrtShell* pWrtSh, const uno::Reference< linguistic2::XSpellAlternatives > &xAlt, @@ -359,11 +381,23 @@ bGrammarResults(false) } sal_Int16 nStringCount = static_cast< sal_Int16 >( aSuggestions.getLength() ); + SvtLinguConfig aCfg; + const bool bIsDark = Application::GetSettings().GetStyleSettings().GetWindowColor().IsDark(); + PopupMenu *pMenu = GetPopupMenu(MN_AUTOCORR); pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); sal_Bool bEnable = sal_False; if( nStringCount ) { + Image aImage; + OUString aSuggestionImageUrl; + uno::Reference< container::XNamed > xNamed( xSpellAlt, uno::UNO_QUERY ); + if (xNamed.is()) + { + aSuggestionImageUrl = aCfg.GetSpellAndGrammarContextSuggestionImage( xNamed->getName(), bIsDark ); + aImage = Image( lcl_GetImageFromPngUrl( aSuggestionImageUrl ) ); + } + InsertSeparator(0); bEnable = sal_True; for( sal_uInt16 i = 0, nPos = 1, nId = MN_AUTOCORR_START + 1; @@ -372,10 +406,29 @@ bGrammarResults(false) const String aEntry = aSuggestions[ i ]; InsertItem( nPos, aEntry, 0, i ); SetHelpId( nPos, HID_LINGU_REPLACE); + + if (aSuggestionImageUrl.getLength() > 0) + SetItemImage( nPos, aImage ); + pMenu->InsertItem( nId, aEntry ); - pMenu->SetHelpId( nId, HID_LINGU_AUTOCORR); + pMenu->SetHelpId( nPos, HID_LINGU_AUTOCORR); } } + + //!! hard wired translations to be removed or added to src file in OOo 3.1 (#i94216) !! + OUString aIgnoreSelection( C2U("Ignore") ); + OUString aSpellingAndGrammar( C2U("Spelling and Grammar...") ); + const lang::Locale aUILocale( Application::GetSettings().GetUILocale() ); + if (aUILocale.Language.equalsAscii("de")) + { + aIgnoreSelection = C2U("Ignorieren"); + aSpellingAndGrammar = C2U("Rechtschreibung und Grammatik..."); + } + SetItemText( MN_SPELLING, aSpellingAndGrammar ); + USHORT nItemPos = GetItemPos( MN_IGNORE ); + InsertItem( MN_IGNORE_SELECTION, aIgnoreSelection, 0, nItemPos ); + SetHelpId( MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION); + EnableItem( MN_AUTOCORR, bEnable ); uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser(); @@ -403,10 +456,10 @@ bGrammarResults(false) uno::Reference< linguistic2::XDictionaryList > xDicList( SvxGetDictionaryList() ); if (xDicList.is()) { - // add active, positive dictionary to dic-list (if not already done). - // This is to ensure that there is at least on dictionary to which + // add the default positive dictionary to dic-list (if not already done). + // This is to ensure that there is at least one dictionary to which // words could be added. - uno::Reference< linguistic2::XDictionary1 > xDic( SvxGetOrCreatePosDic( xDicList ) ); + uno::Reference< linguistic2::XDictionary > xDic( SvxGetOrCreatePosDic( xDicList ) ); if (xDic.is()) xDic->setActive( sal_True ); @@ -416,12 +469,12 @@ bGrammarResults(false) for( USHORT i = 0; i < nDicCount; i++ ) { - uno::Reference< linguistic2::XDictionary1 > xDicTmp( pDic[i], uno::UNO_QUERY ); + uno::Reference< linguistic2::XDictionary > xDicTmp( pDic[i], uno::UNO_QUERY ); if (!xDicTmp.is() || SvxGetIgnoreAllList() == xDicTmp) continue; uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY ); - LanguageType nActLanguage = xDicTmp->getLanguage(); + LanguageType nActLanguage = SvxLocaleToLanguage( xDicTmp->getLocale() ); if( xDicTmp->isActive() && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE && (nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage ) @@ -429,8 +482,21 @@ bGrammarResults(false) { // the extra 1 is because of the (possible) external // linguistic entry above - pMenu->InsertItem( MN_INSERT_START + i + 1, xDicTmp->getName() ); + USHORT nPos = MN_INSERT_START + i + 1; + pMenu->InsertItem( nPos, xDicTmp->getName() ); bEnable = sal_True; + + uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY ); + if (xSvcInfo.is()) + { + OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage( + xSvcInfo->getImplementationName(), bIsDark) ); + if (aDictionaryImageUrl.getLength() > 0) + { + Image aImage( lcl_GetImageFromPngUrl( aDictionaryImageUrl ) ); + pMenu->SetItemImage( nPos, aImage ); + } + } } } } @@ -475,6 +541,11 @@ bGrammarResults(false) nNumLanguageDocEntries = fillLangPopupMenu( pMenu, MN_LANGUAGE_ALL_TEXT_START, aSeq, pWrtSh, 2 ); EnableItem( MN_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, + Application::GetSettings().GetStyleSettings().GetWindowColor().IsDark() ); + SetItemImage( MN_SPELLING, rImg ); ////////////////////////////////////////////////////////////////////////////////// RemoveDisabledEntries( TRUE, TRUE ); @@ -487,22 +558,25 @@ bGrammarResults(false) SwSpellPopup::SwSpellPopup( SwWrtShell *pWrtSh, - const linguistic2::GrammarCheckingResult &rResult, + const linguistic2::ProofreadingResult &rResult, sal_Int32 nErrorInResult, const uno::Sequence< rtl::OUString > &rSuggestions, const String &rParaText ) : PopupMenu( SW_RES(MN_SPELL_POPUP) ), pSh( pWrtSh ), aSuggestions( rSuggestions ), -bGrammarResults( true ) +bGrammarResults( true ), +aInfo16( SW_RES(IMG_INFO_16) ) { nCheckedLanguage = SvxLocaleToLanguage( rResult.aLocale ); sal_Int16 nItemId = 1; sal_Int16 nPos = 0; - OUString aMessageText( rResult.aGrammarErrors[ nErrorInResult ].aShortComment ); + OUString aMessageText( rResult.aErrors[ nErrorInResult ].aShortComment ); InsertSeparator( nPos++ ); - InsertItem( nItemId++, aMessageText, MIB_NOSELECT, nPos++ ); + InsertItem( nItemId, aMessageText, MIB_NOSELECT, nPos++ ); + SetItemImage( nItemId, aInfo16 ); + ++nItemId; CreateAutoMnemonics(); @@ -510,15 +584,43 @@ bGrammarResults( true ) sal_Int32 nStringCount = aSuggestions.getLength(); if ( nStringCount ) // suggestions available... { + Image aImage; + OUString aSuggestionImageUrl; + uno::Reference< lang::XServiceInfo > xInfo( rResult.xProofreader, uno::UNO_QUERY ); + if (xInfo.is()) + { + aSuggestionImageUrl = SvtLinguConfig().GetSpellAndGrammarContextSuggestionImage( xInfo->getImplementationName() ); + aImage = Image( lcl_GetImageFromPngUrl( aSuggestionImageUrl ) ); + } + 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 ); + ++nItemId; } InsertSeparator( nPos++ ); } + + //!! hard wired translations to be removed or added to src file in OOo 3.1 (#i94216) !! + OUString aIgnoreSelection( C2U("Ignore") ); + OUString aSpellingAndGrammar( C2U("Spelling and Grammar...") ); + const lang::Locale aUILocale( Application::GetSettings().GetUILocale() ); + if (aUILocale.Language.equalsAscii("de")) + { + aIgnoreSelection = C2U("Ignorieren"); + aSpellingAndGrammar = C2U("Rechtschreibung und Grammatik..."); + } + SetItemText( MN_SPELLING, aSpellingAndGrammar ); + USHORT nItemPos = GetItemPos( MN_IGNORE ); + InsertItem( MN_IGNORE_SELECTION, aIgnoreSelection, 0, nItemPos ); + SetHelpId( MN_IGNORE_SELECTION, HID_LINGU_IGNORE_SELECTION); + EnableItem( MN_AUTOCORR, false ); uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser(); @@ -580,6 +682,12 @@ bGrammarResults( true ) nNumLanguageDocEntries = fillLangPopupMenu( pMenu, MN_LANGUAGE_ALL_TEXT_START, aSeq, pWrtSh, 2 ); EnableItem( MN_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, + Application::GetSettings().GetStyleSettings().GetWindowColor().IsDark() ); + SetItemImage( MN_SPELLING, rImg ); + ////////////////////////////////////////////////////////////////////////////////// RemoveDisabledEntries( TRUE, TRUE ); @@ -691,7 +799,7 @@ void SwSpellPopup::Execute( USHORT nId ) { if (bGrammarResults) { - SwLinguConfig().SetProperty( A2OU( UPN_IS_GRAMMAR_INTERACTIVE ), uno::makeAny( sal_True )); + SvtLinguConfig().SetProperty( A2OU( UPN_IS_GRAMMAR_INTERACTIVE ), uno::makeAny( sal_True )); } pSh->Left(CRSR_SKIP_CHARS, FALSE, 1, FALSE ); { @@ -702,6 +810,13 @@ void SwSpellPopup::Execute( USHORT nId ) } } 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 ); diff --git a/sw/source/ui/lingu/olmenu.hrc b/sw/source/ui/lingu/olmenu.hrc index 38a462654c9c..521fe313a55b 100644 --- a/sw/source/ui/lingu/olmenu.hrc +++ b/sw/source/ui/lingu/olmenu.hrc @@ -41,13 +41,16 @@ #define STR_LANGSTATUS_NONE (RC_LINGU_BEGIN + 6) #define STR_LANGSTATUS_MORE (RC_LINGU_BEGIN + 7) -#define MN_SPELLING 100 -#define MN_IGNORE 102 -#define MN_INSERT 103 -#define MN_AUTOCORR 104 -#define MN_LANGUAGE_WORD 105 -#define MN_LANGUAGE_PARA 106 +#define IMG_INFO_16 (RC_LINGU_BEGIN + 8) +//! 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 diff --git a/sw/source/ui/lingu/olmenu.src b/sw/source/ui/lingu/olmenu.src index e4d4e1de7492..de391f0bc68d 100644 --- a/sw/source/ui/lingu/olmenu.src +++ b/sw/source/ui/lingu/olmenu.src @@ -31,16 +31,19 @@ #include "olmenu.hrc" #include "helpid.h" -#define SEPARATOR MenuItem { Separator = TRUE; }; + +#define MASKCOLOR MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; }; +#define SEPARATOR MenuItem { Separator = TRUE; }; + Menu MN_SPELL_POPUP { ItemList = { MenuItem { - Identifier = MN_SPELLING ; - HelpID = HID_LINGU_SPELLING_DLG ; - Text [ en-US ] = "~Spellcheck..." ; + Identifier = MN_IGNORE ; + HelpID = HID_LINGU_IGNORE_WORD ; + Text [ en-US ] = "Ignore All" ; }; MenuItem { @@ -53,14 +56,6 @@ Menu MN_SPELL_POPUP }; MenuItem { - Identifier = MN_IGNORE ; - HelpID = HID_LINGU_IGNORE_WORD ; - /* ### ACHTUNG: Neuer Text in Resource? Alle i~gnorieren : ~Ignorieren */ - /* ### ACHTUNG: Neuer Text in Resource? Alle i~gnorieren : ~Ignorieren */ - Text [ en-US ] = "Ignore All" ; - }; - MenuItem - { Identifier = MN_AUTOCORR ; HelpID = HID_LINGU_AUTOCORR ; SubMenu = Menu @@ -68,6 +63,12 @@ Menu MN_SPELL_POPUP }; Text [ en-US ] = "AutoCorrect" ; }; + MenuItem + { + Identifier = MN_SPELLING ; + HelpID = HID_LINGU_SPELLING_DLG ; + Text [ en-US ] = "~Spellcheck..." ; + }; SEPARATOR MenuItem { @@ -122,3 +123,9 @@ String STR_LANGSTATUS_MORE Text [ en-US ] = "More..." ; }; +Image IMG_INFO_16 +{ + ImageBitmap = Bitmap { File = "info_16.png" ; }; + MASKCOLOR +}; + diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 5fd8453bebd0..3d40ce80c918 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -54,6 +54,7 @@ #endif #include <svtools/stritem.hxx> #include <svtools/pathoptions.hxx> +#include <svtools/lingucfg.hxx> #include <sfx2/request.hxx> #include <sfx2/fcontnr.hxx> @@ -113,9 +114,6 @@ #include <swmodule.hxx> #include <sfx2/filedlghelper.hxx> -// #107253# -#include <swlinguconfig.hxx> - #define LONG_LENGTH 60 #define SHORT_LENGTH 30 @@ -284,11 +282,7 @@ SwGlossaryDlg::SwGlossaryDlg(SfxViewFrame* pViewFrame, pSh (pWrtShell) { - // #107253# Hold one local SwLinguConfig here. This creates one incarnation - // of a SvtLinguConfig which is then used as long as this local incarnation - // exists. Other dialogs may be equipped with the same startup-mechanism - // when required. - SwLinguConfig aLocalLinguConfig; + SvtLinguConfig aLocalLinguConfig; // Static-Pointer initialisieren if( !::GetCurrGlosGroup() ) diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index 6c10952d0e2e..aa63e682c06d 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -410,7 +410,6 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) break; } - case SID_AUTOSPELL_MARKOFF: case SID_AUTOSPELL_CHECK: { rView.ExecuteSlot(rReq); @@ -601,7 +600,6 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet) } break; } - case SID_AUTOSPELL_MARKOFF: case SID_AUTOSPELL_CHECK: { const SfxPoolItem* pState = rView.GetSlotState(nWhich); diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx index 2fad7245106c..f09a3d6a7dad 100644 --- a/sw/source/ui/shells/drwtxtex.cxx +++ b/sw/source/ui/shells/drwtxtex.cxx @@ -347,7 +347,6 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) aNewAttr.Put(*pArgs); } break; - case SID_AUTOSPELL_MARKOFF: case SID_AUTOSPELL_CHECK: { //!! JP 16.03.2001: why?? pSdrView = rSh.GetDrawView(); @@ -357,20 +356,10 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) sal_Bool bSet = ((const SfxBoolItem&)rReq.GetArgs()->Get( nSlot)).GetValue(); - if(nSlot == SID_AUTOSPELL_MARKOFF) - { - if(bSet) - nCtrl |= EE_CNTRL_NOREDLINES; - else - nCtrl &= ~EE_CNTRL_NOREDLINES; - } + if(bSet) + nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS; else - { - if(bSet) - nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS; - else - nCtrl &= ~EE_CNTRL_ONLINESPELLING; - } + nCtrl &= ~EE_CNTRL_ONLINESPELLING; pOutliner->SetControlWord(nCtrl); rView.ExecuteSlot(rReq); @@ -728,7 +717,6 @@ void SwDrawTextShell::GetDrawTxtCtrlState(SfxItemSet& rSet) case SID_ATTR_CHAR_CONTOUR: nEEWhich = EE_CHAR_OUTLINE; break; case SID_ATTR_CHAR_SHADOWED: nEEWhich = EE_CHAR_SHADOW;break; case SID_ATTR_CHAR_STRIKEOUT: nEEWhich = EE_CHAR_STRIKEOUT;break; - case SID_AUTOSPELL_MARKOFF: case SID_AUTOSPELL_CHECK: { const SfxPoolItem* pState = rView.GetSlotState(nWhich); diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index 1a80c7fc2176..f2381dbc8ff3 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -151,11 +151,9 @@ void SwDrawTextShell::Init() if(pVOpt->IsOnlineSpell()) { nCtrl |= EE_CNTRL_ONLINESPELLING|EE_CNTRL_ALLOWBIGOBJS; - if(pVOpt->IsHideSpell()) - nCtrl |= EE_CNTRL_NOREDLINES; } else - nCtrl &= ~(EE_CNTRL_ONLINESPELLING|EE_CNTRL_NOREDLINES); + nCtrl &= ~(EE_CNTRL_ONLINESPELLING); pOutliner->SetControlWord(nCtrl); pOLV->ShowCursor(); diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index a855e3dbb121..7c12f537761e 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -1793,7 +1793,6 @@ void SwPagePreView::Init(const SwViewOption * pPrefs) aOpt.SetTable( TRUE ); aOpt.SetSnap( FALSE ); aOpt.SetGridVisible( FALSE ); - aOpt.SetHideSpell( TRUE ); GetViewShell()->ApplyViewOptions( aOpt ); GetViewShell()->ApplyAccessiblityOptions(SW_MOD()->GetAccessibilityOptions()); diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index d2cb9c01956c..2b559a8f535b 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -158,8 +158,6 @@ #include <rtl/ustrbuf.hxx> #include <xmloff/xmluconv.hxx> -// #107253# -#include <swlinguconfig.hxx> #include "formatclipboard.hxx" #include <PostItMgr.hxx> #include <annotsh.hxx> @@ -880,11 +878,9 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) //! get lingu options without loading lingu DLL SvtLinguOptions aLinguOpt; - // #107253# Replaced SvtLinguConfig with SwLinguConfig wrapper with UsageCount - SwLinguConfig().GetOptions( aLinguOpt ); + SvtLinguConfig().GetOptions( aLinguOpt ); aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto ); - aUsrPref.SetHideSpell( aLinguOpt.bIsSpellHideMarkings ); sal_Bool bOldShellWasSrcView = FALSE; diff --git a/sw/source/ui/uiview/view0.cxx b/sw/source/ui/uiview/view0.cxx index 3803c218b8e1..368cf4749897 100644 --- a/sw/source/ui/uiview/view0.cxx +++ b/sw/source/ui/uiview/view0.cxx @@ -40,6 +40,7 @@ #include <SwSpellDialogChildWindow.hxx> #include <svtools/eitem.hxx> #include <svtools/linguprops.hxx> +#include <svtools/lingucfg.hxx> #include <viewopt.hxx> #include <globals.h> #include <sfx2/app.hxx> @@ -51,7 +52,6 @@ #ifndef _AVMEDIA_MEDIAPPLAYER_HXX #include <avmedia/mediaplayer.hxx> #endif -#include <swlinguconfig.hxx> #include <swmodule.hxx> #include <sfx2/objface.hxx> @@ -312,9 +312,6 @@ void SwView::StateViewOptions(SfxItemSet &rSet) case SID_AUTOSPELL_CHECK: aBool.SetValue( pOpt->IsOnlineSpell() ); break; - case SID_AUTOSPELL_MARKOFF: - aBool.SetValue( pOpt->IsHideSpell() ); - break; case FN_SHADOWCURSOR: if (pIDSA == 0 || pIDSA->get( IDocumentSettingAccess::BROWSE_MODE )) { @@ -486,8 +483,8 @@ void SwView::ExecViewOptions(SfxRequest &rReq) uno::Any aVal( &bSet, ::getCppuBooleanType() ); String aPropName( C2S(UPN_IS_SPELL_AUTO) ); - // #107253# Replaced SvtLinguConfig with SwLinguConfig wrapper with UsageCount - SwLinguConfig().SetProperty( aPropName, aVal ); + SvtLinguConfig aCfg; + aCfg.SetProperty( aPropName, aVal ); if (xLngProp.is()) xLngProp->setPropertyValue( aPropName, aVal ); @@ -499,28 +496,16 @@ void SwView::ExecViewOptions(SfxRequest &rReq) SwDocShell *pDocSh = GetDocShell(); SwDoc *pDoc = pDocSh? pDocSh->GetDoc() : NULL; SwRootFrm *pRootFrm = pDoc ? pDoc->GetRootFrm() : NULL; - if (pDoc && pRootFrm) - StartGrammarChecking( *pDoc, *pRootFrm ); - } - } - if (!(STATE_TOGGLE == eState && bSet && ( pOpt->IsHideSpell() ))) - break; - case SID_AUTOSPELL_MARKOFF: - if( STATE_TOGGLE == eState ) - bFlag = bSet = !pOpt->IsHideSpell(); - pOpt->SetHideSpell(bSet); - { - uno::Any aVal( &bSet, ::getCppuBooleanType() ); - String aPropName( C2S(UPN_IS_SPELL_HIDE) ); + // right now we don't have view options for automatic grammar checking. Thus... + sal_Bool bIsAutoGrammar = sal_False; + aCfg.GetProperty( C2U( UPN_IS_GRAMMAR_AUTO ) ) >>= bIsAutoGrammar; - // #107253# Replaced SvtLinguConfig with SwLinguConfig wrapper with UsageCount - SwLinguConfig().SetProperty( aPropName, aVal ); - - if (xLngProp.is()) - xLngProp->setPropertyValue( aPropName, aVal ); + if (pDoc && pRootFrm && bIsAutoGrammar) + StartGrammarChecking( *pDoc, *pRootFrm ); + } } - break; + break; case FN_SHADOWCURSOR: if( STATE_TOGGLE == eState ) bFlag = bSet = !pOpt->IsShadowCursor(); @@ -555,7 +540,7 @@ void SwView::ExecViewOptions(SfxRequest &rReq) pModule->ApplyUsrPref( *pOpt, this, bWebView ? VIEWOPT_DEST_WEB : VIEWOPT_DEST_TEXT ); //mod #i6193# let postits know about new spellcheck setting - if ( (nSlot==SID_AUTOSPELL_CHECK) || nSlot==SID_AUTOSPELL_MARKOFF) + if ( nSlot == SID_AUTOSPELL_CHECK ) GetPostItMgr()->SetSpellChecking(); const BOOL bLockedView = rSh.IsViewLocked(); diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 5f14993f66e6..11d0ee0f0f36 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -1106,21 +1106,39 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) GenerateFormLetter(bUseCurrentDocument); } break; + case SID_RECHECK_DOCUMENT: + { + SwDocShell* pDocShell = GetDocShell(); + SwDoc* pDoc = pDocShell->GetDoc(); + uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() ); + if( xGCIterator.is() ) + { + xGCIterator->resetIgnoreRules(); + } + // reset ignore lists + pDoc->SpellItAgainSam( sal_True, sal_False, sal_False ); + // clear ignore dictionary + uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY ); + if( xDictionary.is() ) + xDictionary->clear(); + // put cursor to the start of the document + pWrtShell->SttDoc(); + } + // no break; - but call spell/grammar dialog case FN_SPELL_GRAMMAR_DIALOG: { SfxViewFrame* pViewFrame = GetViewFrame(); if (rReq.GetArgs() != NULL) - pViewFrame->SetChildWindow (nSlot, + pViewFrame->SetChildWindow (FN_SPELL_GRAMMAR_DIALOG, ((const SfxBoolItem&) (rReq.GetArgs()-> - Get(nSlot))).GetValue()); + Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue()); else - pViewFrame->ToggleChildWindow(nSlot); + pViewFrame->ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG); - pViewFrame->GetBindings().Invalidate(nSlot); + pViewFrame->GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG); rReq.Ignore (); } break; - case SID_ALIGN_ANY_LEFT : case SID_ALIGN_ANY_HCENTER : case SID_ALIGN_ANY_RIGHT : diff --git a/sw/source/ui/uiview/viewdraw.cxx b/sw/source/ui/uiview/viewdraw.cxx index 50c1c4d094e5..d366a5ddc16c 100644 --- a/sw/source/ui/uiview/viewdraw.cxx +++ b/sw/source/ui/uiview/viewdraw.cxx @@ -548,11 +548,6 @@ sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin, else nCntrl &= ~EE_CNTRL_MARKFIELDS; - if (pOpt->IsHideSpell()) - nCntrl |= EE_CNTRL_NOREDLINES; - else - nCntrl &= ~EE_CNTRL_NOREDLINES; - if (pOpt->IsOnlineSpell()) nCntrl |= EE_CNTRL_ONLINESPELLING; else diff --git a/sw/source/ui/uiview/viewling.cxx b/sw/source/ui/uiview/viewling.cxx index 76e637f5a727..588c30a9844d 100644 --- a/sw/source/ui/uiview/viewling.cxx +++ b/sw/source/ui/uiview/viewling.cxx @@ -40,7 +40,7 @@ #endif #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/linguistic2/XThesaurus.hpp> -#include <com/sun/star/linguistic2/GrammarCheckingResult.hpp> +#include <com/sun/star/linguistic2/ProofreadingResult.hpp> #include <com/sun/star/i18n/TextConversionOption.hpp> #include <linguistic/lngprops.hxx> #include <comphelper/processfactory.hxx> @@ -97,6 +97,18 @@ #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/util/URL.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> + +#include <unotools/processfactory.hxx> + +#include <vcl/svapp.hxx> +#include <rtl/ustring.hxx> + #include <cppuhelper/bootstrap.hxx> #include "stmenu.hxx" // PopupMenu for smarttags #include <svx/dialogs.hrc> @@ -105,6 +117,7 @@ #include <memory> +using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::uno; @@ -702,13 +715,45 @@ void SwView::StartThesaurus() Beschreibung: Online-Vorschlaege anbieten *--------------------------------------------------------------------*/ +//!! Start of extra code for context menu modifying extensions +struct ExecuteInfo +{ + uno::Reference< frame::XDispatch > xDispatch; + util::URL aTargetURL; + uno::Sequence< PropertyValue > aArgs; +}; + +class AsyncExecute +{ +public: + DECL_STATIC_LINK( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo* ); +}; + +IMPL_STATIC_LINK_NOINSTANCE( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo ) +{ + const sal_uInt32 nRef = Application::ReleaseSolarMutex(); + try + { + // Asynchronous execution as this can lead to our own destruction! + // Framework can recycle our current frame and the layout manager disposes all user interface + // elements if a component gets detached from its frame! + pExecuteInfo->xDispatch->dispatch( pExecuteInfo->aTargetURL, pExecuteInfo->aArgs ); + } + catch ( Exception& ) + { + } + + Application::AcquireSolarMutex( nRef ); + delete pExecuteInfo; + return 0; +} +//!! End of extra code for context menu modifying extensions sal_Bool SwView::ExecSpellPopup(const Point& rPt) { sal_Bool bRet = sal_False; const SwViewOption* pVOpt = pWrtShell->GetViewOptions(); if( pVOpt->IsOnlineSpell() && - !pVOpt->IsHideSpell() && !pWrtShell->IsSelection()) { if (pWrtShell->GetSelectionType() & nsSelectionType::SEL_DRW_TXT) @@ -725,7 +770,7 @@ sal_Bool SwView::ExecSpellPopup(const Point& rPt) // default context menu. bool bUseGrammarContext = false; Reference< XSpellAlternatives > xAlt( pWrtShell->GetCorrection(&rPt, aToFill) ); - /*linguistic2::*/GrammarCheckingResult aGrammarCheckRes; + /*linguistic2::*/ProofreadingResult aGrammarCheckRes; sal_Int32 nErrorPosInText = -1; sal_Int32 nErrorInResult = -1; uno::Sequence< rtl::OUString > aSuggestions; @@ -735,7 +780,7 @@ sal_Bool SwView::ExecSpellPopup(const Point& rPt) bCorrectionRes = pWrtShell->GetGrammarCorrection( aGrammarCheckRes, nErrorPosInText, nErrorInResult, aSuggestions, &rPt, aToFill ); ::rtl::OUString aMessageText; if (nErrorInResult >= 0) - aMessageText = aGrammarCheckRes.aGrammarErrors[ nErrorInResult ].aShortComment; + aMessageText = aGrammarCheckRes.aErrors[ nErrorInResult ].aShortComment; // we like to use the grammar checking context menu if we either get // some suggestions or at least a comment about the error found... bUseGrammarContext = bCorrectionRes && @@ -744,7 +789,7 @@ sal_Bool SwView::ExecSpellPopup(const Point& rPt) // open respective context menu for spell check or grammar errors with correction suggestions... if ((!bUseGrammarContext && xAlt.is()) || - (bUseGrammarContext && bCorrectionRes && aGrammarCheckRes.aGrammarErrors.getLength() > 0)) + (bUseGrammarContext && bCorrectionRes && aGrammarCheckRes.aErrors.getLength() > 0)) { // get paragraph text String aParaText; @@ -777,13 +822,64 @@ sal_Bool SwView::ExecSpellPopup(const Point& rPt) aEvent.ExecutePosition.Y = aPixPos.Y(); Menu* pMenu = 0; - if(TryContextMenuInterception( *pPopup, pMenu, aEvent )) + ::rtl::OUString sMenuName = ::rtl::OUString::createFromAscii( + bUseGrammarContext ? "private:resource/GrammarContextMenu" : "private:resource/SpellContextMenu"); + if(TryContextMenuInterception( *pPopup, sMenuName, pMenu, aEvent )) { + + //! happy hacking for context menu modifying extensions of this + //! 'custom made' menu... *sigh* (code copied from sfx2 and framework) if ( pMenu ) { + OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); USHORT nId = ((PopupMenu*)pMenu)->Execute(pEditWin, aPixPos); - if(!ExecuteMenuCommand( *dynamic_cast<PopupMenu*>(pMenu), *GetViewFrame(), nId )) - pPopup->Execute(nId); + OUString aCommand = ((PopupMenu*)pMenu)->GetItemCommand(nId); + if (aCommand.getLength() == 0 ) + { + if(!ExecuteMenuCommand( *dynamic_cast<PopupMenu*>(pMenu), *GetViewFrame(), nId )) + pPopup->Execute(nId); + } + else + { + SfxViewFrame *pSfxViewFrame = GetViewFrame(); + SfxFrame *pSfxFrame = pSfxViewFrame? pSfxViewFrame->GetFrame() : 0; + uno::Reference< frame::XFrame > xFrame; + if (pSfxFrame) + xFrame = pSfxFrame->GetFrameInterface(); + com::sun::star::util::URL aURL; + uno::Reference< frame::XDispatchProvider > xDispatchProvider( xFrame, UNO_QUERY ); + uno::Reference< lang::XMultiServiceFactory > xMgr( utl::getProcessServiceFactory(), uno::UNO_QUERY ); + + try + { + uno::Reference< frame::XDispatch > xDispatch; + uno::Reference< util::XURLTransformer > xURLTransformer; + if (xMgr.is()) + { + xURLTransformer = uno::Reference< util::XURLTransformer >( xMgr->createInstance( + C2U("com.sun.star.util.URLTransformer")), UNO_QUERY); + } + + aURL.Complete = aCommand; + xURLTransformer->parseStrict(aURL); + uno::Sequence< beans::PropertyValue > aArgs; + xDispatch = xDispatchProvider->queryDispatch( aURL, rtl::OUString(), 0 ); + + + if (xDispatch.is()) + { + // Execute dispatch asynchronously + ExecuteInfo* pExecuteInfo = new ExecuteInfo; + pExecuteInfo->xDispatch = xDispatch; + pExecuteInfo->aTargetURL = aURL; + pExecuteInfo->aArgs = aArgs; + Application::PostUserEvent( STATIC_LINK(0, AsyncExecute , ExecuteHdl_Impl), pExecuteInfo ); + } + } + catch (Exception &) + { + } + } } else { diff --git a/sw/source/ui/uno/dlelstnr.cxx b/sw/source/ui/uno/dlelstnr.cxx index 54e48ef4db79..3b066a66ce08 100644 --- a/sw/source/ui/uno/dlelstnr.cxx +++ b/sw/source/ui/uno/dlelstnr.cxx @@ -38,7 +38,7 @@ #include <com/sun/star/linguistic2/XDictionaryList.hpp> #include <com/sun/star/linguistic2/XLinguServiceManager.hpp> #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> -#include <com/sun/star/linguistic2/XGrammarCheckingIterator.hpp> +#include <com/sun/star/linguistic2/XProofreadingIterator.hpp> #include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp> #include <svtools/lingucfg.hxx> @@ -87,8 +87,8 @@ SwLinguServiceEventListener::SwLinguServiceEventListener() if (SvtLinguConfig().HasGrammarChecker()) { - aSvcName = A2OU( "com.sun.star.lingu2.GrammarCheckingIterator" ); - xGCIterator = Reference< XGrammarCheckingIterator >( xMgr->createInstance( aSvcName ), UNO_QUERY ); + aSvcName = A2OU( "com.sun.star.linguistic2.ProofreadingIterator" ); + xGCIterator = Reference< XProofreadingIterator >( xMgr->createInstance( aSvcName ), UNO_QUERY ); Reference< XLinguServiceEventBroadcaster > xBC( xGCIterator, UNO_QUERY ); if (xBC.is()) xBC->addLinguServiceEventListener( (XLinguServiceEventListener *) this ); @@ -143,34 +143,26 @@ void SAL_CALL SwLinguServiceEventListener::processLinguServiceEvent( { vos::OGuard aGuard(Application::GetSolarMutex()); - if (rLngSvcEvent.nEvent == GRAMMAR_CHECK_AGAIN) + sal_Bool bIsSpellWrong = 0 != (rLngSvcEvent.nEvent & SPELL_WRONG_WORDS_AGAIN); + sal_Bool bIsSpellAll = 0 != (rLngSvcEvent.nEvent & SPELL_CORRECT_WORDS_AGAIN); + if (0 != (rLngSvcEvent.nEvent & PROOFREAD_AGAIN)) + bIsSpellWrong = bIsSpellAll = sal_True; // have all spelling and grammar checked... + if (bIsSpellWrong || bIsSpellAll) { - // have all text spell and grammar checked again - SW_MOD()->CheckSpellChanges( sal_False, sal_True, sal_True, sal_False ); + SW_MOD()->CheckSpellChanges( sal_False, bIsSpellWrong, bIsSpellAll, sal_False ); } - if (rLngSvcEvent.Source == xLngSvcMgr) + if (rLngSvcEvent.nEvent & HYPHENATE_AGAIN) { - sal_Bool bIsSpellWrong = - 0 != (rLngSvcEvent.nEvent & SPELL_WRONG_WORDS_AGAIN); - sal_Bool bIsSpellAll = - 0 != (rLngSvcEvent.nEvent & SPELL_CORRECT_WORDS_AGAIN); - if (bIsSpellWrong || bIsSpellAll) - { - SW_MOD()->CheckSpellChanges( sal_False, bIsSpellWrong, bIsSpellAll, sal_False ); - } - if (rLngSvcEvent.nEvent & HYPHENATE_AGAIN) - { - SwView *pSwView = SW_MOD()->GetFirstView(); + SwView *pSwView = SW_MOD()->GetFirstView(); - //!! since this function may be called within the ctor of - //!! SwView (during formatting) where the WrtShell is not yet - //!! created, we have to check for the WrtShellPtr to see - //!! if it is already availbale - while (pSwView && pSwView->GetWrtShellPtr()) - { - pSwView->GetWrtShell().ChgHyphenation(); - pSwView = SW_MOD()->GetNextView( pSwView ); - } + //!! since this function may be called within the ctor of + //!! SwView (during formatting) where the WrtShell is not yet + //!! created, we have to check for the WrtShellPtr to see + //!! if it is already availbale + while (pSwView && pSwView->GetWrtShellPtr()) + { + pSwView->GetWrtShell().ChgHyphenation(); + pSwView = SW_MOD()->GetNextView( pSwView ); } } } diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index ec6ba322548e..42b0d699689a 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -1032,8 +1032,10 @@ void SAL_CALL SwXTextView::setPropertyValue( { switch (pCur->nWID) { - case WID_IS_CONSTANT_SPELLCHECK : case WID_IS_HIDE_SPELL_MARKS : + // deprecated #i91949 + break; + case WID_IS_CONSTANT_SPELLCHECK : { sal_Bool bVal = sal_False; const SwViewOption *pOpt = pView->GetWrtShell().GetViewOptions(); @@ -1042,8 +1044,6 @@ void SAL_CALL SwXTextView::setPropertyValue( SwViewOption aNewOpt( *pOpt ); if (pCur->nWID == WID_IS_CONSTANT_SPELLCHECK) aNewOpt.SetOnlineSpell(bVal); - else - aNewOpt.SetHideSpell(bVal); pView->GetWrtShell().ApplyViewOptions( aNewOpt ); } break; @@ -1085,14 +1085,15 @@ uno::Any SAL_CALL SwXTextView::getPropertyValue( aRet <<= nCount; } break; - case WID_IS_CONSTANT_SPELLCHECK : case WID_IS_HIDE_SPELL_MARKS : + // deprecated #i91949 + break; + case WID_IS_CONSTANT_SPELLCHECK : { const SwViewOption *pOpt = pView->GetWrtShell().GetViewOptions(); if (!pOpt) throw RuntimeException(); - UINT32 nFlag = nWID == WID_IS_CONSTANT_SPELLCHECK ? - VIEWOPT_1_ONLINESPELL : VIEWOPT_1_HIDESPELL; + UINT32 nFlag = VIEWOPT_1_ONLINESPELL; sal_Bool bVal = 0 != (pOpt->GetCoreOptions() & nFlag); aRet <<= bVal; } |