[Libreoffice-commits] core.git: Branch 'distro/suse/suse-4.0' - sd/sdi sd/source sd/uiconfig
Muthu Subramanian
sumuthu at collabora.com
Wed Apr 23 10:10:19 PDT 2014
sd/sdi/_docsh.sdi | 15 ++--
sd/source/ui/docshell/docshel3.cxx | 114 +++++++++++++++++++++++++++++++
sd/source/ui/docshell/docshell.cxx | 6 +
sd/uiconfig/sdraw/menubar/menubar.xml | 2
sd/uiconfig/simpress/menubar/menubar.xml | 2
5 files changed, 134 insertions(+), 5 deletions(-)
New commits:
commit b80dc0ed7be65c448c7a286454c4304120b4c20e
Author: Muthu Subramanian <sumuthu at collabora.com>
Date: Wed Apr 23 22:41:11 2014 +0530
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
diff --git a/sd/sdi/_docsh.sdi b/sd/sdi/_docsh.sdi
index 075b60a..b087723 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 d6fd37d..cf85086 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 6488b0e..ec0e61a 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 85ea0e0..d6a209e 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 9fd07b1..0f60af9 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"/>
More information about the Libreoffice-commits
mailing list