summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuthu Subramanian <sumuthu@collabora.com>2014-04-23 18:33:22 +0530
committerMuthu Subramanian <sumuthu@collabora.com>2014-04-23 18:36:38 +0530
commit0833f4046a1afa77aeed97a131c5325c44be1bb3 (patch)
treed3481fe0be6f8eba343926320c941440deb915ae
parentcf33af732ed0d3d553bb74636e3b14c55d44c153 (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: I4695423fed3ed9422185b23803eedd12ef434bea
-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 d22f50a036b0..cd45b39d2320 100644
--- a/sd/source/ui/docshell/docshel3.cxx
+++ b/sd/source/ui/docshell/docshel3.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "Window.hxx"
#include "DrawDocShell.hxx"
#include "app.hrc"
@@ -28,11 +29,18 @@
#include <svx/svxerr.hxx>
#include <svx/dialmgr.hxx>
#include <svl/srchitem.hxx>
+#include <svl/languageoptions.hxx>
+#include <svtools/langtab.hxx>
#include <svx/srchdlg.hxx>
#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>
#include "strings.hrc"
@@ -55,6 +63,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 );
+ }
+ }
+}
+
/**
* Handles SFX-Requests
*/
@@ -201,6 +271,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 f43878762457..7becd842e230 100644
--- a/sd/source/ui/docshell/docshell.cxx
+++ b/sd/source/ui/docshell/docshell.cxx
@@ -269,6 +269,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 0f0508e4a34a..c34e8bb291f1 100644
--- a/sd/uiconfig/sdraw/menubar/menubar.xml
+++ b/sd/uiconfig/sdraw/menubar/menubar.xml
@@ -245,6 +245,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 5ffabefb485f..be36853332f0 100644
--- a/sd/uiconfig/simpress/menubar/menubar.xml
+++ b/sd/uiconfig/simpress/menubar/menubar.xml
@@ -274,6 +274,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"/>