[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sd/sdi sd/source sd/uiconfig

Muthu Subramanian sumuthu at collabora.com
Sun May 25 12:40:13 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 585077d4f681582386baa10acff53abdd280552b
Author: Muthu Subramanian <sumuthu at collabora.com>
Date:   Wed Apr 23 18:33:22 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: I4695423fed3ed9422185b23803eedd12ef434bea
    (cherry picked from commit 0833f4046a1afa77aeed97a131c5325c44be1bb3)
    Signed-off-by: Andras Timar <andras.timar at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/9314
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

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 d22f50a..cd45b39 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 1553954..ee0fad0 100644
--- a/sd/source/ui/docshell/docshell.cxx
+++ b/sd/source/ui/docshell/docshell.cxx
@@ -270,6 +270,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 6e8f9e4..289acf9 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 b2d5ae6..e8b1a6d 100644
--- a/sd/uiconfig/simpress/menubar/menubar.xml
+++ b/sd/uiconfig/simpress/menubar/menubar.xml
@@ -273,6 +273,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