Kaydet (Commit) 6db709ba authored tarafından Henry Castro's avatar Henry Castro

sc, sd: rework UI Text Language "More" button, tdf#113911

Calc and Impress handle different uno command to set language

Change-Id: Ic0ffef6a8fee5078b29873934001819a384c8f3a
Reviewed-on: https://gerrit.libreoffice.org/45366Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarHenry Castro <hcastro@collabora.com>
üst d3440e0e
...@@ -58,6 +58,9 @@ enum LangMenuIDs ...@@ -58,6 +58,9 @@ enum LangMenuIDs
MID_LANG_SEL_NONE, MID_LANG_SEL_NONE,
MID_LANG_SEL_RESET, MID_LANG_SEL_RESET,
MID_LANG_SEL_MORE, MID_LANG_SEL_MORE,
MID_LANG_DEF_NONE,
MID_LANG_DEF_RESET,
MID_LANG_DEF_MORE,
MID_LANG_PARA_SEPARATOR, MID_LANG_PARA_SEPARATOR,
MID_LANG_PARA_STRING, MID_LANG_PARA_STRING,
......
...@@ -128,6 +128,7 @@ void LangSelectionStatusbarController::LangMenu( ...@@ -128,6 +128,7 @@ void LangSelectionStatusbarController::LangMenu(
if (!m_bShowMenu) if (!m_bShowMenu)
return; return;
const Reference<XModuleManager> xModuleManager = ModuleManager::create( m_xContext );
//add context menu //add context menu
Reference< awt::XPopupMenu > xPopupMenu( awt::PopupMenu::create( m_xContext ) ); Reference< awt::XPopupMenu > xPopupMenu( awt::PopupMenu::create( m_xContext ) );
//sub menu that contains all items except the last two items: Separator + Set Language for Paragraph //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph
...@@ -164,36 +165,65 @@ void LangSelectionStatusbarController::LangMenu( ...@@ -164,36 +165,65 @@ void LangSelectionStatusbarController::LangMenu(
} }
} }
xPopupMenu->insertItem( MID_LANG_SEL_NONE, FwkResId(STR_LANGSTATUS_NONE), 0, MID_LANG_SEL_NONE );
if ( sNone == m_aCurLang )
xPopupMenu->checkItem( MID_LANG_SEL_NONE, true );
xPopupMenu->insertItem( MID_LANG_SEL_RESET, FwkResId(STR_RESET_TO_DEFAULT_LANGUAGE), 0, MID_LANG_SEL_RESET );
xPopupMenu->insertItem( MID_LANG_SEL_MORE, FwkResId(STR_LANGSTATUS_MORE), 0, MID_LANG_SEL_MORE );
// add entries to submenu ('set language for paragraph') if (xModuleManager->identify(m_xFrame) == "com.sun.star.text.TextDocument")
nItemId = static_cast< sal_Int16 >(MID_LANG_PARA_1);
for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
{ {
const OUString & rStr( *it ); xPopupMenu->insertItem( MID_LANG_SEL_NONE, FwkResId(STR_LANGSTATUS_NONE), 0, MID_LANG_SEL_NONE );
if( rStr != sNone && if ( sNone == m_aCurLang )
rStr != sAsterisk && xPopupMenu->checkItem( MID_LANG_SEL_NONE, true );
!rStr.isEmpty()) // 'no language found' from language guessing xPopupMenu->insertItem( MID_LANG_SEL_RESET, FwkResId(STR_RESET_TO_DEFAULT_LANGUAGE), 0, MID_LANG_SEL_RESET );
xPopupMenu->insertItem( MID_LANG_SEL_MORE, FwkResId(STR_LANGSTATUS_MORE), 0, 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)
{ {
SAL_WARN_IF( MID_LANG_PARA_1 > nItemId || nItemId > MID_LANG_PARA_9, const OUString & rStr( *it );
"fwk.uielement", "nItemId outside of expected range!" ); if( rStr != sNone &&
subPopupMenu->insertItem( nItemId, rStr, 0, nItemId ); rStr != sAsterisk &&
aLangMap[nItemId] = rStr; !rStr.isEmpty()) // 'no language found' from language guessing
++nItemId; {
SAL_WARN_IF( MID_LANG_PARA_1 > nItemId || nItemId > MID_LANG_PARA_9,
"fwk.uielement", "nItemId outside of expected range!" );
subPopupMenu->insertItem( nItemId, rStr, 0, nItemId );
aLangMap[nItemId] = rStr;
++nItemId;
}
} }
}
subPopupMenu->insertItem( MID_LANG_PARA_NONE, FwkResId(STR_LANGSTATUS_NONE), 0, MID_LANG_PARA_NONE );
subPopupMenu->insertItem( MID_LANG_PARA_RESET, FwkResId(STR_RESET_TO_DEFAULT_LANGUAGE), 0, MID_LANG_PARA_RESET );
subPopupMenu->insertItem( MID_LANG_PARA_MORE, FwkResId(STR_LANGSTATUS_MORE), 0, MID_LANG_PARA_MORE );
// add last two entries to main menu // add entries to submenu ('set language for paragraph')
xPopupMenu->insertSeparator( MID_LANG_PARA_SEPARATOR ); nItemId = static_cast< sal_Int16 >(MID_LANG_PARA_1);
xPopupMenu->insertItem( MID_LANG_PARA_STRING, FwkResId(STR_SET_LANGUAGE_FOR_PARAGRAPH), 0, MID_LANG_PARA_STRING ); for (it = aLangItems.begin(); it != aLangItems.end(); ++it)
xPopupMenu->setPopupMenu( MID_LANG_PARA_STRING, subPopupMenu ); {
const OUString & rStr( *it );
if( rStr != sNone &&
rStr != sAsterisk &&
!rStr.isEmpty()) // 'no language found' from language guessing
{
SAL_WARN_IF( MID_LANG_PARA_1 > nItemId || nItemId > MID_LANG_PARA_9,
"fwk.uielement", "nItemId outside of expected range!" );
subPopupMenu->insertItem( nItemId, rStr, 0, nItemId );
aLangMap[nItemId] = rStr;
++nItemId;
}
}
subPopupMenu->insertItem( MID_LANG_PARA_NONE, FwkResId(STR_LANGSTATUS_NONE), 0, MID_LANG_PARA_NONE );
subPopupMenu->insertItem( MID_LANG_PARA_RESET, FwkResId(STR_RESET_TO_DEFAULT_LANGUAGE), 0, MID_LANG_PARA_RESET );
subPopupMenu->insertItem( MID_LANG_PARA_MORE, FwkResId(STR_LANGSTATUS_MORE), 0, MID_LANG_PARA_MORE );
// add last two entries to main menu
xPopupMenu->insertSeparator( MID_LANG_PARA_SEPARATOR );
xPopupMenu->insertItem( MID_LANG_PARA_STRING, FwkResId(STR_SET_LANGUAGE_FOR_PARAGRAPH), 0, MID_LANG_PARA_STRING );
xPopupMenu->setPopupMenu( MID_LANG_PARA_STRING, subPopupMenu );
}
else
{
xPopupMenu->insertItem( MID_LANG_DEF_NONE, FwkResId(STR_LANGSTATUS_NONE), 0, MID_LANG_DEF_NONE );
if ( sNone == m_aCurLang )
xPopupMenu->checkItem( MID_LANG_DEF_NONE, true );
xPopupMenu->insertItem( MID_LANG_DEF_RESET, FwkResId(STR_RESET_TO_DEFAULT_LANGUAGE), 0, MID_LANG_DEF_RESET );
xPopupMenu->insertItem( MID_LANG_DEF_MORE, FwkResId(STR_LANGSTATUS_MORE), 0, MID_LANG_DEF_MORE );
}
// now display the popup menu and execute every command ... // now display the popup menu and execute every command ...
...@@ -209,7 +239,10 @@ void LangSelectionStatusbarController::LangMenu( ...@@ -209,7 +239,10 @@ void LangSelectionStatusbarController::LangMenu(
if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9) if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9)
{ {
aBuff.append( ".uno:LanguageStatus?Language:string=Current_" ); if ( xModuleManager->identify(m_xFrame) == "com.sun.star.text.TextDocument" )
aBuff.append( ".uno:LanguageStatus?Language:string=Current_" );
else
aBuff.append( ".uno:LanguageStatus?Language:string=Default_" );
aBuff.append( aSelectedLang ); aBuff.append( aSelectedLang );
} }
else if (nId == MID_LANG_SEL_NONE) else if (nId == MID_LANG_SEL_NONE)
...@@ -227,6 +260,18 @@ void LangSelectionStatusbarController::LangMenu( ...@@ -227,6 +260,18 @@ void LangSelectionStatusbarController::LangMenu(
//open the dialog "format/character" for current selection //open the dialog "format/character" for current selection
aBuff.append( ".uno:FontDialog?Page:string=font" ); aBuff.append( ".uno:FontDialog?Page:string=font" );
} }
else if (nId == MID_LANG_DEF_NONE)
{
aBuff.append( ".uno:LanguageStatus?Language:string=Default_LANGUAGE_NONE" );
}
else if (nId == MID_LANG_DEF_RESET)
{
aBuff.append( ".uno:LanguageStatus?Language:string=Default_RESET_LANGUAGES" );
}
else if (nId == MID_LANG_DEF_MORE)
{
aBuff.append( ".uno:LanguageStatus?Language:string=*" );
}
else if (MID_LANG_PARA_1 <= nId && nId <= MID_LANG_PARA_9) else if (MID_LANG_PARA_1 <= nId && nId <= MID_LANG_PARA_9)
{ {
aBuff.append( ".uno:LanguageStatus?Language:string=Paragraph_" ); aBuff.append( ".uno:LanguageStatus?Language:string=Paragraph_" );
...@@ -286,8 +331,7 @@ void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStat ...@@ -286,8 +331,7 @@ void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStat
if ( m_bDisposed ) if ( m_bDisposed )
return; return;
const Reference<XModuleManager> xModuleManager = ModuleManager::create( m_xContext ); m_bShowMenu = true;
m_bShowMenu = xModuleManager->identify(m_xFrame) == "com.sun.star.text.TextDocument";
m_nScriptType = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX; //set the default value m_nScriptType = SvtScriptType::LATIN | SvtScriptType::ASIAN | SvtScriptType::COMPLEX; //set the default value
if ( m_xStatusbarItem.is() ) if ( m_xStatusbarItem.is() )
...@@ -296,7 +340,10 @@ void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStat ...@@ -296,7 +340,10 @@ void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStat
Sequence< OUString > aSeq; Sequence< OUString > aSeq;
if ( Event.State >>= aStrValue ) if ( Event.State >>= aStrValue )
{
m_xStatusbarItem->setText( aStrValue ); m_xStatusbarItem->setText( aStrValue );
m_aCurLang = aStrValue;
}
else if ( Event.State >>= aSeq ) else if ( Event.State >>= aSeq )
{ {
if ( aSeq.getLength() == 4 ) if ( aSeq.getLength() == 4 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment