summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuthu Subramanian <sumuthu@collabora.com>2014-04-23 22:41:11 +0530
committerMuthu Subramanian <sumuthu@collabora.com>2014-04-23 22:41:11 +0530
commitb80dc0ed7be65c448c7a286454c4304120b4c20e (patch)
treea9f9f019ed2f21bbb40a518c32a432281965aa3b
parent9c340d46b457cb54700cd2e8ccaab7001ee42b27 (diff)
fdo#64047: n#863021: Add set-all language menu.
Problems: * Doesn't reset the spell error markers * Modifies only at object level * Currently has only setting for 'all text' * Maybe provide a current slide only option? Change-Id: Idcf8555bab9a5618362dfd2aa8773dd736cbdbb0
-rw-r--r--sd/sdi/_docsh.sdi15
-rw-r--r--sd/source/ui/docshell/docshel3.cxx114
-rw-r--r--sd/source/ui/docshell/docshell.cxx6
-rw-r--r--sd/uiconfig/sdraw/menubar/menubar.xml2
-rw-r--r--sd/uiconfig/simpress/menubar/menubar.xml2
5 files changed, 134 insertions, 5 deletions
diff --git a/sd/sdi/_docsh.sdi b/sd/sdi/_docsh.sdi
index 075b60a96c2c..b08772302161 100644
--- a/sd/sdi/_docsh.sdi
+++ b/sd/sdi/_docsh.sdi
@@ -32,11 +32,16 @@ interface DrawDocument
ExecMethod = Execute ;
StateMethod = GetState ;
]
- SID_CHINESE_CONVERSION // ole : ?, status : ?
- [
- ExecMethod = Execute ;
- StateMethod = GetState ;
- ]
+ SID_CHINESE_CONVERSION // ole : ?, status : ?
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ ]
+ SID_LANGUAGE_STATUS
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ ]
// ?
FID_SEARCH_NOW // ole : ?, status : ?
[
diff --git a/sd/source/ui/docshell/docshel3.cxx b/sd/source/ui/docshell/docshel3.cxx
index d6fd37d42d3d..cf8508681bd8 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -18,6 +18,7 @@
*/
+#include "Window.hxx"
#include "DrawDocShell.hxx"
#include "app.hrc"
@@ -29,14 +30,21 @@
#include <svx/svxerr.hxx>
#include <svx/dialmgr.hxx>
#include <svl/srchitem.hxx>
+#include <svl/languageoptions.hxx>
+#include <svtools/langtab.hxx>
#include <svx/srchdlg.hxx>
#ifdef _OUTLINER_HXX
#include <editeng/outliner.hxx>
#endif
#include <sfx2/request.hxx>
+#include <sfx2/sfxdlg.hxx>
+#include <vcl/abstdlg.hxx>
+#include <vcl/window.hxx>
#include <svl/style.hxx>
#include <svx/drawitem.hxx>
#include <editeng/unolingu.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/eeitem.hxx>
#include <com/sun/star/i18n/TextConversionOption.hpp>
@@ -60,6 +68,68 @@ using namespace ::com::sun::star::uno;
namespace sd {
+static void lcl_setLanguageForObj( SdrObject *pObj, LanguageType nLang, bool bLanguageNone = false )
+{
+ const sal_uInt16 aLangWhichId_EE[3] =
+ {
+ EE_CHAR_LANGUAGE,
+ EE_CHAR_LANGUAGE_CJK,
+ EE_CHAR_LANGUAGE_CTL
+ };
+
+ if( bLanguageNone )
+ nLang = LANGUAGE_NONE;
+
+ if( nLang != LANGUAGE_DONTKNOW )
+ {
+ if( nLang == LANGUAGE_NONE )
+ {
+ for(sal_Int32 n = 0; n < 3; n++ )
+ pObj->SetMergedItem( SvxLanguageItem( nLang, aLangWhichId_EE[n] ) );
+ }
+ else
+ {
+ sal_uInt16 nLangWhichId = 0;
+ sal_uInt16 nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nLang );
+ switch (nScriptType)
+ {
+ case SCRIPTTYPE_LATIN : nLangWhichId = EE_CHAR_LANGUAGE; break;
+ case SCRIPTTYPE_ASIAN : nLangWhichId = EE_CHAR_LANGUAGE_CJK; break;
+ case SCRIPTTYPE_COMPLEX : nLangWhichId = EE_CHAR_LANGUAGE_CTL; break;
+ default:
+ OSL_FAIL("unexpected case" );
+ return;
+ }
+ pObj->SetMergedItem( SvxLanguageItem( nLang, nLangWhichId ) );
+ }
+ }
+ else // Reset to default
+ {
+ for( sal_Int32 n = 0; n < 3; n++ )
+ pObj->ClearMergedItem( aLangWhichId_EE[n] );
+ }
+}
+
+
+static void lcl_setLanguage( const SdDrawDocument *pDoc, const OUString &rLanguage, bool bLanguageNone = false )
+{
+ LanguageType nLang = SvtLanguageTable().GetType( rLanguage );
+
+ // Do it for SdDrawDocument->SetLanguage as well?
+
+ sal_uInt16 nPageCount = pDoc->GetPageCount(); // Pick All Pages
+ for( sal_uInt16 nPage = 0; nPage < nPageCount; nPage++ )
+ {
+ const SdrPage *pPage = pDoc->GetPage( nPage );
+ sal_uIntPtr nObjCount = pPage->GetObjCount();
+ for( sal_uInt16 nObj = 0; nObj < nObjCount; nObj++ )
+ {
+ SdrObject *pObj = pPage->GetObj( nObj );
+ lcl_setLanguageForObj( pObj, nLang, bLanguageNone );
+ }
+ }
+}
+
/*************************************************************************
|*
|* SFX-Requests bearbeiten
@@ -209,6 +279,50 @@ void DrawDocShell::Execute( SfxRequest& rReq )
}
}
break;
+ case SID_LANGUAGE_STATUS:
+ {
+ OUString aNewLangTxt;
+ SFX_REQUEST_ARG( rReq, pItem, SfxStringItem, SID_LANGUAGE_STATUS , false );
+ if (pItem)
+ aNewLangTxt = pItem->GetValue();
+ if (aNewLangTxt == "*" )
+ {
+ // open the dialog "Tools/Options/Language Settings - Language"
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ if (pFact && mpViewShell)
+ {
+ VclAbstractDialog* pDlg = pFact->CreateVclDialog( mpViewShell->GetActiveWindow(), SID_LANGUAGE_OPTIONS );
+ pDlg->Execute();
+ delete pDlg;
+ }
+ }
+ else
+ {
+ // setting the new language...
+ if (!aNewLangTxt.isEmpty())
+ {
+ const OUString aDocumentLangPrefix("Default_");
+ const OUString aStrNone("LANGUAGE_NONE");
+ const OUString aStrResetLangs("RESET_LANGUAGES");
+ sal_Int32 nPos = -1;
+ if (-1 != (nPos = aNewLangTxt.indexOf( aDocumentLangPrefix , 0 )))
+ {
+ aNewLangTxt = aNewLangTxt.replaceAt( nPos, aDocumentLangPrefix.getLength(), "" );
+ }
+ else
+ {
+ break;
+ }
+ if (aNewLangTxt == aStrNone)
+ lcl_setLanguage( mpViewShell->GetDoc(), OUString() );
+ else if (aNewLangTxt == aStrResetLangs)
+ lcl_setLanguage( mpViewShell->GetDoc(), OUString(), true );
+ else
+ lcl_setLanguage( mpViewShell->GetDoc(), aNewLangTxt );
+ }
+ }
+ }
+ break;
default:
break;
diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx
index 6488b0ebaf34..ec0e61a00018 100644
--- a/sd/source/ui/docshell/docshell.cxx
+++ b/sd/source/ui/docshell/docshell.cxx
@@ -308,6 +308,12 @@ void DrawDocShell::GetState(SfxItemSet &rSet)
rSet.Put(SfxVisibilityItem(nWhich, SvtCJKOptions().IsAnyEnabled()));
}
break;
+ case SID_LANGUAGE_STATUS:
+ {
+ // Keeping this enabled for the time being
+ rSet.Put(SfxVisibilityItem(nWhich, true));
+ }
+ break;
default:
break;
diff --git a/sd/uiconfig/sdraw/menubar/menubar.xml b/sd/uiconfig/sdraw/menubar/menubar.xml
index 85ea0e028868..d6a209ee6c84 100644
--- a/sd/uiconfig/sdraw/menubar/menubar.xml
+++ b/sd/uiconfig/sdraw/menubar/menubar.xml
@@ -237,6 +237,8 @@
<menu:menuitem menu:id=".uno:SpellDialog"/>
<menu:menu menu:id=".uno:LanguageMenu">
<menu:menupopup>
+ <menu:menuitem menu:id=".uno:SetLanguageAllTextMenu"/>
+ <menu:menuseparator/>
<menu:menuitem menu:id=".uno:HangulHanjaConversion"/>
<menu:menuitem menu:id=".uno:ChineseConversion"/>
<menu:menuitem menu:id=".uno:ThesaurusDialog"/>
diff --git a/sd/uiconfig/simpress/menubar/menubar.xml b/sd/uiconfig/simpress/menubar/menubar.xml
index 9fd07b1ea8b9..0f60af99721f 100644
--- a/sd/uiconfig/simpress/menubar/menubar.xml
+++ b/sd/uiconfig/simpress/menubar/menubar.xml
@@ -265,6 +265,8 @@
<menu:menuitem menu:id=".uno:SpellDialog"/>
<menu:menu menu:id=".uno:LanguageMenu">
<menu:menupopup>
+ <menu:menuitem menu:id=".uno:SetLanguageAllTextMenu"/>
+ <menu:menuseparator/>
<menu:menuitem menu:id=".uno:HangulHanjaConversion"/>
<menu:menuitem menu:id=".uno:ChineseConversion"/>
<menu:menuitem menu:id=".uno:ThesaurusDialog"/>