diff options
Diffstat (limited to 'sw/source/ui/lingu/olmenu.cxx')
-rw-r--r-- | sw/source/ui/lingu/olmenu.cxx | 96 |
1 files changed, 25 insertions, 71 deletions
diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx index 0bdbb6b60bb5..0bb8f5921183 100644 --- a/sw/source/ui/lingu/olmenu.cxx +++ b/sw/source/ui/lingu/olmenu.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -52,9 +53,6 @@ #include "viewopt.hxx" #include "wrtsh.hxx" #include "wview.hxx" -#include "swabstdlg.hxx" -#include "chrdlg.hrc" - #ifndef _SVSTDARR_HXX #define _SVSTDARR_STRINGSDTOR @@ -81,7 +79,6 @@ #include <svl/itemset.hxx> #include <svl/languageoptions.hxx> #include <svl/stritem.hxx> -#include <svtools/filter.hxx> #include <svtools/langtab.hxx> #include <svx/dlgutil.hxx> #include <unotools/lingucfg.hxx> @@ -89,6 +86,7 @@ #include <vcl/msgbox.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> +#include <sal/macros.h> #include <map> @@ -112,9 +110,7 @@ using ::rtl::OUString; extern void lcl_CharDialog( SwWrtShell &rWrtSh, sal_Bool bUseDialog, sal_uInt16 nSlot,const SfxItemSet *pArgs, SfxRequest *pReq ); -/*-------------------------------------------------------------------------- ----------------------------------------------------------------------------*/ // tries to determine the language of 'rText' // @@ -170,15 +166,15 @@ LanguageType lcl_CheckLanguage( aLangList[2] = rSettings.GetLanguage(); // en-US aLangList[3] = LANGUAGE_ENGLISH_US; -#ifdef DEBUG +#if OSL_DEBUG_LEVEL > 1 lang::Locale a0( SvxCreateLocale( aLangList[0] ) ); lang::Locale a1( SvxCreateLocale( aLangList[1] ) ); lang::Locale a2( SvxCreateLocale( aLangList[2] ) ); lang::Locale a3( SvxCreateLocale( aLangList[3] ) ); #endif - sal_Int32 nCount = sizeof(aLangList) / sizeof(aLangList[0]); - for (sal_Int32 i = 0; i < nCount; i++) + sal_Int32 nCount = SAL_N_ELEMENTS(aLangList); + for (sal_Int32 i = 0; i < nCount; i++) { sal_Int16 nTmpLang = aLangList[i]; if (nTmpLang != LANGUAGE_NONE && nTmpLang != LANGUAGE_DONTKNOW) @@ -307,7 +303,7 @@ void SwSpellPopup::fillLangPopupMenu( aEntryTxt != sAsterix && aEntryTxt != sEmpty) { - DBG_ASSERT( nLangItemIdStart <= nItemId && nItemId <= nLangItemIdStart + MN_MAX_NUM_LANG, + OSL_ENSURE( nLangItemIdStart <= nItemId && nItemId <= nLangItemIdStart + MN_MAX_NUM_LANG, "nItemId outside of expected range!" ); pPopupMenu->InsertItem( nItemId, aEntryTxt, MIB_RADIOCHECK ); if (aEntryTxt == aCurLang) @@ -331,10 +327,6 @@ 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 == GraphicFilter::LoadGraphic( aTmp, aFilterName, aGraphic ) ) @@ -352,7 +344,7 @@ OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) { try { - uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( OUString::createFromAscii("com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY ); + uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.UICommandDescription")) ), uno::UNO_QUERY ); if ( xNameAccess.is() ) { uno::Reference< container::XNameAccess > xUICommandLabels; @@ -367,7 +359,7 @@ OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) { for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) { - if ( aPropSeq[i].Name.equalsAscii( "Name" )) + if ( aPropSeq[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" ) ) ) { aPropSeq[i].Value >>= aStr; break; @@ -389,15 +381,14 @@ OUString RetrieveLabelFromCommand( const OUString& aCmdURL ) SwSpellPopup::SwSpellPopup( SwWrtShell* pWrtSh, const uno::Reference< linguistic2::XSpellAlternatives > &xAlt, - const String &rParaText ) : -PopupMenu( SW_RES(MN_SPELL_POPUP) ), -pSh( pWrtSh ), -xSpellAlt(xAlt), -bGrammarResults(false) + const String &rParaText +) : PopupMenu( SW_RES(MN_SPELL_POPUP) ) + , pSh( pWrtSh ) + , xSpellAlt(xAlt) + , bGrammarResults(false) { - DBG_ASSERT(xSpellAlt.is(), "no spelling alternatives available"); + OSL_ENSURE(xSpellAlt.is(), "no spelling alternatives available"); -// CreateAutoMnemonics(); SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); nCheckedLanguage = LANGUAGE_NONE; @@ -409,7 +400,6 @@ bGrammarResults(false) sal_Int16 nStringCount = static_cast< sal_Int16 >( aSuggestions.getLength() ); SvtLinguConfig aCfg; - const bool bHC = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); PopupMenu *pMenu = GetPopupMenu(MN_AUTOCORR); pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); @@ -421,7 +411,7 @@ bGrammarResults(false) uno::Reference< container::XNamed > xNamed( xSpellAlt, uno::UNO_QUERY ); if (xNamed.is()) { - aSuggestionImageUrl = aCfg.GetSpellAndGrammarContextSuggestionImage( xNamed->getName(), bHC ); + aSuggestionImageUrl = aCfg.GetSpellAndGrammarContextSuggestionImage( xNamed->getName() ); aImage = Image( lcl_GetImageFromPngUrl( aSuggestionImageUrl ) ); } @@ -472,7 +462,6 @@ bGrammarResults(false) } pMenu = GetPopupMenu(MN_ADD_TO_DIC); -// pMenu->CreateAutoMnemonics(); pMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); //! necessary to retrieve the correct dictionary name in 'Execute' below bEnable = sal_False; // enable MN_ADD_TO_DIC? uno::Reference< linguistic2::XDictionaryList > xDicList( SvxGetDictionaryList() ); @@ -512,7 +501,7 @@ bGrammarResults(false) if (xSvcInfo.is()) { OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage( - xSvcInfo->getImplementationName(), bHC) ); + xSvcInfo->getImplementationName() ) ); if (aDictionaryImageUrl.getLength() > 0) { Image aImage( lcl_GetImageFromPngUrl( aDictionaryImageUrl ) ); @@ -560,15 +549,10 @@ bGrammarResults(false) 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_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, - OUString::createFromAscii(".uno:SpellingAndGrammarDialog"), sal_False, - Application::GetSettings().GetStyleSettings().GetHighContrastMode() ); + OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:SpellingAndGrammarDialog")), sal_False ); SetItemImage( MN_SPELLING_DLG, rImg ); ////////////////////////////////////////////////////////////////////////////////// @@ -576,9 +560,7 @@ bGrammarResults(false) RemoveDisabledEntries( sal_True, sal_True ); } -/*-------------------------------------------------------------------------- ----------------------------------------------------------------------------*/ SwSpellPopup::SwSpellPopup( SwWrtShell *pWrtSh, @@ -600,7 +582,6 @@ aInfo16( SW_RES(IMG_INFO_16) ) InsertItem( MN_SHORT_COMMENT, aMessageText, MIB_NOSELECT, nPos++ ); SetItemImage( MN_SHORT_COMMENT, aInfo16 ); -// CreateAutoMnemonics(); SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); InsertSeparator( nPos++ ); @@ -644,7 +625,6 @@ aInfo16( SW_RES(IMG_INFO_16) ) nGuessLangPara = LANGUAGE_NONE; if (xLG.is()) { -// nGuessLangWord = lcl_CheckLanguage( xSpellAlt->getWord(), ::GetSpellChecker(), xLG, sal_False ); nGuessLangPara = lcl_CheckLanguage( rParaText, ::GetSpellChecker(), xLG, sal_True ); } if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE) @@ -693,15 +673,10 @@ aInfo16( SW_RES(IMG_INFO_16) ) 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_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, - OUString::createFromAscii(".uno:SpellingAndGrammarDialog"), sal_False, - Application::GetSettings().GetStyleSettings().GetHighContrastMode() ); + OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:SpellingAndGrammarDialog")), sal_False ); SetItemImage( MN_SPELLING_DLG, rImg ); ////////////////////////////////////////////////////////////////////////////////// @@ -709,19 +684,14 @@ aInfo16( SW_RES(IMG_INFO_16) ) RemoveDisabledEntries( sal_True, sal_True ); } -/*-------------------------------------------------------------------------- ----------------------------------------------------------------------------*/ sal_uInt16 SwSpellPopup::Execute( const Rectangle& rWordPos, Window* pWin ) { -// SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS); sal_uInt16 nRet = PopupMenu::Execute(pWin, pWin->LogicToPixel(rWordPos)); Execute( nRet ); return nRet; } -/*-- 19.01.2006 08:15:48--------------------------------------------------- - -----------------------------------------------------------------------*/ void SwSpellPopup::Execute( sal_uInt16 nId ) { if (nId == USHRT_MAX) @@ -735,7 +705,7 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) { 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" ); + OSL_ENSURE( 0 <= nAltIdx && nAltIdx < aSuggestions.getLength(), "index out of range" ); if (0 <= nAltIdx && nAltIdx < aSuggestions.getLength() && (bGrammarResults || xSpellAlt.is())) { sal_Bool bOldIns = pSh->IsInsMode(); @@ -774,8 +744,8 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) 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(); + // record only if it's NOT already present in autocorrection + SvxAutoCorrect* pACorr = SvxAutoCorrCfg::Get().GetAutoCorrect(); String aOrigWord( bGrammarResults ? OUString() : xSpellAlt->getWord() ) ; String aNewWord( aSuggestions[ nAltIdx ] ); @@ -913,25 +883,9 @@ void SwSpellPopup::Execute( sal_uInt16 nId ) lcl_CharDialog( *pSh, true, nId, 0, 0 ); pSh->Pop( sal_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) - { - VclAbstractDialog* pDlg = pFact->CreateVclDialog( pSh->GetView().GetWindow(), SID_LANGUAGE_OPTIONS ); - pDlg->Execute(); - delete pDlg; - } - } -#endif } pSh->EnterStdMode(); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |