diff options
-rw-r--r-- | sw/inc/cmdid.h | 1 | ||||
-rw-r--r-- | sw/inc/crsrsh.hxx | 8 | ||||
-rw-r--r-- | sw/inc/swcrsr.hxx | 8 | ||||
-rw-r--r-- | sw/inc/viewopt.hxx | 14 | ||||
-rw-r--r-- | sw/sdi/_textsh.sdi | 6 | ||||
-rw-r--r-- | sw/sdi/_viewsh.sdi | 2 | ||||
-rwxr-xr-x | sw/sdi/annotsh.sdi | 9 | ||||
-rw-r--r-- | sw/sdi/drwtxtsh.sdi | 10 | ||||
-rw-r--r-- | sw/sdi/swriter.sdi | 25 | ||||
-rw-r--r-- | sw/source/core/crsr/crstrvl1.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/crsr/swcrsr.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/config/viewopt.cxx | 7 | ||||
-rw-r--r-- | sw/source/ui/docvw/postit.cxx | 24 | ||||
-rw-r--r-- | sw/source/ui/inc/view.hxx | 6 | ||||
-rwxr-xr-x | sw/source/ui/shells/annotsh.cxx | 42 | ||||
-rw-r--r-- | sw/source/ui/shells/drwtxtex.cxx | 168 | ||||
-rw-r--r-- | sw/source/ui/shells/drwtxtsh.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/shells/textsh1.cxx | 52 | ||||
-rw-r--r-- | sw/source/ui/uiview/view.src | 4 | ||||
-rw-r--r-- | sw/source/ui/uiview/viewling.cxx | 167 | ||||
-rw-r--r-- | sw/source/ui/uiview/viewstat.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/web/web.src | 4 |
23 files changed, 362 insertions, 234 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 0ea79539fc..64dd62492d 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -721,7 +721,6 @@ Achtung: Ab sofort sind in diesem File keine C++-Kommentare (//) mehr --------------------------------------------------------------------*/ #define FN_LINE_NUMBERING_DLG (FN_EXTRA + 2 ) /* Zeilennumerierung */ -#define FN_THESAURUS_DLG (FN_EXTRA + 3 ) /* Thesaurus */ #define FN_HYPHENATE_OPT_DLG (FN_EXTRA + 5 ) /* Silbentrennung */ #define FN_ADD_UNKNOWN (FN_EXTRA + 6 ) /* Woerter lernen */ #define FN_DICTIONARY_DLG (FN_EXTRA + 8 ) /* Woerterbuecher */ diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 692184be2d..403e8c7ece 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -30,6 +30,8 @@ #ifndef _CRSRSH_HXX #define _CRSRSH_HXX +#include <com/sun/star/i18n/WordType.hpp> + #include <tools/string.hxx> #include <tools/link.hxx> #include <tools/rtti.hxx> @@ -749,9 +751,9 @@ public: BOOL SelectWord( const Point* pPt = 0 ); // Position vom akt. Cursor erfragen - BOOL IsStartWord()const; - BOOL IsEndWord() const; - BOOL IsInWord() const; + BOOL IsStartWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES )const; + BOOL IsEndWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; + BOOL IsInWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; BOOL IsStartSentence() const; BOOL IsEndSentence() const; BOOL IsSttPara() const; diff --git a/sw/inc/swcrsr.hxx b/sw/inc/swcrsr.hxx index 40d605b57c..21cbf05aa8 100644 --- a/sw/inc/swcrsr.hxx +++ b/sw/inc/swcrsr.hxx @@ -29,7 +29,9 @@ ************************************************************************/ #ifndef _SWCRSR_HXX #define _SWCRSR_HXX + #include <com/sun/star/i18n/WordType.hpp> + #include <pam.hxx> #include <tblsel.hxx> #include <cshtyp.hxx> @@ -132,10 +134,10 @@ public: const SfxItemSet* rReplSet = 0 ); // UI versions - BOOL IsStartWord() const; - BOOL IsEndWord() const; + BOOL IsStartWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; + BOOL IsEndWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; + BOOL IsInWord( sal_Int16 nWordType = com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ) const; BOOL IsStartEndSentence( bool bEnd ) const; - BOOL IsInWord() const; BOOL GoStartWord(); BOOL GoEndWord(); BOOL GoNextWord(); diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx index 98d88b87b3..84d09b6cb6 100644 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -44,7 +44,7 @@ class ViewShell; class SwDocShell; namespace svtools{ class ColorConfig;} -#define VIEWOPT_1_IDLE 0x00000001L +//#define VIEWOPT_1_IDLE 0x00000001L no longer used, see new member 'bIdle' #define VIEWOPT_1_TAB 0x00000002L #define VIEWOPT_1_BLANK 0x00000004L #define VIEWOPT_1_HARDBLANK 0x00000008L @@ -168,6 +168,7 @@ protected: BOOL bBookview : 1; // view mode for page preview BOOL mbViewLayoutBookMode : 1; // book view mode for edit view sal_Bool bShowPlaceHolderFields : 1; //only used in printing! + mutable bool bIdle; // Maszstab USHORT nZoom; // Angaben in Prozent @@ -206,9 +207,14 @@ public: ----------------------------------------------------------------------------*/ inline BOOL IsIdle() const - { return nCoreOptions & VIEWOPT_1_IDLE ? TRUE : FALSE; } - inline void SetIdle( BOOL b ) - { (b != 0) ? (nCoreOptions |= VIEWOPT_1_IDLE ) : ( nCoreOptions &= ~VIEWOPT_1_IDLE); } + { return bIdle; } + + // logically this is a const function since it does not modify the viewoptions + // but only effects idle formatting. Of course that member is already implement + // in the wrong place here... Also currently there are many const modifying casts in the code + // just to call this function on otherwise const objects. Thus declaring it as const now. + inline void SetIdle( BOOL b ) const + { bIdle = b; } inline BOOL IsTab(BOOL bHard = FALSE) const { return !bReadonly && (nCoreOptions & VIEWOPT_1_TAB) && diff --git a/sw/sdi/_textsh.sdi b/sw/sdi/_textsh.sdi index f059be44db..2421136f51 100644 --- a/sw/sdi/_textsh.sdi +++ b/sw/sdi/_textsh.sdi @@ -1601,6 +1601,12 @@ interface BaseText DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; // e.g. disable for read-only documents ] + SID_THES + [ + ExecMethod = Execute ; + StateMethod = GetState ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; // e.g. disable for read-only documents + ] } //ende interface text diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi index 27c8cb4d85..53ff43f8b7 100644 --- a/sw/sdi/_viewsh.sdi +++ b/sw/sdi/_viewsh.sdi @@ -401,7 +401,7 @@ interface BaseTextEditView : View ExecMethod = Execute ; StateMethod = GetState ; ] - FN_THESAURUS_DLG // status(final|play) + SID_THESAURUS // status(final|play) [ ExecMethod = ExecLingu ; StateMethod = GetState ; diff --git a/sw/sdi/annotsh.sdi b/sw/sdi/annotsh.sdi index 95aa023e9e..7321985a9d 100755 --- a/sw/sdi/annotsh.sdi +++ b/sw/sdi/annotsh.sdi @@ -34,7 +34,7 @@ interface Annotation : _Annotation ] { - FN_THESAURUS_DLG // api: + SID_THESAURUS // api: [ ExecMethod = ExecLingu ; StateMethod = GetLinguState ; @@ -368,6 +368,13 @@ interface Annotation : _Annotation DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + SID_THES + [ + ExecMethod = ExecLingu ; + StateMethod = GetLinguState ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; // e.g. disable for read-only documents + ] + } shell SwAnnotationShell diff --git a/sw/sdi/drwtxtsh.sdi b/sw/sdi/drwtxtsh.sdi index 3083df4ae4..1a4c4fe63e 100644 --- a/sw/sdi/drwtxtsh.sdi +++ b/sw/sdi/drwtxtsh.sdi @@ -427,7 +427,7 @@ interface TextDrawText DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - FN_THESAURUS_DLG // api: + SID_THESAURUS // api: [ ExecMethod = ExecDrawLingu ; StateMethod = GetState ; @@ -535,6 +535,7 @@ interface TextDrawText StateMethod = GetState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + SID_LANGUAGE_STATUS [ ExecMethod = Execute; @@ -542,6 +543,13 @@ interface TextDrawText DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; // e.g. disable for read-only documents ] + SID_THES + [ + ExecMethod = Execute; + StateMethod = GetState; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; // e.g. disable for read-only documents + ] + FN_FORMAT_FOOTNOTE_DLG // status() [ ExecMethod = Execute ; diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 315d341977..3f95cbc918 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -8344,31 +8344,6 @@ SfxVoidItem TextWrap FN_DRAW_WRAP_DLG ] //-------------------------------------------------------------------------- -SfxVoidItem ThesaurusDialog FN_THESAURUS_DLG -() -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = TRUE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Asynchron; - - /* config: */ - AccelConfig = TRUE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_OPTIONS; -] - -//-------------------------------------------------------------------------- SfxVoidItem ToggleAnchorType FN_TOOL_ANKER () [ diff --git a/sw/source/core/crsr/crstrvl1.cxx b/sw/source/core/crsr/crstrvl1.cxx index bd14e87a8a..834c7ea100 100644 --- a/sw/source/core/crsr/crstrvl1.cxx +++ b/sw/source/core/crsr/crstrvl1.cxx @@ -36,26 +36,30 @@ #include <viscrs.hxx> #include <callnk.hxx> -BOOL SwCrsrShell::IsStartWord() const +BOOL SwCrsrShell::IsStartWord( sal_Int16 nWordType ) const { - return pCurCrsr->IsStartWord(); + return pCurCrsr->IsStartWord( nWordType ); } -BOOL SwCrsrShell::IsEndWord() const + +BOOL SwCrsrShell::IsEndWord( sal_Int16 nWordType ) const +{ + return pCurCrsr->IsEndWord( nWordType ); +} + +BOOL SwCrsrShell::IsInWord( sal_Int16 nWordType ) const { - return pCurCrsr->IsEndWord(); + return pCurCrsr->IsInWord( nWordType ); } + BOOL SwCrsrShell::IsStartSentence() const { return pCurCrsr->IsStartEndSentence( false ); } + BOOL SwCrsrShell::IsEndSentence() const { return pCurCrsr->IsStartEndSentence( true ); } -BOOL SwCrsrShell::IsInWord() const -{ - return pCurCrsr->IsInWord(); -} BOOL SwCrsrShell::GoStartWord() diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 749046780b..68196f6a86 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1144,19 +1144,19 @@ short SwCursor::MaxReplaceArived() } -BOOL SwCursor::IsStartWord() const +BOOL SwCursor::IsStartWord( sal_Int16 nWordType ) const { - return IsStartWordWT( WordType::ANYWORD_IGNOREWHITESPACES ); + return IsStartWordWT( nWordType ); } -BOOL SwCursor::IsEndWord() const +BOOL SwCursor::IsEndWord( sal_Int16 nWordType ) const { - return IsEndWordWT( WordType::ANYWORD_IGNOREWHITESPACES ); + return IsEndWordWT( nWordType ); } -BOOL SwCursor::IsInWord() const +BOOL SwCursor::IsInWord( sal_Int16 nWordType ) const { - return IsInWordWT( WordType::ANYWORD_IGNOREWHITESPACES ); + return IsInWordWT( nWordType ); } BOOL SwCursor::GoStartWord() diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 4d2eb96d35..2bd95b88a4 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3575,7 +3575,8 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer void MSWordExportBase::OutputEndNode( const SwEndNode &rNode ) { #ifdef DEBUG - ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl; +// someone who knows what he wants should make this linkable when building with 'debug=t' ... +// ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl; #endif ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = mpTableInfo->getTableNodeInfo( &rNode ); diff --git a/sw/source/ui/config/viewopt.cxx b/sw/source/ui/config/viewopt.cxx index fed94bcba8..5f0cd9e8fe 100644 --- a/sw/source/ui/config/viewopt.cxx +++ b/sw/source/ui/config/viewopt.cxx @@ -115,6 +115,7 @@ BOOL SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const && bFormView == rOpt.IsFormView() && mbViewLayoutBookMode == rOpt.mbViewLayoutBookMode && bShowPlaceHolderFields == rOpt.bShowPlaceHolderFields + && bIdle == rOpt.bIdle #ifndef PRODUCT // korrespondieren zu den Angaben in ui/config/cfgvw.src && bTest1 == rOpt.IsTest1() @@ -229,7 +230,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 | @@ -246,6 +247,8 @@ SwViewOption::SwViewOption() : bSelectionInReadonly = SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly(); + bIdle = true; + #ifndef PRODUCT // korrespondieren zu den Angaben in ui/config/cfgvw.src bTest1 = bTest2 = bTest3 = bTest4 = @@ -280,6 +283,7 @@ SwViewOption::SwViewOption(const SwViewOption& rVOpt) bBookview = rVOpt.bBookview; mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode; bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields; + bIdle = rVOpt.bIdle; #ifndef PRODUCT bTest1 = rVOpt.bTest1 ; @@ -320,6 +324,7 @@ SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt ) bBookview = rVOpt.bBookview; mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode; bShowPlaceHolderFields = rVOpt.bShowPlaceHolderFields; + bIdle = rVOpt.bIdle; #ifndef PRODUCT bTest1 = rVOpt.bTest1 ; diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index 157a6e1997..012a420048 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -384,26 +384,30 @@ void PostItTxt::Command( const CommandEvent& rCEvt ) } else { - SfxPopupMenuManager* aMgr = mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Popup(0, this,&rCEvt.GetMousePosPixel()); - XubString aText = ((PopupMenu*)aMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR ); + SfxPopupMenuManager* pMgr = mpMarginWin->DocView()->GetViewFrame()->GetDispatcher()->Popup( 0, this, &rCEvt.GetMousePosPixel() ); + XubString aText = ((PopupMenu*)pMgr->GetSVMenu())->GetItemText( FN_DELETE_NOTE_AUTHOR ); SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, mpMarginWin->GetAuthor()); aText = aRewriter.Apply(aText); - ((PopupMenu*)aMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR,aText); - // SwPostItLinkForwarder_Impl aFwd( ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->GetSelectHdl(), mpPostIt ); - // ((PopupMenu*)aMgr->GetSVMenu())->pSvMenu->SetSelectHdl( LINK(&aFwd, SwPostItLinkForwarder_Impl, Select) ); + ((PopupMenu*)pMgr->GetSVMenu())->SetItemText(FN_DELETE_NOTE_AUTHOR, aText); - ((PopupMenu*)aMgr->GetSVMenu())->SetSelectHdl( LINK(this, PostItTxt, Select) ); + ((PopupMenu*)pMgr->GetSVMenu())->SetSelectHdl( LINK(this, PostItTxt, Select) ); + 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/inc/view.hxx b/sw/source/ui/inc/view.hxx index 459346df23..2077f0f62f 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(); diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index 1fa92edc54..8d6664c3ea 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -30,14 +30,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> @@ -121,8 +124,8 @@ #include <docsh.hxx> #include <svtools/undo.hxx> -#include "swabstdlg.hxx" //CHINA001 -#include "chrdlg.hrc" //CHINA001 +#include "swabstdlg.hxx" +#include "chrdlg.hrc" #include "misc.hrc" #include <app.hrc> @@ -1132,7 +1135,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; @@ -1240,8 +1253,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, @@ -1251,7 +1281,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: diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx index 60059cdeb1..b7cc6b5398 100644 --- a/sw/source/ui/shells/drwtxtex.cxx +++ b/sw/source/ui/shells/drwtxtex.cxx @@ -30,90 +30,84 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include <hintids.hxx> -#include <tools/shl.hxx> -#include <svx/svdview.hxx> -#include <svx/spltitem.hxx> -#include <svx/orphitem.hxx> -#include <svx/brkitem.hxx> -#include <svx/widwitem.hxx> -#include <svx/kernitem.hxx> -#include <svx/escpitem.hxx> -#ifndef _SVX_PARAITEM_HXX //autogen -#include <svx/lspcitem.hxx> -#endif -#include <svx/adjitem.hxx> -#include <svx/crsditem.hxx> -#include <svx/shdditem.hxx> -#include <svx/hyznitem.hxx> -#include <svx/udlnitem.hxx> -#include <svx/fontitem.hxx> -#include <svx/fhgtitem.hxx> -#include <svx/colritem.hxx> -#include <svx/wghtitem.hxx> -#ifndef _SVX_CNTRITEM_HXX //autogen -#include <svx/cntritem.hxx> -#endif -#include <svx/postitem.hxx> -#include <svx/frmdiritem.hxx> -#include <svx/svdoutl.hxx> -#include <sfx2/viewfrm.hxx> -#include <svtools/whiter.hxx> -#include <svtools/cjkoptions.hxx> -#include <svtools/ctloptions.hxx> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> + +#include <comphelper/processfactory.hxx> +#include <i18npool/mslangid.hxx> #include <sfx2/bindings.hxx> -#include <vcl/msgbox.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/request.hxx> -#include <svx/flditem.hxx> +#include <sfx2/viewfrm.hxx> +#include <svtools/cjkoptions.hxx> +#include <svtools/ctloptions.hxx> +#include <svtools/langtab.hxx> +#include <svtools/languageoptions.hxx> +#include <svtools/slstitm.hxx> +#include <svtools/whiter.hxx> +#include <svx/adjitem.hxx> +#include <svx/brkitem.hxx> +#include <svx/cntritem.hxx> +#include <svx/colritem.hxx> +#include <svx/crsditem.hxx> +#include <svx/editdata.hxx> +#include <svx/editeng.hxx> #include <svx/editstat.hxx> +#include <svx/editview.hxx> +#include <svx/eeitem.hxx> +#include <svx/escpitem.hxx> +#include <svx/fhgtitem.hxx> +#include <svx/flditem.hxx> +#include <svx/fontitem.hxx> +#include <svx/frmdiritem.hxx> #include <svx/hlnkitem.hxx> #include <svx/htmlmode.hxx> +#include <svx/hyznitem.hxx> +#include <svx/kernitem.hxx> #include <svx/langitem.hxx> -#include <svx/unolingu.hxx> +#include <svx/lspcitem.hxx> +#include <svx/orphitem.hxx> +#include <svx/outliner.hxx> +#include <svx/postitem.hxx> #include <svx/scripttypeitem.hxx> +#include <svx/shdditem.hxx> +#include <svx/spltitem.hxx> +#include <svx/svdoutl.hxx> +#include <svx/svdview.hxx> +#include <svx/udlnitem.hxx> +#include <svx/unolingu.hxx> +#include <svx/wghtitem.hxx> +#include <svx/widwitem.hxx> #include <svx/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 <svtools/languageoptions.hxx> -#include <svx/langitem.hxx> -#include <svtools/langtab.hxx> -#include <svtools/slstitm.hxx> -#include <string.h> - -#include <svx/eeitem.hxx> -#include <svx/editeng.hxx> -#include <svx/editdata.hxx> -#include <svx/outliner.hxx> -#include <vcl/window.hxx> -#include <svx/editview.hxx> -#include <vcl/outdev.hxx> - -#include <langhelper.hxx> using namespace ::com::sun::star; @@ -151,6 +145,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: @@ -572,7 +578,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; @@ -623,19 +649,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 0aed8ade82..1996c1f2a4 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -400,7 +400,7 @@ void SwDrawTextShell::ExecDrawLingu(SfxRequest &rReq) { switch(rReq.GetSlot()) { - case FN_THESAURUS_DLG: + case SID_THESAURUS: pOLV->StartThesaurus(); break; diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx index e86926c263..6a2db2b1b5 100644 --- a/sw/source/ui/shells/textsh1.cxx +++ b/sw/source/ui/shells/textsh1.cxx @@ -30,7 +30,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> @@ -402,6 +405,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 &rView = rWrtSh.GetView(); + const bool bSelection = rWrtSh.HasSelection();
+ const String aLookUpText = rView.GetThesaurusLookUpText( bSelection );
+ rView.InsertThesaurusSynonym( aReplaceText, aLookUpText, bSelection );
+ } + } + break; + case SID_CHARMAP: { InsertSymbol( rReq ); @@ -1380,6 +1400,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/uiview/view.src b/sw/source/ui/uiview/view.src index a643c9a136..973dfc9bc2 100644 --- a/sw/source/ui/uiview/view.src +++ b/sw/source/ui/uiview/view.src @@ -302,8 +302,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/viewling.cxx b/sw/source/ui/uiview/viewling.cxx index 304457a828..0112d8e6a0 100644 --- a/sw/source/ui/uiview/viewling.cxx +++ b/sw/source/ui/uiview/viewling.cxx @@ -133,7 +133,7 @@ void SwView::ExecLingu(SfxRequest &rReq) { switch(rReq.GetSlot()) { - case FN_THESAURUS_DLG: + case SID_THESAURUS: StartThesaurus(); rReq.Ignore(); break; @@ -282,47 +282,26 @@ void SwView::StartTextConversion( */ 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 ); @@ -570,16 +549,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, @@ -608,10 +648,9 @@ void SwView::StartThesaurus() 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() ); SvxThesaurusDialog *pDlg = NULL; @@ -661,54 +700,12 @@ void SwView::StartThesaurus() } 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 9800c1ed63..e86cf21099 100644 --- a/sw/source/ui/uiview/viewstat.cxx +++ b/sw/source/ui/uiview/viewstat.cxx @@ -306,7 +306,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/web/web.src b/sw/source/ui/web/web.src index d7d60ddde5..d354c12971 100644 --- a/sw/source/ui/web/web.src +++ b/sw/source/ui/web/web.src @@ -141,8 +141,8 @@ ToolBox RID_WEBTOOLS_TOOLBOX }; ToolBoxItem { - Identifier = FN_THESAURUS_DLG; - HelpID = FN_THESAURUS_DLG; + Identifier = SID_THESAURUS; + HelpID = SID_THESAURUS; Hide = TRUE; }; ToolBoxItem |