summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorobo <obo@openoffice.org>2010-06-09 16:35:27 +0200
committerobo <obo@openoffice.org>2010-06-09 16:35:27 +0200
commitf80893d9a3dbb7acb449d505dc585e72c2720f50 (patch)
tree505e47529867eaf340548a7f58e75352eccbc41c
parentb2147842d8c1dc2e55576792db50ccf6c5e914d7 (diff)
parent5c14cccd4010d26ed84f85dc0c6944a34c407c91 (diff)
CWS-TOOLING: integrate CWS tl74
-rw-r--r--desktop/source/deployment/gui/makefile.mk1
-rw-r--r--editeng/inc/editeng/editview.hxx4
-rw-r--r--editeng/inc/editeng/outliner.hxx6
-rwxr-xr-x[-rw-r--r--]editeng/inc/editeng/splwrap.hxx1
-rw-r--r--editeng/source/editeng/editview.cxx4
-rwxr-xr-x[-rw-r--r--]editeng/source/outliner/outlvw.cxx66
-rw-r--r--framework/inc/classes/resource.hrc1
-rwxr-xr-x[-rw-r--r--]framework/inc/helper/mischelper.hxx55
-rw-r--r--framework/inc/uielement/langselectionmenucontroller.hxx3
-rw-r--r--framework/inc/uielement/langselectionstatusbarcontroller.hxx17
-rw-r--r--framework/source/classes/resource.src5
-rw-r--r--framework/source/helper/mischelper.cxx113
-rw-r--r--framework/source/uielement/langselectionmenucontroller.cxx219
-rw-r--r--framework/source/uielement/langselectionstatusbarcontroller.cxx285
-rw-r--r--framework/util/makefile.mk4
-rw-r--r--linguistic/source/convdiclist.cxx1
-rw-r--r--linguistic/source/dlistimp.cxx7
-rwxr-xr-xofficecfg/registry/data/org/openoffice/Office/Accelerators.xcu6
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu46
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs25
-rw-r--r--sfx2/inc/sfx2/mnumgr.hxx26
-rw-r--r--sfx2/inc/sfx2/sfxsids.hrc3
-rw-r--r--sfx2/sdi/sfx.sdi26
-rw-r--r--sfx2/source/menu/makefile.mk5
-rw-r--r--sfx2/source/menu/menu.hrc4
-rw-r--r--sfx2/source/menu/menu.src15
-rwxr-xr-x[-rw-r--r--]sfx2/source/menu/mnumgr.cxx120
-rwxr-xr-xsfx2/source/menu/thessubmenu.cxx274
-rw-r--r--sfx2/source/menu/thessubmenu.hxx107
-rw-r--r--svx/inc/globlmn_tmpl.hrc31
-rw-r--r--svx/inc/helpid.hrc3
-rwxr-xr-x[-rw-r--r--]svx/inc/svx/dialogs.hrc0
-rw-r--r--svx/inc/svx/svxids.hrc8
-rw-r--r--svx/sdi/svx.sdi79
-rw-r--r--svx/source/dialog/makefile.mk2
35 files changed, 1206 insertions, 366 deletions
diff --git a/desktop/source/deployment/gui/makefile.mk b/desktop/source/deployment/gui/makefile.mk
index 6a9c7b6bbb..52092a077a 100644
--- a/desktop/source/deployment/gui/makefile.mk
+++ b/desktop/source/deployment/gui/makefile.mk
@@ -77,6 +77,7 @@ SHL1STDLIBS = \
$(SVTOOLLIB) \
$(SVLLIB) \
$(SVXLIB) \
+ $(SVXCORELIB) \
$(SFXLIB) \
$(DEPLOYMENTMISCLIB) \
$(OLE32LIB)
diff --git a/editeng/inc/editeng/editview.hxx b/editeng/inc/editeng/editview.hxx
index 88dad95d99..761f2821af 100644
--- a/editeng/inc/editeng/editview.hxx
+++ b/editeng/inc/editeng/editview.hxx
@@ -28,6 +28,8 @@
#ifndef _MyEDITVIEW_HXX
#define _MyEDITVIEW_HXX
+#include <com/sun/star/i18n/WordType.hpp>
+
#include <rsc/rscsfx.hxx>
#include <i18npool/lang.h>
#include <tools/color.hxx>
@@ -111,7 +113,7 @@ public:
BOOL HasSelection() const;
ESelection GetSelection() const;
void SetSelection( const ESelection& rNewSel );
- BOOL SelectCurrentWord();
+ BOOL SelectCurrentWord( sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES );
void IndentBlock();
void UnindentBlock();
diff --git a/editeng/inc/editeng/outliner.hxx b/editeng/inc/editeng/outliner.hxx
index 8efc42288d..7d4653dd7c 100644
--- a/editeng/inc/editeng/outliner.hxx
+++ b/editeng/inc/editeng/outliner.hxx
@@ -389,6 +389,12 @@ public:
Selection GetSurroundingTextSelection() const;
};
+
+// some thesaurus functionality to avoid code duplication in different projects...
+bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext( String &rStatusVal, LanguageType &rLang, const EditView &rEditView );
+void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const String &rSynonmText );
+
+
//#if 0 // _SOLAR__PRIVATE
DECLARE_LIST(ViewList,OutlinerView*)
//#else
diff --git a/editeng/inc/editeng/splwrap.hxx b/editeng/inc/editeng/splwrap.hxx
index 1be54f909f..8d2926adcf 100644..100755
--- a/editeng/inc/editeng/splwrap.hxx
+++ b/editeng/inc/editeng/splwrap.hxx
@@ -56,6 +56,7 @@ class EDITENG_DLLPUBLIC SvxSpellWrapper {
private:
friend class SvxSpellCheckDialog;
friend class SvxHyphenWordDialog;
+ friend class SvxHyphenWordDialog_Impl;
Window* pWin;
::com::sun::star::uno::Reference<
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index d9f60c5f64..843e6cf8a8 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1256,13 +1256,13 @@ void EditView::SpellIgnoreWord()
pImpEditView->SpellIgnoreOrAddWord( sal_False );
}
-sal_Bool EditView::SelectCurrentWord()
+sal_Bool EditView::SelectCurrentWord( sal_Int16 nWordType )
{
DBG_CHKTHIS( EditView, 0 );
DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 );
EditSelection aCurSel( pImpEditView->GetEditSelection() );
pImpEditView->DrawSelection();
- aCurSel = PIMPEE->SelectWord( aCurSel.Max() );
+ aCurSel = PIMPEE->SelectWord( aCurSel.Max(), nWordType );
pImpEditView->SetEditSelection( aCurSel );
pImpEditView->DrawSelection();
ShowCursor( sal_True, sal_False );
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index e7ee6c7c16..4034b03d01 100644..100755
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -26,7 +26,11 @@
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
+
#include "precompiled_editeng.hxx"
+
+#include <com/sun/star/i18n/WordType.hpp>
+
#include <svl/intitem.hxx>
#include <editeng/editeng.hxx>
#include <editeng/editview.hxx>
@@ -34,7 +38,9 @@
#include <editeng/eerdll.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/fhgtitem.hxx>
+
#include <svl/style.hxx>
+#include <i18npool/mslangid.hxx>
#define _OUTLINER_CXX
#include <editeng/outliner.hxx>
@@ -59,6 +65,8 @@
#define OL_SCROLL_HOROFFSET 20 /* in % von VisibleSize.Width */
#define OL_SCROLL_VEROFFSET 20 /* in % von VisibleSize.Height */
+using namespace ::com::sun::star;
+
DBG_NAME(OutlinerView)
@@ -972,7 +980,7 @@ void OutlinerView::InsertText( const OutlinerParaObject& rParaObj )
// Eigentlich nicht ganz richtig, das evtl. Einrueckungen
// korrigiert werden muessen, aber das kommt spaeter durch ein
// allgemeingueltiges Import.
- // Dann wird im Inserted gleich ermittelt, was fr eine Einrueckebene
+ // Dann wird im Inserted gleich ermittelt, was f�r eine Einrueckebene
// Moegliche Struktur:
// pImportInfo mit DestPara, DestPos, nFormat, pParaObj...
// Evtl. Problematisch:
@@ -1295,7 +1303,7 @@ void OutlinerView::RemoveAttribs( BOOL bRemoveParaAttribs, USHORT nWhich, BOOL b
- // =====================================================================
+// =====================================================================
// ====================== Einfache Durchreicher =======================
// ======================================================================
@@ -1670,3 +1678,57 @@ Selection OutlinerView::GetSurroundingTextSelection() const
DBG_CHKTHIS(OutlinerView,0);
return pEditView->GetSurroundingTextSelection();
}
+
+
+// ======================================================================
+// ===== some code for thesaurus sub menu within context menu
+// ======================================================================
+
+// returns: true if a word for thesaurus look-up was found at the current cursor position.
+// The status string will be word + iso language string (e.g. "light#en-US")
+bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext(
+ String &rStatusVal,
+ LanguageType &rLang,
+ const EditView &rEditView )
+{
+ // get text and locale for thesaurus look up
+ String aText;
+ EditEngine *pEditEngine = rEditView.GetEditEngine();
+ ESelection aTextSel( rEditView.GetSelection() );
+ if (!aTextSel.HasRange())
+ aTextSel = pEditEngine->GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD );
+ aText = pEditEngine->GetText( aTextSel );
+ aTextSel.Adjust();
+ LanguageType nLang = pEditEngine->GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos );
+ String aLangText( MsLangId::convertLanguageToIsoString( nLang ) );
+
+ // set word and locale to look up as status value
+ String aStatusVal( aText );
+ aStatusVal.AppendAscii( "#" );
+ aStatusVal += aLangText;
+
+ rStatusVal = aStatusVal;
+ rLang = nLang;
+
+ return aText.Len() > 0;
+}
+
+
+void EDITENG_DLLPUBLIC ReplaceTextWithSynonym( EditView &rEditView, const String &rSynonmText )
+{
+ // get selection to use
+ ESelection aCurSel( rEditView.GetSelection() );
+ if (!rEditView.HasSelection())
+ {
+ // select the same word that was used in GetStatusValueForThesaurusFromContext by calling GetWord.
+ // (In the end both functions will call ImpEditEngine::SelectWord)
+ rEditView.SelectCurrentWord( i18n::WordType::DICTIONARY_WORD );
+ aCurSel = rEditView.GetSelection();
+ }
+
+ // replace word ...
+ rEditView.InsertText( rSynonmText );
+ rEditView.ShowCursor( sal_True, sal_False );
+}
+
+
diff --git a/framework/inc/classes/resource.hrc b/framework/inc/classes/resource.hrc
index 66503d3176..5929b8b348 100644
--- a/framework/inc/classes/resource.hrc
+++ b/framework/inc/classes/resource.hrc
@@ -55,6 +55,7 @@
#define STR_SET_LANGUAGE_FOR_PARAGRAPH (RID_STR_START+19)
#define STR_SET_LANGUAGE_FOR_ALL_TEXT (RID_STR_START+20)
#define STR_UNTITLED_DOCUMENT (RID_STR_START+21)
+#define STR_RESET_TO_DEFAULT_LANGUAGE (RID_STR_START+22)
#define POPUPMENU_TOOLBAR_QUICKCUSTOMIZATION (RID_MENU_START+0)
diff --git a/framework/inc/helper/mischelper.hxx b/framework/inc/helper/mischelper.hxx
index c23a38fb24..8efbbac090 100644..100755
--- a/framework/inc/helper/mischelper.hxx
+++ b/framework/inc/helper/mischelper.hxx
@@ -34,10 +34,56 @@
#include <i18npool/lang.h>
#include <svl/languageoptions.hxx>
+#include <rtl/ustring.hxx>
+
+#include <set>
+
+class SvtLanguageTable;
+
+
+// flags for script types in use within selection
+#define LS_SCRIPT_LATIN 0x0001
+#define LS_SCRIPT_ASIAN 0x0002
+#define LS_SCRIPT_COMPLEX 0x0004
+
namespace framework
{
+// menu ids for language status bar control
+enum LangMenuIDs
+{
+ MID_LANG_SEL_1 = 1, // need to start with 1 since xPopupMenu->execute will return 0 if the menu is cancelled
+ MID_LANG_SEL_2,
+ MID_LANG_SEL_3,
+ MID_LANG_SEL_4,
+ MID_LANG_SEL_5,
+ MID_LANG_SEL_6,
+ MID_LANG_SEL_7,
+ MID_LANG_SEL_8,
+ MID_LANG_SEL_9,
+ MID_LANG_SEL_NONE,
+ MID_LANG_SEL_RESET,
+ MID_LANG_SEL_MORE,
+
+ MID_LANG_PARA_SEPERATOR,
+ MID_LANG_PARA_STRING,
+
+ MID_LANG_PARA_1,
+ MID_LANG_PARA_2,
+ MID_LANG_PARA_3,
+ MID_LANG_PARA_4,
+ MID_LANG_PARA_5,
+ MID_LANG_PARA_6,
+ MID_LANG_PARA_7,
+ MID_LANG_PARA_8,
+ MID_LANG_PARA_9,
+ MID_LANG_PARA_NONE,
+ MID_LANG_PARA_RESET,
+ MID_LANG_PARA_MORE,
+};
+
+
inline bool IsScriptTypeMatchingToLanguage( sal_Int16 nScriptType, LanguageType nLang )
{
return 0 != (nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ));
@@ -63,6 +109,15 @@ public:
,sal_Bool& _rIni
,const sal_Char* _pName);
+void FillLangItems( std::set< ::rtl::OUString > &rLangItems,
+ const SvtLanguageTable &rLanguageTable,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &rxFrame,
+ const LanguageGuessingHelper & rLangGuessHelper,
+ sal_Int16 nScriptType,
+ const ::rtl::OUString & rCurLang,
+ const ::rtl::OUString & rKeyboardLang,
+ const ::rtl::OUString & rGuessedTextLang );
+
} // namespace framework
#endif // __MISC_HELPER_HXX_
diff --git a/framework/inc/uielement/langselectionmenucontroller.hxx b/framework/inc/uielement/langselectionmenucontroller.hxx
index 52b5ab8f1f..e9f61255b8 100644
--- a/framework/inc/uielement/langselectionmenucontroller.hxx
+++ b/framework/inc/uielement/langselectionmenucontroller.hxx
@@ -102,11 +102,10 @@ namespace framework
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xMenuDispatch_Font;
::rtl::OUString m_aMenuCommandURL_CharDlgForParagraph;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xMenuDispatch_CharDlgForParagraph;
- ::rtl::OUString m_aCurrentLanguage;
::rtl::OUString m_aCurLang;
sal_Int16 m_nScriptType;
::rtl::OUString m_aKeyboardLang;
- ::rtl::OUString m_aGuessedText;
+ ::rtl::OUString m_aGuessedTextLang;
LanguageGuessingHelper m_aLangGuessHelper;
void fillPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu, const Mode rMode );
diff --git a/framework/inc/uielement/langselectionstatusbarcontroller.hxx b/framework/inc/uielement/langselectionstatusbarcontroller.hxx
index ad12225afa..5c2170a534 100644
--- a/framework/inc/uielement/langselectionstatusbarcontroller.hxx
+++ b/framework/inc/uielement/langselectionstatusbarcontroller.hxx
@@ -35,9 +35,15 @@
#include <stdtypes.h>
#include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
#include <svtools/statusbarcontroller.hxx>
+#include <rtl/ustring.hxx>
#include "helper/mischelper.hxx"
+#include <set>
+
+class SvtLanguageTable;
+
+
// component helper namespace
namespace framework {
@@ -86,12 +92,11 @@ class LangSelectionStatusbarController : public svt::StatusbarController
void operator =(LangSelectionStatusbarController &); // not defined
- sal_Bool m_bShowMenu;
- sal_Int16 m_nScriptType;
- ::rtl::OUString m_aCurrentLanguage;
- ::rtl::OUString m_aCurLang;
- ::rtl::OUString m_aKeyboardLang;
- ::rtl::OUString m_aGuessedText;
+ sal_Bool m_bShowMenu; // if the menu is to be displayed or not (depending on the selected object/text)
+ sal_Int16 m_nScriptType; // the flags for the different script types available in the selection, LATIN = 0x0001, ASIAN = 0x0002, COMPLEX = 0x0004
+ ::rtl::OUString m_aCurLang; // the language of the current selection, "*" if there are more than one languages
+ ::rtl::OUString m_aKeyboardLang; // the keyboard language
+ ::rtl::OUString m_aGuessedTextLang; // the 'guessed' language for the selection, "" if none could be guessed
LanguageGuessingHelper m_aLangGuessHelper;
void LangMenu() throw (::com::sun::star::uno::RuntimeException);
diff --git a/framework/source/classes/resource.src b/framework/source/classes/resource.src
index c8114e7129..5c0f7d087a 100644
--- a/framework/source/classes/resource.src
+++ b/framework/source/classes/resource.src
@@ -327,6 +327,11 @@ String STR_LANGSTATUS_NONE
Text [ en-US ] = "None (Do not check spelling)" ;
Text [ x-comment ] = " ";
};
+String STR_RESET_TO_DEFAULT_LANGUAGE
+{
+ Text [ en-US ] = "Reset to Default Language" ;
+ Text [ x-comment ] = " ";
+};
String STR_LANGSTATUS_MORE
{
Text [ en-US ] = "More..." ;
diff --git a/framework/source/helper/mischelper.cxx b/framework/source/helper/mischelper.cxx
index e70e79096e..6fce055238 100644
--- a/framework/source/helper/mischelper.cxx
+++ b/framework/source/helper/mischelper.cxx
@@ -29,10 +29,15 @@
#include "precompiled_framework.hxx"
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/document/XDocumentLanguages.hpp>
#include <com/sun/star/frame/XModuleManager.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <tools/debug.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
+#include <i18npool/mslangid.hxx>
+#include <svtools/langtab.hxx>
#include <comphelper/processfactory.hxx>
#include <helper/mischelper.hxx>
#include <services.h>
@@ -45,6 +50,9 @@ using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::lang;
+using ::rtl::OUString;
+
+
namespace framework
{
@@ -68,20 +76,23 @@ uno::Reference< linguistic2::XLanguageGuessing > LanguageGuessingHelper::GetGues
return m_xLanguageGuesser;
}
-::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL
- ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory
- ,::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xUICommandLabels
- ,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame
- ,::rtl::OUString& _rModuleIdentifier
- ,sal_Bool& _rIni
- ,const sal_Char* _pName)
+////////////////////////////////////////////////////////////
+
+::rtl::OUString RetrieveLabelFromCommand(
+ const ::rtl::OUString& aCmdURL,
+ const uno::Reference< lang::XMultiServiceFactory >& _xServiceFactory,
+ uno::Reference< container::XNameAccess >& _xUICommandLabels,
+ const uno::Reference< frame::XFrame >& _xFrame,
+ ::rtl::OUString& _rModuleIdentifier,
+ sal_Bool& _rIni,
+ const sal_Char* _pName)
{
::rtl::OUString aLabel;
// Retrieve popup menu labels
if ( !_xUICommandLabels.is() )
{
- try
+ try
{
if ( !_rIni )
{
@@ -138,5 +149,91 @@ uno::Reference< linguistic2::XLanguageGuessing > LanguageGuessingHelper::GetGues
return aLabel;
}
+////////////////////////////////////////////////////////////
+
+void FillLangItems( std::set< OUString > &rLangItems,
+ const SvtLanguageTable & rLanguageTable,
+ const uno::Reference< frame::XFrame > & rxFrame,
+ const LanguageGuessingHelper & rLangGuessHelper,
+ sal_Int16 nScriptType,
+ const OUString & rCurLang,
+ const OUString & rKeyboardLang,
+ const OUString & rGuessedTextLang )
+{
+ rLangItems.clear();
+
+ //1--add current language
+ if( rCurLang != OUString() &&
+ LANGUAGE_DONTKNOW != rLanguageTable.GetType( rCurLang ))
+ rLangItems.insert( rCurLang );
+
+ //2--System
+ const AllSettings& rAllSettings = Application::GetSettings();
+ LanguageType rSystemLanguage = rAllSettings.GetLanguage();
+ if( rSystemLanguage != LANGUAGE_DONTKNOW )
+ {
+ if ( IsScriptTypeMatchingToLanguage( nScriptType, rSystemLanguage ))
+ rLangItems.insert( OUString( rLanguageTable.GetString( rSystemLanguage )) );
+ }
+
+ //3--UI
+ LanguageType rUILanguage = rAllSettings.GetUILanguage();
+ if( rUILanguage != LANGUAGE_DONTKNOW )
+ {
+ if ( IsScriptTypeMatchingToLanguage( nScriptType, rUILanguage ))
+ rLangItems.insert( OUString( rLanguageTable.GetString( rUILanguage )) );
+ }
+
+ //4--guessed language
+ uno::Reference< linguistic2::XLanguageGuessing > xLangGuesser( rLangGuessHelper.GetGuesser() );
+ if ( xLangGuesser.is() && rGuessedTextLang.getLength() > 0)
+ {
+ ::com::sun::star::lang::Locale aLocale(xLangGuesser->guessPrimaryLanguage( rGuessedTextLang, 0, rGuessedTextLang.getLength()) );
+ LanguageType nLang = MsLangId::convertLocaleToLanguageWithFallback( aLocale );
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_NONE && nLang != LANGUAGE_SYSTEM
+ && IsScriptTypeMatchingToLanguage( nScriptType, nLang ))
+ rLangItems.insert( rLanguageTable.GetString( nLang ));
+ }
+
+ //5--keyboard language
+ if( rKeyboardLang != OUString())
+ {
+ if ( IsScriptTypeMatchingToLanguage( nScriptType, rLanguageTable.GetType( rKeyboardLang )))
+ rLangItems.insert( rKeyboardLang );
+ }
+
+ //6--all languages used in current document
+ Reference< com::sun::star::frame::XModel > xModel;
+ if ( rxFrame.is() )
+ {
+ Reference< com::sun::star::frame::XController > xController( rxFrame->getController(), UNO_QUERY );
+ if ( xController.is() )
+ xModel = xController->getModel();
+ }
+ Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, UNO_QUERY );
+ /*the description of nScriptType
+ LATIN : 0x001
+ ASIAN : 0x002
+ COMPLEX: 0x004
+ */
+ const sal_Int16 nMaxCount = 7;
+ if ( xDocumentLanguages.is() )
+ {
+ Sequence< Locale > rLocales( xDocumentLanguages->getDocumentLanguages( nScriptType, nMaxCount ));
+ if ( rLocales.getLength() > 0 )
+ {
+ for ( USHORT i = 0; i < rLocales.getLength(); ++i )
+ {
+ if ( rLangItems.size() == static_cast< size_t >(nMaxCount) )
+ break;
+ const Locale& rLocale=rLocales[i];
+ if( IsScriptTypeMatchingToLanguage( nScriptType, rLanguageTable.GetType( rLocale.Language )))
+ rLangItems.insert( OUString( rLocale.Language ) );
+ }
+ }
+ }
+}
+
} // namespace framework
+
diff --git a/framework/source/uielement/langselectionmenucontroller.cxx b/framework/source/uielement/langselectionmenucontroller.cxx
index 521cacf1c6..22154db372 100644
--- a/framework/source/uielement/langselectionmenucontroller.cxx
+++ b/framework/source/uielement/langselectionmenucontroller.cxx
@@ -27,6 +27,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_framework.hxx"
+
#include <uielement/langselectionmenucontroller.hxx>
//_________________________________________________________________________________________________________________
@@ -63,7 +64,7 @@
#include <com/sun/star/document/XDocumentLanguages.hpp>
#include <com/sun/star/frame/XPopupMenuController.hpp>
#include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
-#include <map>
+
#include <i18npool/mslangid.hxx>
#include <svl/languageoptions.hxx>
#include <com/sun/star/awt/MenuItemStyle.hpp>
@@ -78,6 +79,9 @@
#include "helper/mischelper.hxx"
#include <vos/mutex.hxx>
+#include <map>
+#include <set>
+
//_________________________________________________________________________________________________________________
// Defines
//_________________________________________________________________________________________________________________
@@ -89,6 +93,7 @@ using namespace com::sun::star::frame;
using namespace com::sun::star::beans;
using namespace com::sun::star::util;
+using ::rtl::OUString;
namespace framework
{
@@ -103,8 +108,8 @@ DEFINE_INIT_SERVICE ( LanguageSelectionMenuController, {}
LanguageSelectionMenuController::LanguageSelectionMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) :
svt::PopupMenuControllerBase( xServiceManager ),
- m_bShowMenu( sal_True )
- ,m_aLangGuessHelper(xServiceManager)
+ m_bShowMenu( sal_True ),
+ m_aLangGuessHelper( xServiceManager )
{
}
@@ -137,25 +142,21 @@ void SAL_CALL LanguageSelectionMenuController::statusChanged( const FeatureState
return;
m_bShowMenu = sal_True;
- m_nScriptType=7;//set the default value
+ m_nScriptType = LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX; //set the default value
- rtl::OUString aStrValue;
- Sequence< ::rtl::OUString > aSeq;
+ OUString aStrValue;
+ Sequence< OUString > aSeq;
- if ( Event.State >>= aStrValue )
- {
- m_aCurrentLanguage=aStrValue;
- }
- else if ( Event.State >>= aSeq )
+ if ( Event.State >>= aSeq )
{
if ( aSeq.getLength() == 4 )
{
// Retrieve all other values from the sequence and
// store it members!
- m_aCurLang=aSeq[0];
- m_nScriptType= static_cast< sal_Int16 >(aSeq[1].toInt32());
- m_aKeyboardLang=aSeq[2];
- m_aGuessedText=aSeq[3];
+ m_aCurLang = aSeq[0];
+ m_nScriptType = static_cast< sal_Int16 >(aSeq[1].toInt32());
+ m_aKeyboardLang = aSeq[2];
+ m_aGuessedTextLang = aSeq[3];
}
}
else if ( !Event.State.hasValue() )
@@ -186,14 +187,14 @@ void LanguageSelectionMenuController::impl_select(const Reference< XDispatch >&
{
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
if ( xDispatchProvider.is() )
- xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
+ xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
}
if ( xDispatch.is() )
{
Sequence<PropertyValue> aArgs;
if(::comphelper::UiEventsLogger::isEnabled()) //#i88653#
- UiEventLogHelper(::rtl::OUString::createFromAscii("LanguageSelectionMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs);
+ UiEventLogHelper( OUString::createFromAscii("LanguageSelectionMenuController")).log( m_xServiceManager, m_xFrame, aTargetURL, aArgs );
xDispatch->dispatch( aTargetURL, aArgs );
}
}
@@ -208,22 +209,22 @@ void LanguageSelectionMenuController::impl_setPopupMenu()
// Register for language updates
aTargetURL.Complete = m_aLangStatusCommandURL;
m_xURLTransformer->parseStrict( aTargetURL );
- m_xLanguageDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
+ m_xLanguageDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
// Register for setting languages and opening language dialog
aTargetURL.Complete = m_aMenuCommandURL_Lang;
m_xURLTransformer->parseStrict( aTargetURL );
- m_xMenuDispatch_Lang = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
+ m_xMenuDispatch_Lang = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
// Register for opening character dialog
aTargetURL.Complete = m_aMenuCommandURL_Font;
m_xURLTransformer->parseStrict( aTargetURL );
- m_xMenuDispatch_Font = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
+ m_xMenuDispatch_Font = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
// Register for opening character dialog with preselected paragraph
aTargetURL.Complete = m_aMenuCommandURL_CharDlgForParagraph;
m_xURLTransformer->parseStrict( aTargetURL );
- m_xMenuDispatch_CharDlgForParagraph = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
+ m_xMenuDispatch_CharDlgForParagraph = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
}
void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu , const Mode eMode )
@@ -245,143 +246,77 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup
String aCmd_Language;
if( eMode == MODE_SetLanguageSelectionMenu )
{
- aCmd_Dialog+=String::CreateFromAscii(".uno:FontDialog?Language:string=*");
- aCmd_Language+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Current_");
+ aCmd_Dialog.AppendAscii(".uno:FontDialog?Language:string=*");
+ aCmd_Language.AppendAscii(".uno:LanguageStatus?Language:string=Current_");
}
else if ( eMode == MODE_SetLanguageParagraphMenu )
{
- aCmd_Dialog+=String::CreateFromAscii(".uno:FontDialogForParagraph");
- aCmd_Language+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Paragraph_");
+ aCmd_Dialog.AppendAscii(".uno:FontDialogForParagraph");
+ aCmd_Language.AppendAscii(".uno:LanguageStatus?Language:string=Paragraph_");
}
else if ( eMode == MODE_SetLanguageAllTextMenu )
{
- aCmd_Dialog+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=*");
- aCmd_Language+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Default_");
+ aCmd_Dialog.AppendAscii(".uno:LanguageStatus?Language:string=*");
+ aCmd_Language.AppendAscii(".uno:LanguageStatus?Language:string=Default_");
}
- //Reference< awt::XMenuExtended > m_xMenuExtended( m_xPopupMenu, UNO_QUERY );
- std::map< ::rtl::OUString, ::rtl::OUString > LangItems;
-
- SvtLanguageTable aLanguageTable;
- USHORT nItemId = 1;
-
- //1--add current language
- if(m_aCurLang.getLength())
+ SvtLanguageTable aLanguageTable;
+
+ // get languages to be displayed in the menu
+ std::set< OUString > aLangItems;
+ FillLangItems( aLangItems, aLanguageTable, m_xFrame, m_aLangGuessHelper,
+ m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedTextLang );
+
+ //
+ // now add menu entries
+ // the different menues purpose will be handled by the different string
+ // for aCmd_Dialog and aCmd_Language
+ //
+
+ sal_Int16 nItemId = 1; // in this control the item id is not important for executing the command
+ const OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); // multiple languages in current selection
+ const OUString sEmpty; // 'no language found' from language guessing
+ std::map< sal_Int16, OUString > aLangMap;
+ std::set< OUString >::const_iterator it;
+ for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
{
- LangItems[m_aCurLang]=m_aCurLang;
- }
-
- SvtLanguageTable aLangTable;
- //2--System
- const AllSettings& rAllSettings=Application::GetSettings();
- LanguageType rSystemLanguage = rAllSettings.GetLanguage();
- if(rSystemLanguage!=LANGUAGE_DONTKNOW)
- {
- if (IsScriptTypeMatchingToLanguage(m_nScriptType,rSystemLanguage ))
- LangItems[::rtl::OUString(aLangTable.GetString(rSystemLanguage))]=::rtl::OUString(aLangTable.GetString(rSystemLanguage));
- }
-
- //3--UI
- LanguageType rUILanguage = rAllSettings.GetUILanguage();
- if(rUILanguage!=LANGUAGE_DONTKNOW)
- {
- if (IsScriptTypeMatchingToLanguage(m_nScriptType, rUILanguage ))
- LangItems[::rtl::OUString(aLangTable.GetString(rUILanguage))]=::rtl::OUString(aLangTable.GetString(rUILanguage));
- }
-
- //4--guessed language
- uno::Reference< linguistic2::XLanguageGuessing > xLangGuesser( m_aLangGuessHelper.GetGuesser() );
- if (xLangGuesser.is() && m_aGuessedText.getLength() > 0)
- {
- ::com::sun::star::lang::Locale aLocale(xLangGuesser->guessPrimaryLanguage( m_aGuessedText, 0, m_aGuessedText.getLength()) );
- LanguageType nLang = MsLangId::convertLocaleToLanguageWithFallback( aLocale );
- if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_NONE && nLang != LANGUAGE_SYSTEM
- && IsScriptTypeMatchingToLanguage( m_nScriptType, nLang ))
- LangItems[aLangTable.GetString(nLang)]=aLangTable.GetString(nLang);
- }
-
- //5--keyboard language
- if(m_aKeyboardLang!=::rtl::OUString::createFromAscii(""))
- {
- if (IsScriptTypeMatchingToLanguage(m_nScriptType, aLanguageTable.GetType(m_aKeyboardLang)))
- LangItems[m_aKeyboardLang] = m_aKeyboardLang;
- }
-
- //6--all languages used in current document
- Reference< com::sun::star::frame::XModel > xModel;
- if ( m_xFrame.is() )
- {
- Reference< com::sun::star::frame::XController > xController( m_xFrame->getController(), UNO_QUERY );
- if ( xController.is() )
- xModel = xController->getModel();
- }
- Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, UNO_QUERY );
- /*the description of m_nScriptType
- LATIN : 1
- ASIAN : 2
- COMPLEX:4
- LATIN + ASIAN : 3
- LATIN + COMPLEX : 5
- ASIAN + COMPLEX : 6
- LATIN + ASIAN + COMPLEX : 7
- */
-
- sal_Int16 nCount=7;
- if(xDocumentLanguages.is())
- {
- Sequence< Locale > rLocales(xDocumentLanguages->getDocumentLanguages(m_nScriptType,nCount));
- if(rLocales.getLength()>0)
- {
- for(USHORT i = 0; i<rLocales.getLength();++i)
- {
- if (LangItems.size()==7)
- break;
- const Locale& rLocale=rLocales[i];
- if(IsScriptTypeMatchingToLanguage(m_nScriptType, aLanguageTable.GetType(rLocale.Language)))
- LangItems[rLocale.Language] = rLocale.Language;
- }
- }
- }
- std::map< sal_Int16, ::rtl::OUString > LangTable;
-
- const ::rtl::OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*"));
- bool bMultipleLanguages = (eMode != MODE_SetLanguageSelectionMenu) || m_aCurLang.compareToAscii( "*" ) == 0;
- bool bNothingSelected = true;
- MenuItemBits nItemBits = !bMultipleLanguages ? MIB_RADIOCHECK : 0;
- for(std::map< ::rtl::OUString, ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it)
- {
- if(it->first != ::rtl::OUString( aLangTable.GetString( LANGUAGE_NONE ) )&&
- it->first != sAsterix &&
- it->first.getLength())
+ const OUString & rStr( *it );
+ if (rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&&
+ rStr != sAsterix &&
+ rStr != sEmpty)
{
- ++nItemId;
- pPopupMenu->InsertItem( nItemId,it->first,nItemBits );
- LangTable[nItemId] = it->first;
- if(it->first == m_aCurLang && eMode == MODE_SetLanguageSelectionMenu )
+ pPopupMenu->InsertItem( nItemId, rStr );
+ aCmd = aCmd_Language;
+ aCmd += String( rStr );
+ pPopupMenu->SetItemCommand( nItemId, aCmd );
+ if (rStr == m_aCurLang && eMode == MODE_SetLanguageSelectionMenu )
{
//make a sign for the current language
- pPopupMenu->CheckItem(nItemId,TRUE);
- bNothingSelected = false;
+ pPopupMenu->CheckItem( nItemId, TRUE );
}
- aCmd=aCmd_Language;
- aCmd+=(String)it->first;
- pPopupMenu->SetItemCommand(nItemId,aCmd);
+ aLangMap[ nItemId ] = rStr;
+ ++nItemId;
}
}
- //7--none
- nItemId++;
- pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_LANGSTATUS_NONE )), nItemBits );
- if (bNothingSelected && !bMultipleLanguages)
- pPopupMenu->CheckItem(nItemId,TRUE);
+ // entry for LANGUAGE_NONE
+ ++nItemId;
+ pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_LANGSTATUS_NONE )) );
+ aCmd=aCmd_Language;
+ aCmd.AppendAscii("LANGUAGE_NONE");
+ pPopupMenu->SetItemCommand( nItemId, aCmd );
+
+ // entry for 'Reset to default language'
+ ++nItemId;
+ pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_RESET_TO_DEFAULT_LANGUAGE )) );
aCmd=aCmd_Language;
- aCmd+=String::CreateFromAscii("LANGUAGE_NONE");
- pPopupMenu->SetItemCommand(nItemId,aCmd);
+ aCmd.AppendAscii("RESET_LANGUAGES");
+ pPopupMenu->SetItemCommand( nItemId, aCmd );
- //More...
- nItemId++;
+ // entry for opening the Format/Character dialog
+ ++nItemId;
pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_LANGSTATUS_MORE )));
- pPopupMenu->SetItemCommand(nItemId,aCmd_Dialog);
+ pPopupMenu->SetItemCommand( nItemId, aCmd_Dialog );
}
@@ -431,10 +366,10 @@ void SAL_CALL LanguageSelectionMenuController::initialize( const Sequence< Any >
if ( m_bInitialized )
{
- m_aLangStatusCommandURL = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LanguageStatus" ));
+ m_aLangStatusCommandURL = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LanguageStatus" ));
m_aMenuCommandURL_Lang = m_aLangStatusCommandURL;
- m_aMenuCommandURL_Font = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialog" ));
- m_aMenuCommandURL_CharDlgForParagraph = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialogForParagraph" ));
+ m_aMenuCommandURL_Font = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialog" ));
+ m_aMenuCommandURL_CharDlgForParagraph = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialogForParagraph" ));
}
}
}
diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx
index 7c086f2d4a..bf5b660b5f 100644
--- a/framework/source/uielement/langselectionstatusbarcontroller.cxx
+++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx
@@ -27,6 +27,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_framework.hxx"
+
#include <uielement/langselectionstatusbarcontroller.hxx>
#include <classes/fwkresid.hxx>
#include <services.h>
@@ -53,8 +54,6 @@
#include <com/sun/star/frame/XModule.hpp>
#include <com/sun/star/frame/XModel.hpp>
-#include <map>
-#include <set>
#include <classes/fwkresid.hxx>
#ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_
#include <classes/resource.hrc>
@@ -74,6 +73,9 @@
#include "helper/mischelper.hxx"
+#include <map>
+#include <set>
+
using namespace ::cppu;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -82,9 +84,14 @@ using namespace ::com::sun::star::frame;
using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::document;
+using ::rtl::OUString;
+
+
namespace framework
{
+////////////////////////////////////////////////////////////
+
DEFINE_XSERVICEINFO_MULTISERVICE ( LangSelectionStatusbarController ,
OWeakObject ,
SERVICENAME_STATUSBARCONTROLLER ,
@@ -94,10 +101,10 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( LangSelectionStatusbarController
DEFINE_INIT_SERVICE ( LangSelectionStatusbarController, {} )
LangSelectionStatusbarController::LangSelectionStatusbarController( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) :
- svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), rtl::OUString(), 0 ),
+ svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), OUString(), 0 ),
m_bShowMenu( sal_True ),
- m_nScriptType( 7 )
- ,m_aLangGuessHelper(xServiceManager)
+ m_nScriptType( LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX ),
+ m_aLangGuessHelper( xServiceManager )
{
}
@@ -178,223 +185,159 @@ throw (::com::sun::star::uno::RuntimeException)
return sal_False;
}
-void LangSelectionStatusbarController::LangMenu()throw (::com::sun::star::uno::RuntimeException)
+void LangSelectionStatusbarController::LangMenu()
+throw (::com::sun::star::uno::RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::LangMenu" );
if (!m_bShowMenu)
return;
//add context menu
- const static ::rtl::OUString s_sPopupMenu(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.PopupMenu"));
+ const static OUString s_sPopupMenu(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.PopupMenu"));
Reference< awt::XPopupMenu > xPopupMenu( m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY );
//sub menu that contains all items except the last two items: Separator + Set Language for Paragraph
Reference< awt::XPopupMenu > subPopupMenu(m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY );
- std::set< ::rtl::OUString > LangItems;
-
- SvtLanguageTable aLanguageTable;
- USHORT nItemId=1;
-
- //1--add current language
- if( m_aCurLang != ::rtl::OUString( ) &&
- LANGUAGE_DONTKNOW != aLanguageTable.GetType( m_aCurLang ))
- LangItems.insert( m_aCurLang );
-
- //2--System
- SvtLanguageTable aLangTable;
- const AllSettings& rAllSettings = Application::GetSettings();
- LanguageType rSystemLanguage = rAllSettings.GetLanguage();
- if( rSystemLanguage != LANGUAGE_DONTKNOW )
- {
- if ( IsScriptTypeMatchingToLanguage( m_nScriptType, rSystemLanguage ))
- LangItems.insert( ::rtl::OUString( aLangTable.GetString( rSystemLanguage )) );
- }
-
- //3--UI
- LanguageType rUILanguage = rAllSettings.GetUILanguage();
- if( rUILanguage != LANGUAGE_DONTKNOW )
- {
- if ( IsScriptTypeMatchingToLanguage( m_nScriptType, rUILanguage ))
- LangItems.insert( ::rtl::OUString( aLangTable.GetString( rUILanguage )) );
- }
-
- //4--guessed language
- uno::Reference< linguistic2::XLanguageGuessing > xLangGuesser( m_aLangGuessHelper.GetGuesser() );
- if ( xLangGuesser.is() && m_aGuessedText.getLength() > 0)
- {
- ::com::sun::star::lang::Locale aLocale(xLangGuesser->guessPrimaryLanguage( m_aGuessedText, 0, m_aGuessedText.getLength()) );
- LanguageType nLang = MsLangId::convertLocaleToLanguageWithFallback( aLocale );
- if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_NONE && nLang != LANGUAGE_SYSTEM
- && IsScriptTypeMatchingToLanguage( m_nScriptType, nLang ))
- LangItems.insert( aLangTable.GetString( nLang ));
- }
-
- //5--keyboard language
- if( m_aKeyboardLang != ::rtl::OUString::createFromAscii( "" ))
+ SvtLanguageTable aLanguageTable;
+
+ // get languages to be displayed in the menu
+ std::set< OUString > aLangItems;
+ FillLangItems( aLangItems, aLanguageTable, m_xFrame, m_aLangGuessHelper,
+ m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedTextLang );
+
+ //
+ // add first few entries to main menu
+ //
+ sal_Int16 nItemId = static_cast< sal_Int16 >(MID_LANG_SEL_1);
+ const OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); // multiple languages in current selection
+ const OUString sEmpty; // 'no language found' from language guessing
+ std::map< sal_Int16, OUString > aLangMap;
+ std::set< OUString >::const_iterator it;
+ for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
{
- if ( IsScriptTypeMatchingToLanguage( m_nScriptType, aLanguageTable.GetType( m_aKeyboardLang )))
- LangItems.insert( m_aKeyboardLang );
- }
-
- //6--all languages used in current document
- Reference< com::sun::star::frame::XModel > xModel;
- if ( m_xFrame.is() )
- {
- Reference< com::sun::star::frame::XController > xController( m_xFrame->getController(), UNO_QUERY );
- if ( xController.is() )
- xModel = xController->getModel();
- }
- Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, UNO_QUERY );
- /*the description of m_nScriptType
- LATIN : 1
- ASIAN : 2
- COMPLEX:4
- LATIN + ASIAN : 3
- LATIN + COMPLEX : 5
- ASIAN + COMPLEX : 6
- LATIN + ASIAN + COMPLEX : 7
- */
-
- sal_Int16 nCount=7;
- if ( xDocumentLanguages.is() )
- {
- Sequence< Locale > rLocales( xDocumentLanguages->getDocumentLanguages( m_nScriptType, nCount ));
- if ( rLocales.getLength() > 0 )
- {
- for ( USHORT i = 0; i<rLocales.getLength();++i )
- {
- if ( LangItems.size() == 7 )
- break;
- const Locale& rLocale=rLocales[i];
- if( IsScriptTypeMatchingToLanguage( m_nScriptType, aLangTable.GetType( rLocale.Language )))
- LangItems.insert( ::rtl::OUString( rLocale.Language ) );
- }
- }
- }
- std::map< sal_Int16, ::rtl::OUString > LangTable;
- bool bMultipleLanguages = m_aCurLang.compareToAscii( "*" ) == 0;
- bool bNothingSelected = true;
- sal_Int16 nMenuItemStyle = !bMultipleLanguages ? css::awt::MenuItemStyle::RADIOCHECK : 0;
-
- for( std::set< ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it )
- {
- if ( *it != ::rtl::OUString( aLangTable.GetString( LANGUAGE_NONE ) )&&
- *it != ::rtl::OUString::createFromAscii( "*" ) &&
- *it != ::rtl::OUString::createFromAscii( "" ))
+ const OUString & rStr( *it );
+ if ( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) ) &&
+ rStr != sAsterix &&
+ rStr != sEmpty)
{
- //nItemId = xPopupMenu->getItemCount()+1;
- nItemId++;
- xPopupMenu->insertItem( nItemId, *it, nMenuItemStyle, nItemId );
- LangTable[nItemId]=*it;
- if( *it == m_aCurLang )
+ DBG_ASSERT( MID_LANG_SEL_1 <= nItemId && nItemId <= MID_LANG_SEL_9,
+ "nItemId outside of expected range!" );
+ xPopupMenu->insertItem( nItemId, rStr, css::awt::MenuItemStyle::RADIOCHECK, nItemId );
+ if ( rStr == m_aCurLang )
{
//make a sign for the current language
xPopupMenu->checkItem( nItemId, TRUE );
bNothingSelected = false;
}
+ aLangMap[ nItemId ] = rStr;
+ ++nItemId;
}
}
-
- //7--none
- nItemId++;
- xPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_NONE )), nMenuItemStyle, nItemId );
- if (bNothingSelected && !bMultipleLanguages)
- xPopupMenu->checkItem( nItemId, TRUE );
-
- //More...
- nItemId++;
- xPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_MORE )), 0, nItemId );
-
- for( ::std::set< ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it )
+ xPopupMenu->insertItem( MID_LANG_SEL_NONE, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_NONE );
+ xPopupMenu->insertItem( MID_LANG_SEL_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_RESET );
+ xPopupMenu->insertItem( MID_LANG_SEL_MORE, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_MORE );
+
+ //
+ // add entries to submenu ('set language for paragraph')
+ //
+ nItemId = static_cast< sal_Int16 >(MID_LANG_PARA_1);
+ for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
{
- if( *it != ::rtl::OUString( aLangTable.GetString( LANGUAGE_NONE ) )&&
- *it != ::rtl::OUString::createFromAscii( "*" ) &&
- *it != ::rtl::OUString::createFromAscii( "" ))
+ const OUString & rStr( *it );
+ if( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&&
+ rStr != sAsterix &&
+ rStr != sEmpty)
{
- nItemId++;
- subPopupMenu->insertItem( nItemId, *it, 0, nItemId );
- LangTable[nItemId]=*it;
+ DBG_ASSERT( MID_LANG_PARA_1 <= nItemId && nItemId <= MID_LANG_PARA_9,
+ "nItemId outside of expected range!" );
+ subPopupMenu->insertItem( nItemId, rStr, css::awt::MenuItemStyle::RADIOCHECK, nItemId );
+ aLangMap[nItemId] = rStr;
+ ++nItemId;
}
}
- //7--none
- nItemId++;
- subPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_NONE )), 0, nItemId );
- //More
- nItemId++;
- subPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_MORE )), 0, nItemId );
+ subPopupMenu->insertItem( MID_LANG_PARA_NONE, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_NONE );
+ subPopupMenu->insertItem( MID_LANG_PARA_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_RESET );
+ subPopupMenu->insertItem( MID_LANG_PARA_MORE, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_MORE );
- nItemId++;
- xPopupMenu->insertSeparator(nItemId);
+ //
+ // add last two entries to main menu
+ //
+ xPopupMenu->insertSeparator( MID_LANG_PARA_SEPERATOR );
+ xPopupMenu->insertItem( MID_LANG_PARA_STRING, String( FwkResId( STR_SET_LANGUAGE_FOR_PARAGRAPH )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_STRING );
+ xPopupMenu->setPopupMenu( MID_LANG_PARA_STRING, subPopupMenu );
- nItemId++;
- xPopupMenu->insertItem( nItemId, String( FwkResId( STR_SET_LANGUAGE_FOR_PARAGRAPH )), 0, nItemId );
- xPopupMenu->setPopupMenu( nItemId, subPopupMenu );
- //display the popup menu and execute every command
+ //
+ // now display the popup menu and execute every command ...
+ //
Reference< awt::XWindowPeer > xParent( m_xParentWindow, UNO_QUERY );
- com::sun::star::awt::Rectangle mRectangle;
+ com::sun::star::awt::Rectangle aRectangle;
Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow );
const Point mMousePos = pWindow->GetPointerPosPixel();
- mRectangle.X = mMousePos.X();
- mRectangle.Y = mMousePos.Y();
- sal_Int16 nId = xPopupMenu->execute( xParent, mRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 );
+ aRectangle.X = mMousePos.X();
+ aRectangle.Y = mMousePos.Y();
+ sal_Int16 nId = xPopupMenu->execute( xParent, aRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 );
//click "More..."
if ( nId && m_xFrame.is() )
{
uno::Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
util::URL aURL;
- if ( nId < nItemId-3-subPopupMenu->getItemCount() )
+ if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9)
{
- //1..7
//set selected language as current language for selection
- String SelectedLang = LangTable[nId];
- aURL.Complete+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Current_");
- aURL.Complete+=SelectedLang;
+ String aSelectedLang = aLangMap[nId];
+ aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Current_");
+ aURL.Complete += aSelectedLang;
}
- else if ( nId == nItemId-3-subPopupMenu->getItemCount() )
+ else if (nId == MID_LANG_SEL_NONE)
{
- //8
//set None as current language for selection
- aURL.Complete+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE");
+ aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE");
+ }
+ else if (nId == MID_LANG_SEL_RESET)
+ {
+ // reset language attributes for selection
+ aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES");
}
- else if ( nId == nItemId-2-subPopupMenu->getItemCount() )
+ else if (nId == MID_LANG_SEL_MORE)
{
- //9 (more)...
//open the dialog "format/character" for current selection
- aURL.Complete+=String::CreateFromAscii(".uno:FontDialog?Language:string=*");
+ aURL.Complete += OUString::createFromAscii(".uno:FontDialog?Language:string=*");
}
- else if ( nId < nItemId-3 && nId>nItemId-2-subPopupMenu->getItemCount() )
+ else if (MID_LANG_PARA_1 <= nId && nId <= MID_LANG_PARA_9)
{
- //1..7 para
//set selected language for current paragraph
- String SelectedLang = LangTable[nId];
- aURL.Complete+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Paragraph_");
- aURL.Complete+=SelectedLang;
+ String aSelectedLang = aLangMap[nId];
+ aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Paragraph_");
+ aURL.Complete += aSelectedLang;
}
- else if ( nId==nItemId-3 )
+ else if (nId == MID_LANG_PARA_NONE)
{
- //8 para
//set None as language for current paragraph
- aURL.Complete+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE");
+ aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE");
}
- else if ( nId==nItemId-2 )
+ else if (nId == MID_LANG_PARA_RESET)
+ {
+ // reset language attributes for paragraph
+ aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES");
+ }
+ else if (nId == MID_LANG_PARA_MORE)
{
- //9 (more) para...
//open the dialog "format/character" for current paragraph
- aURL.Complete+=String::CreateFromAscii(".uno:FontDialogForParagraph");
+ aURL.Complete += OUString::createFromAscii(".uno:FontDialogForParagraph");
}
- uno::Reference< util::XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), uno::UNO_QUERY );
+ uno::Reference< util::XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( OUString::createFromAscii("com.sun.star.util.URLTransformer" )), uno::UNO_QUERY );
xURLTransformer->parseStrict( aURL );
- uno::Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL,::rtl::OUString(),0);
+ uno::Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL, OUString(), 0);
if( xDispatch.is() )
{
uno::Sequence< beans::PropertyValue > aPV;
if(::comphelper::UiEventsLogger::isEnabled()) //#i88653#
- UiEventLogHelper(::rtl::OUString::createFromAscii("ButtonToolbarController")).log(m_xServiceManager, m_xFrame, aURL, aPV);
+ UiEventLogHelper( OUString::createFromAscii("ButtonToolbarController")).log(m_xServiceManager, m_xFrame, aURL, aPV);
xDispatch->dispatch( aURL, aPV);
}
}
@@ -443,6 +386,13 @@ throw (::com::sun::star::uno::RuntimeException)
void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStateEvent& Event )
throw ( RuntimeException )
{
+ // This function will be called when observed data changes,
+ // for example the selection or keyboard language.
+ // - It displays the language in use in the status bar
+ // - and it stores the relevant data for creating the menu
+ // at some later point in the member variables
+ // m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedText
+
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::statusChanged" );
vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
@@ -451,25 +401,22 @@ throw ( RuntimeException )
m_bShowMenu = sal_True;
- m_nScriptType=7;//set the default value
+ m_nScriptType = LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX; //set the default value
Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow );
if ( pWindow && pWindow->GetType() == WINDOW_STATUSBAR && m_nID != 0 )
{
- rtl::OUString aStrValue;
- Sequence< ::rtl::OUString > aSeq;
+ OUString aStrValue;
+ Sequence< OUString > aSeq;
StatusBar* pStatusBar = (StatusBar *)pWindow;
if ( Event.State >>= aStrValue )
- {
pStatusBar->SetItemText( m_nID, aStrValue );
- m_aCurrentLanguage = aStrValue;
- }
else if ( Event.State >>= aSeq )
{
if ( aSeq.getLength() == 4 )
{
const String aMultipleLangText( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) );
- ::rtl::OUString aStatusText = aSeq[0];
+ OUString aStatusText = aSeq[0];
if ( 0 == aStatusText.compareToAscii( "*" ))
aStatusText = aMultipleLangText;
pStatusBar->SetItemText( m_nID, aStatusText );
@@ -479,7 +426,7 @@ throw ( RuntimeException )
m_aCurLang = aSeq[0];
m_nScriptType = static_cast< sal_Int16 >( aSeq[1].toInt32() );
m_aKeyboardLang = aSeq[2];
- m_aGuessedText = aSeq[3];
+ m_aGuessedTextLang = aSeq[3];
}
}
else if ( !Event.State.hasValue() )
diff --git a/framework/util/makefile.mk b/framework/util/makefile.mk
index 55cb3c0aea..6a65b9986f 100644
--- a/framework/util/makefile.mk
+++ b/framework/util/makefile.mk
@@ -113,6 +113,9 @@ SHL1STDLIBS= \
$(UNOTOOLSLIB) \
$(CPPUHELPERLIB) \
$(TOOLSLIB) \
+ $(SVTOOLLIB) \
+ $(SVLLIB) \
+ $(I18NISOLANGLIB) \
$(VOSLIB) \
$(VCLLIB) \
$(TKLIB) \
@@ -205,7 +208,6 @@ SHL3STDLIBS= \
$(SVTOOLLIB) \
$(UNOTOOLSLIB) \
$(TOOLSLIB) \
- $(I18NISOLANGLIB) \
$(COMPHELPERLIB) \
$(CPPUHELPERLIB) \
$(COMPHELPERLIB) \
diff --git a/linguistic/source/convdiclist.cxx b/linguistic/source/convdiclist.cxx
index 4647861b99..9199d43ad9 100644
--- a/linguistic/source/convdiclist.cxx
+++ b/linguistic/source/convdiclist.cxx
@@ -27,6 +27,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_linguistic.hxx"
+
#include <tools/fsys.hxx>
#include <tools/stream.hxx>
#include <tools/urlobj.hxx>
diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx
index de7c14349e..989d0588e4 100644
--- a/linguistic/source/dlistimp.cxx
+++ b/linguistic/source/dlistimp.cxx
@@ -28,6 +28,8 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_linguistic.hxx"
+#include <cppuhelper/factory.hxx>
+#include <i18npool/mslangid.hxx>
#include <osl/file.hxx>
#include <tools/fsys.hxx>
#include <tools/stream.hxx>
@@ -52,6 +54,11 @@
#include "dicimp.hxx"
#include "lngopt.hxx"
+#include "defs.hxx"
+#include "dlistimp.hxx"
+#include "dicimp.hxx"
+#include "lngopt.hxx"
+
//using namespace utl;
using namespace osl;
using namespace rtl;
diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
index 9e0218c45c..1d5dade69b 100755
--- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
@@ -535,7 +535,7 @@
</node>
<node oor:name="F7_MOD1" oor:op="replace">
<prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
- <value xml:lang="en-US">.uno:Thesaurus</value>
+ <value xml:lang="en-US">.uno:ThesaurusDialog</value>
</prop>
</node>
<node oor:name="F7_SHIFT" oor:op="replace">
@@ -1082,7 +1082,7 @@
</node>
<node oor:name="F7_MOD1" oor:op="replace">
<prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
- <value xml:lang="en-US">.uno:Thesaurus</value>
+ <value xml:lang="en-US">.uno:ThesaurusDialog</value>
</prop>
</node>
<node oor:name="F8" oor:op="replace">
@@ -2056,7 +2056,7 @@
</node>
<node oor:name="F7_MOD1" oor:op="replace">
<prop oor:name="Command"><value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
- <value xml:lang="en-US">.uno:Thesaurus</value>
+ <value xml:lang="en-US">.uno:ThesaurusDialog</value>
</prop>
</node>
<node oor:name="F8" oor:op="replace">
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 18e1c66d7d..175867d07d 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -2122,22 +2122,22 @@
<value>1</value>
</prop>
</node>
- <node oor:name=".uno:ChangeCaseToUpper" oor:op="replace">
+ <node oor:name=".uno:LanguageStatus" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Language Status</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:ChooseControls" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
- <value xml:lang="en-US">~Uppercase</value>
+ <value xml:lang="en-US">Insert Controls</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
</prop>
</node>
- <node oor:name=".uno:LanguageStatus" oor:op="replace">
- <prop oor:name="Label" oor:type="xs:string">
- <value xml:lang="en-US">Language Status</value>
- </prop>
- </node>
- <node oor:name=".uno:ChooseControls" oor:op="replace">
+ <node oor:name=".uno:ChangeCaseToSentenceCase" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
- <value xml:lang="en-US">Insert Controls</value>
+ <value xml:lang="en-US">~Sentence case</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
@@ -2145,7 +2145,31 @@
</node>
<node oor:name=".uno:ChangeCaseToLower" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
- <value xml:lang="en-US">~Lowercase</value>
+ <value xml:lang="en-US">~lowercase</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:ChangeCaseToUpper" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">~UPPERCASE</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:ChangeCaseToTitleCase" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">~Capitalize Every Word</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
+ <node oor:name=".uno:ChangeCaseToToggleCase" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">~tOGGLE cASE</value>
</prop>
<prop oor:name="Properties" oor:type="xs:int">
<value>1</value>
@@ -3021,7 +3045,7 @@
<value xml:lang="en-US">New FrameSet</value>
</prop>
</node>
- <node oor:name=".uno:Thesaurus" oor:op="replace">
+ <node oor:name=".uno:ThesaurusDialog" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">~Thesaurus...</value>
</prop>
diff --git a/officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs b/officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs
index 220d94c89d..7cb13b7070 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Linguistic.xcs
@@ -121,6 +121,31 @@
<label>Spell and grammar context menu dictionary image</label>
</info>
</prop>
+ <prop oor:name="ThesaurusDialogImage" oor:type="xs:string">
+ <info>
+ <desc>The path to the image for the thesaurus dialog.</desc>
+ <label>Thesaurus dialog image</label>
+ </info>
+ </prop>
+ <prop oor:name="ThesaurusDialogImage_HC" oor:type="xs:string">
+ <info>
+ <desc>The path to the image for the thesaurus dialog in high contrast mode.</desc>
+ <label>Thesaurus dialog image</label>
+ </info>
+ </prop>
+ <prop oor:name="SynonymsContextMenuImage" oor:type="xs:string">
+ <info>
+ <desc>The path to the image for the synonyms context menu.</desc>
+ <label>Synonyms context menu image</label>
+ </info>
+ </prop>
+ <prop oor:name="SynonymsContextMenuImage_HC" oor:type="xs:string">
+ <info>
+ <desc>The path to the image for the synonyms context menu in high contrast mode.</desc>
+ <label>Synonyms context menu image</label>
+ </info>
+ </prop>
+
</group>
<group oor:name="GrammarCheckerEntry">
diff --git a/sfx2/inc/sfx2/mnumgr.hxx b/sfx2/inc/sfx2/mnumgr.hxx
index b54047b3d5..4221d2b405 100644
--- a/sfx2/inc/sfx2/mnumgr.hxx
+++ b/sfx2/inc/sfx2/mnumgr.hxx
@@ -102,30 +102,44 @@ private:
DECL_LINK( SelectHdl, void * );
Menu* pSVMenu;
-private:
- // only declared, but not defined: don't allow copying
- SfxPopupMenuManager( const SfxPopupMenuManager& );
- SfxPopupMenuManager& operator=( const SfxPopupMenuManager& );
+ // when #i107205 gets fixed this one should be superfluous.
+ // But right now we want to avoid the memory leak that would otherwise occur,
+ // if we don't delete the pointer that got created in SfxPopupMenuManager::Popup
+ static PopupMenu * pStaticThesSubMenu;
+
+ // only declared, but not defined: don't allow copying
+ SfxPopupMenuManager( const SfxPopupMenuManager& );
+ SfxPopupMenuManager& operator=( const SfxPopupMenuManager& );
public:
SfxPopupMenuManager( const ResId&, SfxBindings& );
SfxPopupMenuManager( PopupMenu*, SfxBindings& );
~SfxPopupMenuManager();
static void ExecutePopup( const ResId&, SfxViewFrame* pViewFrame, const Point& rPoint, Window* pWindow );
+ // @deprecated!!
+ // Don't use this method any longer. The whole class will be removed in the future.
+ // Changing code which relies on Popup would need much more effort.
+ // Please contact cd@openoffice.org if you have questions or need help
static SfxPopupMenuManager* Popup( const ResId& rResId, SfxViewFrame* pFrame,const Point& rPoint, Window* pWindow );
USHORT Execute( const Point& rPos, Window *pWindow );
USHORT Execute( const Point& rPoint, Window* pWindow, va_list pArgs, const SfxPoolItem *pArg1 );
USHORT Execute( const Point& rPoint, Window* pWindow, const SfxPoolItem *pArg1 ... );
- void StartInsert();
+ // @deprecated (start)!!
+ // Don't use these methods any longer. The whole class will be removed in the future.
+ // Changing code which relies on these methods would need much more effort!
+ // Please contact cd@openoffice.org if you have questions or need help
+ void StartInsert();
void EndInsert();
void CheckItem( USHORT, BOOL );
void RemoveItem( USHORT );
void InsertItem( USHORT, const String&, MenuItemBits,
USHORT nPos = MENU_APPEND );
void InsertSeparator( USHORT nPos = MENU_APPEND );
- void RemoveDisabledEntries();
+ // @deprecated (end)
+
+ void RemoveDisabledEntries();
void AddClipboardFunctions();
Menu* GetSVMenu();
};
diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc
index 07062e3c0f..846b6c547f 100644
--- a/sfx2/inc/sfx2/sfxsids.hrc
+++ b/sfx2/inc/sfx2/sfxsids.hrc
@@ -477,6 +477,9 @@
#define SID_CAPTION (SID_SFX_START + 641)
#define SID_STATUSBARTEXT (SID_SFX_START + 642)
+// id for thesaurs entry in context menu
+#define SID_THES (SID_SFX_START + 698)
+
// default-ids for editing, cursor travellung and selection
#define SID_REDO (SID_SFX_START + 700)
#define SID_UNDO (SID_SFX_START + 701)
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 283f7d07ce..bfff1068d9 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -8221,3 +8221,29 @@ SfxInt16Item PasteUnformatted SID_PASTE_UNFORMATTED
GroupId = GID_EDIT;
]
+//--------------------------------------------------------------------------
+// call thesaurus dialog from context menu
+SfxInt16Item ThesaurusFromContext SID_THES
+(SfxStringItem WordReplace SID_THES)
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = TRUE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+
+ /* config: */
+ AccelConfig = FALSE,
+ MenuConfig = FALSE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = FALSE,
+ GroupId = GID_TEXT;
+]
+
diff --git a/sfx2/source/menu/makefile.mk b/sfx2/source/menu/makefile.mk
index d3b209fc4a..8b55bd0840 100644
--- a/sfx2/source/menu/makefile.mk
+++ b/sfx2/source/menu/makefile.mk
@@ -43,10 +43,11 @@ SRS1NAME=$(TARGET)
SRC1FILES = menu.src
SLOFILES = \
+ $(SLO)$/mnuitem.obj \
$(SLO)$/mnumgr.obj \
- $(SLO)$/virtmenu.obj \
$(SLO)$/objmnctl.obj \
- $(SLO)$/mnuitem.obj
+ $(SLO)$/thessubmenu.obj \
+ $(SLO)$/virtmenu.obj
# --- Tagets -------------------------------------------------------
diff --git a/sfx2/source/menu/menu.hrc b/sfx2/source/menu/menu.hrc
index 71f5b60507..3b89f474c3 100644
--- a/sfx2/source/menu/menu.hrc
+++ b/sfx2/source/menu/menu.hrc
@@ -64,6 +64,10 @@
#define STR_MENU_ADDONS RID_SFX_MENU_START+2
#define STR_MENU_ADDONHELP RID_SFX_MENU_START+3
+#define STR_MENU_SYNONYMS (RID_SFX_MENU_START+11)
+#define STR_MENU_NO_SYNONYM_FOUND (RID_SFX_MENU_START+12)
+#define STR_MENU_THESAURUS (RID_SFX_MENU_START+13)
+
#define MN_CLIPBOARDFUNCS RID_SFX_MENU_START+1
#endif
diff --git a/sfx2/source/menu/menu.src b/sfx2/source/menu/menu.src
index a84198917d..cf13af67c3 100644
--- a/sfx2/source/menu/menu.src
+++ b/sfx2/source/menu/menu.src
@@ -72,6 +72,21 @@ String STR_MENU_ADDONHELP
Text [ en-US ] = "Add-~On Help" ;
};
+String STR_MENU_SYNONYMS
+{
+ Text [ en-US ] = "Synonyms" ;
+};
+
+String STR_MENU_NO_SYNONYM_FOUND
+{
+ Text [ en-US ] = "(none)" ;
+};
+
+String STR_MENU_THESAURUS
+{
+ Text [ en-US ] = "~Thesaurus..." ;
+};
+
// ******************************************************************* EOF
diff --git a/sfx2/source/menu/mnumgr.cxx b/sfx2/source/menu/mnumgr.cxx
index 0ac68900c4..8269611c97 100644..100755
--- a/sfx2/source/menu/mnumgr.cxx
+++ b/sfx2/source/menu/mnumgr.cxx
@@ -27,8 +27,10 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sfx2.hxx"
+
#include <com/sun/star/embed/VerbDescriptor.hpp>
#include <com/sun/star/embed/VerbAttributes.hpp>
+#include <com/sun/star/container/XNamed.hpp>
#ifdef SOLARIS
// HACK: prevent conflict between STLPORT and Workshop headers on Solaris 8
@@ -50,9 +52,14 @@
#include <framework/addonmenu.hxx>
#include <comphelper/processfactory.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/lingucfg.hxx>
#include <tools/urlobj.hxx>
#include <unotools/pathoptions.hxx>
+#include <svl/stritem.hxx>
#include <toolkit/helper/vclunohelper.hxx>
+#include <osl/file.hxx>
+#include <vcl/graph.hxx>
+#include <svtools/filter.hxx>
#include <sfx2/mnumgr.hxx>
@@ -76,10 +83,15 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/objface.hxx>
+#include "thessubmenu.hxx"
+
static const USHORT nCompatVersion = 4;
static const USHORT nVersion = 5;
+// static member initialization
+PopupMenu * SfxPopupMenuManager::pStaticThesSubMenu = NULL;
+
using namespace com::sun::star;
//=========================================================================
@@ -166,6 +178,101 @@ void InsertVerbs_Impl( SfxBindings* pBindings, const com::sun::star::uno::Sequen
}
+//--------------------------------------------------------------------
+
+
+static Image lcl_GetImageFromPngUrl( const ::rtl::OUString &rFileUrl )
+{
+ Image aRes;
+
+ ::rtl::OUString aTmp;
+ osl::FileBase::getSystemPathFromFileURL( rFileUrl, aTmp );
+
+ Graphic aGraphic;
+ const String aFilterName( RTL_CONSTASCII_USTRINGPARAM( IMP_PNG ) );
+ if( GRFILTER_OK == GraphicFilter::LoadGraphic( aTmp, aFilterName, aGraphic ) )
+ {
+ aRes = Image( aGraphic.GetBitmapEx() );
+ }
+ return aRes;
+}
+
+
+PopupMenu* InsertThesaurusSubmenu_Impl( SfxBindings* pBindings, Menu* pSVMenu )
+{
+ //
+ // build thesaurus sub menu if look-up string is available
+ //
+ PopupMenu* pThesSubMenu = 0;
+ SfxPoolItem *pItem = 0;
+ pBindings->QueryState( SID_THES, pItem );
+ String aThesLookUpStr;
+ SfxStringItem *pStrItem = dynamic_cast< SfxStringItem * >(pItem);
+ xub_StrLen nDelimPos = STRING_LEN;
+ if (pStrItem)
+ {
+ aThesLookUpStr = pStrItem->GetValue();
+ nDelimPos = aThesLookUpStr.SearchBackward( '#' );
+ }
+ if (aThesLookUpStr.Len() > 0 && nDelimPos != STRING_NOTFOUND)
+ {
+ // get synonym list for sub menu
+ std::vector< ::rtl::OUString > aSynonyms;
+ SfxThesSubMenuHelper aHelper;
+ ::rtl::OUString aText( aHelper.GetText( aThesLookUpStr, nDelimPos ) );
+ lang::Locale aLocale;
+ aHelper.GetLocale( aLocale, aThesLookUpStr, nDelimPos );
+ const bool bHasMoreSynonyms = aHelper.GetMeanings( aSynonyms, aText, aLocale, 7 /*max number of synonyms to retrieve*/ );
+ (void) bHasMoreSynonyms;
+
+ pThesSubMenu = new PopupMenu;
+ pThesSubMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
+ const size_t nNumSynonyms = aSynonyms.size();
+ if (nNumSynonyms > 0)
+ {
+ SvtLinguConfig aCfg;
+ const bool bHC = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ Image aImage;
+ String sThesImplName( aHelper.GetThesImplName( aLocale ) );
+ ::rtl::OUString aSynonymsImageUrl( aCfg.GetSynonymsContextImage( sThesImplName, bHC ) );
+ if (sThesImplName.Len() > 0 && aSynonymsImageUrl.getLength() > 0)
+ aImage = Image( lcl_GetImageFromPngUrl( aSynonymsImageUrl ) );
+
+ for (USHORT i = 0; (size_t)i < nNumSynonyms; ++i)
+ {
+ //! item ids should start with values > 0, since 0 has special meaning
+ const USHORT nId = i + 1;
+
+ String aItemText( GetThesaurusReplaceText_Impl( aSynonyms[i] ) );
+ pThesSubMenu->InsertItem( nId, aItemText );
+ ::rtl::OUString aCmd( ::rtl::OUString::createFromAscii( ".uno:ThesaurusFromContext?WordReplace:string=" ) );
+ aCmd += aItemText;
+ pThesSubMenu->SetItemCommand( nId, aCmd );
+
+ if (aSynonymsImageUrl.getLength() > 0)
+ pThesSubMenu->SetItemImage( nId, aImage );
+ }
+ }
+ else // nNumSynonyms == 0
+ {
+ const String aItemText( SfxResId( STR_MENU_NO_SYNONYM_FOUND ) );
+ pThesSubMenu->InsertItem( 1, aItemText, MIB_NOSELECT );
+ }
+ pThesSubMenu->InsertSeparator();
+ const String sThesaurus( SfxResId( STR_MENU_THESAURUS ) );
+ pThesSubMenu->InsertItem( 100, sThesaurus );
+ pThesSubMenu->SetItemCommand( 100, ::rtl::OUString::createFromAscii( ".uno:ThesaurusDialog" ) );
+
+ pSVMenu->InsertSeparator();
+ const String sSynonyms( SfxResId( STR_MENU_SYNONYMS ) );
+ pSVMenu->InsertItem( SID_THES, sSynonyms );
+ pSVMenu->SetPopupMenu( SID_THES, pThesSubMenu );
+ }
+
+ return pThesSubMenu;
+}
+
//--------------------------------------------------------------------
@@ -305,7 +412,9 @@ void SfxPopupMenuManager::RemoveDisabledEntries()
USHORT SfxPopupMenuManager::Execute( const Point& rPos, Window* pWindow )
{
DBG_MEMTEST();
- return ( (PopupMenu*) GetMenu()->GetSVMenu() )->Execute( pWindow, rPos );
+ USHORT nVal = ( (PopupMenu*) GetMenu()->GetSVMenu() )->Execute( pWindow, rPos );
+ delete pStaticThesSubMenu; pStaticThesSubMenu = NULL;
+ return nVal;
}
//--------------------------------------------------------------------
@@ -429,6 +538,10 @@ SfxPopupMenuManager* SfxPopupMenuManager::Popup( const ResId& rResId, SfxViewFra
break;
}
+ PopupMenu* pThesSubMenu = InsertThesaurusSubmenu_Impl( &pFrame->GetBindings(), pSVMenu );
+ // #i107205# (see comment in header file)
+ pStaticThesSubMenu = pThesSubMenu;
+
if ( n == nCount )
{
PopupMenu aPop( SfxResId( MN_CLIPBOARDFUNCS ) );
@@ -461,6 +574,7 @@ SfxPopupMenuManager* SfxPopupMenuManager::Popup( const ResId& rResId, SfxViewFra
aMgr->RemoveDisabledEntries();
return aMgr;
}
+
return 0;
}
@@ -475,6 +589,8 @@ void SfxPopupMenuManager::ExecutePopup( const ResId& rResId, SfxViewFrame* pFram
break;
}
+ PopupMenu* pThesSubMenu = InsertThesaurusSubmenu_Impl( &pFrame->GetBindings(), pSVMenu );
+
if ( n == nCount )
{
PopupMenu aPop( SfxResId( MN_CLIPBOARDFUNCS ) );
@@ -507,6 +623,8 @@ void SfxPopupMenuManager::ExecutePopup( const ResId& rResId, SfxViewFrame* pFram
aPop.RemoveDisabledEntries();
aPop.Execute( rPoint, pWindow );
}
+
+ delete pThesSubMenu;
}
Menu* SfxPopupMenuManager::GetSVMenu()
diff --git a/sfx2/source/menu/thessubmenu.cxx b/sfx2/source/menu/thessubmenu.cxx
new file mode 100755
index 0000000000..a47e1b18a4
--- /dev/null
+++ b/sfx2/source/menu/thessubmenu.cxx
@@ -0,0 +1,274 @@
+/*************************************************************************
+ *
+ * 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: thessubmenu.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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_sfx2.hxx"
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/linguistic2/XMeaning.hpp>
+#include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <svl/stritem.hxx>
+#include <tools/debug.hxx>
+#include <vcl/graph.hxx>
+#include <svtools/filter.hxx>
+
+
+#include <vector>
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewsh.hxx>
+#include "thessubmenu.hxx"
+
+
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+
+
+// STATIC DATA -----------------------------------------------------------
+
+SFX_IMPL_MENU_CONTROL(SfxThesSubMenuControl, SfxStringItem);
+
+////////////////////////////////////////////////////////////
+
+String GetThesaurusReplaceText_Impl( const ::rtl::OUString &rText )
+{
+ // The strings returned by the thesaurus sometimes have some
+ // explanation text put in between '(' and ')' or a trailing '*'.
+ // These parts should not be put in the ReplaceEdit Text that may get
+ // inserted into the document. Thus we strip them from the text.
+
+ String aText( rText );
+
+ xub_StrLen nPos = aText.Search( sal_Unicode('(') );
+ while (STRING_NOTFOUND != nPos)
+ {
+ xub_StrLen nEnd = aText.Search( sal_Unicode(')'), nPos );
+ if (STRING_NOTFOUND != nEnd)
+ aText.Erase( nPos, nEnd-nPos+1 );
+ else
+ break;
+ nPos = aText.Search( sal_Unicode('(') );
+ }
+
+ nPos = aText.Search( sal_Unicode('*') );
+ if (STRING_NOTFOUND != nPos)
+ aText.Erase( nPos );
+
+ // remove any possible remaining ' ' that may confuse the thesaurus
+ // when it gets called with the text
+ aText.EraseLeadingAndTrailingChars( sal_Unicode(' ') );
+
+ return aText;
+}
+
+////////////////////////////////////////////////////////////
+
+
+/*
+ Ctor; setzt Select-Handler am Menu und traegt Menu
+ in seinen Parent ein.
+ */
+SfxThesSubMenuControl::SfxThesSubMenuControl( USHORT nSlotId, Menu &rMenu, SfxBindings &rBindings )
+ : SfxMenuControl( nSlotId, rBindings ),
+ pMenu(new PopupMenu),
+ rParent(rMenu)
+{
+ rMenu.SetPopupMenu(nSlotId, pMenu);
+ pMenu->SetSelectHdl(LINK(this, SfxThesSubMenuControl, MenuSelect));
+ pMenu->Clear();
+ rParent.EnableItem( GetId(), FALSE );
+}
+
+
+SfxThesSubMenuControl::~SfxThesSubMenuControl()
+{
+ delete pMenu;
+}
+
+
+/*
+ Statusbenachrichtigung;
+ Ist die Funktionalit"at disabled, wird der entsprechende
+ Menueeintrag im Parentmenu disabled, andernfalls wird er enabled.
+ */
+void SfxThesSubMenuControl::StateChanged(
+ USHORT /*nSID*/,
+ SfxItemState eState,
+ const SfxPoolItem* /*pState*/ )
+{
+ rParent.EnableItem(GetId(), SFX_ITEM_AVAILABLE == eState );
+}
+
+
+/*
+ Select-Handler des Menus;
+ das selektierte Verb mit ausgef"uhrt,
+ */
+IMPL_LINK_INLINE_START( SfxThesSubMenuControl, MenuSelect, Menu *, pSelMenu )
+{
+ const USHORT nSlotId = pSelMenu->GetCurItemId();
+ if( nSlotId )
+ GetBindings().Execute(nSlotId);
+ return 1;
+}
+IMPL_LINK_INLINE_END( SfxThesSubMenuControl, MenuSelect, Menu *, pSelMenu )
+
+
+PopupMenu* SfxThesSubMenuControl::GetPopup() const
+{
+ return pMenu;
+}
+
+
+////////////////////////////////////////////////////////////
+
+OUString SfxThesSubMenuHelper::GetText(
+ const String &rLookUpString,
+ xub_StrLen nDelimPos )
+{
+ return OUString( rLookUpString.Copy( 0, nDelimPos ) );
+}
+
+
+void SfxThesSubMenuHelper::GetLocale(
+ lang::Locale /*out */ &rLocale,
+ const String &rLookUpString,
+ xub_StrLen nDelimPos )
+{
+ String aIsoLang( rLookUpString.Copy( nDelimPos + 1) );
+ const xub_StrLen nPos = aIsoLang.Search( '-' );
+ if (nPos != STRING_NOTFOUND)
+ {
+ rLocale.Language = aIsoLang.Copy( 0, nPos );
+ rLocale.Country = aIsoLang.Copy( nPos + 1 );
+ rLocale.Variant = String::EmptyString();
+ }
+}
+
+
+SfxThesSubMenuHelper::SfxThesSubMenuHelper()
+{
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ m_xLngMgr = uno::Reference< linguistic2::XLinguServiceManager >( xMSF->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.linguistic2.LinguServiceManager" ))), uno::UNO_QUERY_THROW );
+ m_xThesarus = m_xLngMgr->getThesaurus();
+ }
+ catch (uno::Exception &e)
+ {
+ (void) e;
+ DBG_ASSERT( 0, "failed to get thesaurus" );
+ }
+}
+
+
+SfxThesSubMenuHelper::~SfxThesSubMenuHelper()
+{
+}
+
+
+bool SfxThesSubMenuHelper::IsSupportedLocale( const lang::Locale & rLocale ) const
+{
+ return m_xThesarus.is() && m_xThesarus->hasLocale( rLocale );
+}
+
+
+bool SfxThesSubMenuHelper::GetMeanings(
+ std::vector< OUString > & rSynonyms,
+ const OUString & rWord,
+ const lang::Locale & rLocale,
+ sal_Int16 nMaxSynonms )
+{
+ bool bHasMoreSynonyms = false;
+ rSynonyms.clear();
+ if (IsSupportedLocale( rLocale ) && rWord.getLength() && nMaxSynonms > 0)
+ {
+ try
+ {
+ // get all meannings
+ const uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeaningSeq(
+ m_xThesarus->queryMeanings( rWord, rLocale, uno::Sequence< beans::PropertyValue >() ));
+ const uno::Reference< linguistic2::XMeaning > *pxMeaning = aMeaningSeq.getConstArray();
+ const sal_Int32 nMeanings = aMeaningSeq.getLength();
+
+ // iterate over all meanings until nMaxSynonms are found or all meanings are processed
+ sal_Int32 nCount = 0;
+ sal_Int32 i = 0;
+ for ( ; i < nMeanings && nCount < nMaxSynonms; ++i)
+ {
+ const uno::Sequence< OUString > aSynonymSeq( pxMeaning[i]->querySynonyms() );
+ const OUString *pSynonyms = aSynonymSeq.getConstArray();
+ const sal_Int32 nSynonyms = aSynonymSeq.getLength();
+ sal_Int32 k = 0;
+ for ( ; k < nSynonyms && nCount < nMaxSynonms; ++k)
+ {
+ rSynonyms.push_back( pSynonyms[k] );
+ ++nCount;
+ }
+ bHasMoreSynonyms = k < nSynonyms; // any synonym from this meaning skipped?
+ }
+
+ bHasMoreSynonyms |= i < nMeanings; // any meaning skipped?
+ }
+ catch (uno::Exception &e)
+ {
+ (void) e;
+ DBG_ASSERT( 0, "failed to get synonyms" );
+ }
+ }
+ return bHasMoreSynonyms;
+}
+
+
+String SfxThesSubMenuHelper::GetThesImplName( const lang::Locale &rLocale ) const
+{
+ String aRes;
+ DBG_ASSERT( m_xLngMgr.is(), "LinguServiceManager missing" );
+ if (m_xLngMgr.is())
+ {
+ uno::Sequence< OUString > aServiceNames = m_xLngMgr->getConfiguredServices(
+ OUString::createFromAscii("com.sun.star.linguistic2.Thesaurus"), rLocale );
+ // there should be at most one thesaurus configured for each language
+ DBG_ASSERT( aServiceNames.getLength() <= 1, "more than one thesaurus found. Should not be possible" );
+ if (aServiceNames.getLength() == 1)
+ aRes = aServiceNames[0];
+ }
+ return aRes;
+}
+
+////////////////////////////////////////////////////////////
+
+
diff --git a/sfx2/source/menu/thessubmenu.hxx b/sfx2/source/menu/thessubmenu.hxx
new file mode 100644
index 0000000000..13438a917a
--- /dev/null
+++ b/sfx2/source/menu/thessubmenu.hxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * 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: thessubmenu.hxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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 _THESSUBMENU_HXX_
+#define _THESSUBMENU_HXX_
+
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
+
+#include <vcl/menu.hxx>
+#include <sfx2/mnuitem.hxx>
+
+class SfxBindings;
+class PopupMenu;
+class Menu;
+
+namespace css = ::com::sun::star;
+
+////////////////////////////////////////////////////////////
+
+String GetThesaurusReplaceText_Impl( const ::rtl::OUString &rText );
+
+////////////////////////////////////////////////////////////
+
+class SfxThesSubMenuControl : public SfxMenuControl
+{
+ PopupMenu* pMenu;
+ Menu& rParent;
+
+private:
+ virtual void StateChanged( USHORT, SfxItemState, const SfxPoolItem* pState );
+ DECL_LINK( MenuSelect, Menu * );
+
+public:
+ SfxThesSubMenuControl(USHORT, Menu&, SfxBindings&);
+ ~SfxThesSubMenuControl();
+
+ virtual PopupMenu* GetPopup() const;
+
+ SFX_DECL_MENU_CONTROL();
+};
+
+////////////////////////////////////////////////////////////
+
+class SfxThesSubMenuHelper
+{
+ css::uno::Reference< css::linguistic2::XLinguServiceManager > m_xLngMgr;
+ css::uno::Reference< css::linguistic2::XThesaurus > m_xThesarus;
+
+private:
+
+ // don't use copy c-tor and assignment operator
+ SfxThesSubMenuHelper( const SfxThesSubMenuHelper & );
+ SfxThesSubMenuHelper & operator = ( const SfxThesSubMenuHelper & );
+
+public:
+ SfxThesSubMenuHelper();
+ ~SfxThesSubMenuHelper();
+
+ static ::rtl::OUString GetText( const String &rLookUpString, xub_StrLen nDelimPos );
+
+ // returns the Locale to be used for the selected text when the thesaurus is to be called
+ static void GetLocale( css::lang::Locale /*out */ &rLocale, const String &rLookUpString, xub_StrLen nDelimPos );
+
+ // returns true if the locale is upported by the theasaurus
+ bool IsSupportedLocale( const css::lang::Locale & rLocale ) const;
+
+ // get the first nMax Synonym entries, even if different meanings need to be evaluated
+ bool GetMeanings( std::vector< ::rtl::OUString > & rSynonyms, const ::rtl::OUString & rWord, const css::lang::Locale & rLocale, sal_Int16 nMaxSynonms );
+
+ String GetThesImplName( const css::lang::Locale &rLocale ) const;
+};
+
+////////////////////////////////////////////////////////////
+
+
+#endif
+
+
diff --git a/svx/inc/globlmn_tmpl.hrc b/svx/inc/globlmn_tmpl.hrc
index 41d0d42bdf..22dc0b1772 100644
--- a/svx/inc/globlmn_tmpl.hrc
+++ b/svx/inc/globlmn_tmpl.hrc
@@ -1332,17 +1332,38 @@
{\
MenuItem\
{\
- Identifier = SID_TRANSLITERATE_UPPER ; \
- Command = ".uno:ChangeCaseToUpper" ; \
- HelpID = SID_TRANSLITERATE_UPPER ; \
- Text [ en-US ] = "~Uppercase";\
+ Identifier = SID_TRANSLITERATE_SENTENCE_CASE; \
+ Command = ".uno:ChangeCaseToSentenceCase" ; \
+ HelpID = SID_TRANSLITERATE_SENTENCE_CASE; \
+ Text [ en-US ] = "~Sentence case";\
};\
MenuItem\
{\
Identifier = SID_TRANSLITERATE_LOWER; \
Command = ".uno:ChangeCaseToLower" ; \
HelpID = SID_TRANSLITERATE_LOWER; \
- Text [ en-US ] = "~Lowercase";\
+ Text [ en-US ] = "~lowercase";\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_TRANSLITERATE_UPPER ; \
+ Command = ".uno:ChangeCaseToUpper" ; \
+ HelpID = SID_TRANSLITERATE_UPPER ; \
+ Text [ en-US ] = "~UPPERCASE";\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_TRANSLITERATE_TITLE_CASE; \
+ Command = ".uno:ChangeCaseToTitleCase" ; \
+ HelpID = SID_TRANSLITERATE_TITLE_CASE; \
+ Text [ en-US ] = "~Capitalize Every Word";\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_TRANSLITERATE_TOGGLE_CASE; \
+ Command = ".uno:ChangeCaseToToggleCase" ; \
+ HelpID = SID_TRANSLITERATE_TOGGLE_CASE; \
+ Text [ en-US ] = "~tOGGLE cASE";\
};\
MenuItem\
{\
diff --git a/svx/inc/helpid.hrc b/svx/inc/helpid.hrc
index a183735b6c..29899ed5ae 100644
--- a/svx/inc/helpid.hrc
+++ b/svx/inc/helpid.hrc
@@ -278,6 +278,7 @@
#define HID_SVX_SENDMENU_SIGNANDENCRYPT (HID_SVX_START + 245)
#define HID_SVX_TP_APPEARANCE (HID_SVX_START + 246)
#define HID_SVX_TP_DESKTOP (HID_SVX_START + 247)
+#define HID_CT_THES_ALTERNATIVES (HID_SVX_START + 248)
// please adjust ACT_SVX_HID_END2 below if you add entries here!
@@ -285,7 +286,7 @@
// Overrun check ---------------------------------------------------------
// -----------------------------------------------------------------------
-#define ACT_SVX_HID_END (HID_SVX_START+247)
+#define ACT_SVX_HID_END (HID_SVX_START+248)
#if ACT_SVX_HID_END > HID_SVX_END
#error Resource-Ueberlauf in #line, #file
#endif
diff --git a/svx/inc/svx/dialogs.hrc b/svx/inc/svx/dialogs.hrc
index eb304d09f3..eb304d09f3 100644..100755
--- a/svx/inc/svx/dialogs.hrc
+++ b/svx/inc/svx/dialogs.hrc
diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc
index 0996b4291d..7c67690256 100644
--- a/svx/inc/svx/svxids.hrc
+++ b/svx/inc/svx/svxids.hrc
@@ -383,6 +383,7 @@
#define FN_INSERT_HARD_SPACE (FN_INSERT + 44) /* hard space */
#define FN_INSERT_HARDHYPHEN (FN_INSERT + 85) /* hyphen withou break*/
+//!! be aware to not overwrite something that is used in sw/inc/cmdid.h already !!
#define FN_FORMAT (SID_SW_START + 400)
#define FN_SET_JUSTIFY_PARA (FN_FORMAT + 21)
#define FN_FORMAT_RESET (FN_FORMAT + 69)
@@ -1239,6 +1240,7 @@
#define SID_TABLE_STYLE_SETTINGS (SID_SVX_START+1089)
#define SID_CHAR_DLG_PREVIEW_STRING (SID_SVX_START+1090)
#define SID_RECHECK_DOCUMENT (SID_SVX_START+1091)
+
#define SID_OBJECT_MIRROR (SID_SVX_START+1093)
#define SID_DELETE_POSTIT (SID_SVX_START+1094)
@@ -1250,8 +1252,12 @@
#define SID_DELETEALLBYAUTHOR_POSTIT (SID_SVX_START+1100)
#define SID_INSERT_POSTIT (SID_SVX_START+1101)
+#define SID_TRANSLITERATE_SENTENCE_CASE (SID_SVX_START+1102)
+#define SID_TRANSLITERATE_TITLE_CASE (SID_SVX_START+1103)
+#define SID_TRANSLITERATE_TOGGLE_CASE (SID_SVX_START+1104)
+
// IMPORTANT NOTE: adjust SID_SVX_FIRSTFREE, when adding new slot id
-#define SID_SVX_FIRSTFREE SID_INSERT_POSTIT + 1
+#define SID_SVX_FIRSTFREE (SID_TRANSLITERATE_TOGGLE_CASE + 1)
// --------------------------------------------------------------------------
// Overflow check for slot IDs
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index ecd6fcd930..c5069ad2eb 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -1455,6 +1455,81 @@ SfxVoidItem ChangeCaseToKatakana SID_TRANSLITERATE_KATAGANA
]
//--------------------------------------------------------------------------
+SfxVoidItem ChangeCaseToSentenceCase SID_TRANSLITERATE_SENTENCE_CASE
+()
+[
+ /* flags: */
+ AutoUpdate = TRUE,
+ Cachable = Cachable,
+ FastCall = TRUE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Asynchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_FORMAT;
+]
+
+//--------------------------------------------------------------------------
+SfxVoidItem ChangeCaseToTitleCase SID_TRANSLITERATE_TITLE_CASE
+()
+[
+ /* flags: */
+ AutoUpdate = TRUE,
+ Cachable = Cachable,
+ FastCall = TRUE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Asynchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_FORMAT;
+]
+
+//--------------------------------------------------------------------------
+SfxVoidItem ChangeCaseToToggleCase SID_TRANSLITERATE_TOGGLE_CASE
+()
+[
+ /* flags: */
+ AutoUpdate = TRUE,
+ Cachable = Cachable,
+ FastCall = TRUE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Asynchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_FORMAT;
+]
+
+//--------------------------------------------------------------------------
SfxVoidItem ChangeCaseToLower SID_TRANSLITERATE_LOWER
()
[
@@ -10834,7 +10909,7 @@ SdrTextFitToSizeTypeItem TextFitToSize SID_ATTR_TEXT_FITTOSIZE
]
//--------------------------------------------------------------------------
-SfxVoidItem Thesaurus SID_THESAURUS
+SfxVoidItem ThesaurusDialog SID_THESAURUS
()
[
/* flags: */
@@ -10843,7 +10918,7 @@ SfxVoidItem Thesaurus SID_THESAURUS
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = TRUE,
- ReadOnlyDoc = TRUE,
+ ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
diff --git a/svx/source/dialog/makefile.mk b/svx/source/dialog/makefile.mk
index 01951caa14..ac608fae8e 100644
--- a/svx/source/dialog/makefile.mk
+++ b/svx/source/dialog/makefile.mk
@@ -74,6 +74,7 @@ SRC2FILES = \
LIB1TARGET=$(SLB)$/$(TARGET)-core.lib
LIB1OBJFILES= \
+ $(SLO)$/checklbx.obj \
$(SLO)$/dialmgr.obj\
$(SLO)$/dlgutil.obj \
$(SLO)$/framelink.obj\
@@ -86,7 +87,6 @@ LIB2TARGET=$(SLB)$/$(TARGET).lib
LIB2OBJFILES= \
$(SLO)$/charmap.obj \
- $(SLO)$/checklbx.obj \
$(SLO)$/connctrl.obj \
$(SLO)$/contwnd.obj \
$(SLO)$/ctredlin.obj \