[Libreoffice-commits] core.git: sw/inc sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 24 17:12:24 UTC 2019


 sw/inc/doc.hxx                                       |    8 +++++
 sw/source/core/doc/doc.cxx                           |    9 ++++++
 sw/source/core/doc/docnew.cxx                        |    1 
 sw/source/core/txtnode/txtedt.cxx                    |   18 ++++++++++++
 sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx |   27 +++++++++----------
 5 files changed, 50 insertions(+), 13 deletions(-)

New commits:
commit 33f6848dc5abe71471b08dc6a8946feaa2d75ffc
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Jan 22 17:43:45 2019 +0100
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Thu Jan 24 18:11:56 2019 +0100

    tdf#86731 Don't show 'spelling complete' when dictionary is missing
    
    To check if dictionary is missing we have to run spelling which
    checks used language for each text portion.
    When AutoSpelling or manually invoked Spelling is performed SwDoc
    receives notification about missing dictionaries. Then it is possible
    to not show 'Completed' dialog.
    
    Change-Id: I040ce6565632294796c0206d20c4cd0066ca9643
    Reviewed-on: https://gerrit.libreoffice.org/66813
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 4d1cf10c9010..9dda17de8e8b 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -312,6 +312,9 @@ private:
     bool mbColumnSelection       : 1;    //< TRUE: this content has been created by a column selection (clipboard docs only)
     bool mbIsPrepareSelAll       : 1;
 
+    enum MissingDictionary { False = -1, Undefined = 0, True = 1 };
+    MissingDictionary meDictionaryMissing;
+
     // true: Document contains at least one anchored object, which is anchored AT_PAGE with a content position.
     //       Thus, certain adjustment needed during formatting for these kind of anchored objects.
     bool mbContainsAtPageObjWithContentAnchor : 1;
@@ -1635,6 +1638,11 @@ public:
      */
     bool StartGrammarChecking( bool bSkipStart = false );
 
+    /// Use to notify if the dictionary can be found for a single content portion (has to be called for all portions)
+    void SetMissingDictionaries( bool bIsMissing );
+    /// Returns true if no dictionary can be found for any content
+    bool IsDictionaryMissing() { return meDictionaryMissing == MissingDictionary::True; }
+
 private:
     // Copies master header to left / first one, if necessary - used by ChgPageDesc().
     void CopyMasterHeader(const SwPageDesc &rChged, const SwFormatHeader &rHead, SwPageDesc &pDesc, bool bLeft, bool bFirst);
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 1e223e8b64a9..ee4dd7682dba 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1827,4 +1827,13 @@ SwDoc::GetVbaEventProcessor()
     return mxVbaEvents;
 }
 
+void SwDoc::SetMissingDictionaries( bool bIsMissing )
+{
+    if( bIsMissing && meDictionaryMissing == MissingDictionary::Undefined )
+        meDictionaryMissing = MissingDictionary::True;
+    else if( !bIsMissing )
+        meDictionaryMissing = MissingDictionary::False;
+};
+
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index a1034a6e482c..d17b8202d699 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -274,6 +274,7 @@ SwDoc::SwDoc()
     mbClipBoard( false ),
     mbColumnSelection( false ),
     mbIsPrepareSelAll(false),
+    meDictionaryMissing( MissingDictionary::Undefined ),
     mbContainsAtPageObjWithContentAnchor(false), //#i119292#, fdo#37024
 
     meDocType(DOCTYPE_NATIVE)
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 358669f3fba6..686b64dc89a2 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -88,6 +88,22 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::linguistic2;
 using namespace ::com::sun::star::smarttags;
 
+namespace
+{
+    void DetectAndMarkMissingDictionaries( SwDoc* pDoc,
+                                           const uno::Reference< XSpellChecker1 >& xSpell,
+                                           const LanguageType eActLang )
+    {
+        if( !pDoc )
+            return;
+
+        if( xSpell.is() && !xSpell->hasLanguage( eActLang.get() ) )
+            pDoc->SetMissingDictionaries( true );
+        else
+            pDoc->SetMissingDictionaries( false );
+    }
+}
+
 struct SwParaIdleData_Impl
 {
     SwWrongList* pWrong;                // for spell checking
@@ -1054,6 +1070,7 @@ bool SwTextNode::Spell(SwSpellArgs* pArgs)
             // get next language for next word, consider language attributes
             // within the word
             LanguageType eActLang = aScanner.GetCurrentLanguage();
+            DetectAndMarkMissingDictionaries( GetTextNode()->GetDoc(), pArgs->xSpeller, eActLang );
 
             if( rWord.getLength() > 0 && LANGUAGE_NONE != eActLang )
             {
@@ -1360,6 +1377,7 @@ SwRect SwTextFrame::AutoSpell_(SwTextNode & rNode, sal_Int32 nActPos)
             // get next language for next word, consider language attributes
             // within the word
             LanguageType eActLang = aScanner.GetCurrentLanguage();
+            DetectAndMarkMissingDictionaries( pDoc, xSpell, eActLang );
 
             bool bSpell = xSpell.is() && xSpell->hasLanguage( static_cast<sal_uInt16>(eActLang) );
             if( bSpell && !rWord.isEmpty() )
diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
index 5502faa34954..0f6725fc64e8 100644
--- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
+++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
@@ -405,20 +405,21 @@ The code below would only be part of the solution.
                     bCloseMessage = false; // no closing message if a wrap around has been denied
             }
         }
-        if(aRet.empty())
+        bool bNoDictionaryAvailable = pWrtShell->GetDoc()->IsDictionaryMissing();
+        if( aRet.empty() && bCloseMessage && !bNoDictionaryAvailable )
         {
-            if(bCloseMessage)
-            {
-                LockFocusNotification( true );
-                OUString sInfo(SwResId(STR_SPELLING_COMPLETED));
-                // #i84610#
-                std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetWindow()->GetFrameWeld(),
-                                                                                           VclMessageType::Info, VclButtonsType::Ok, sInfo));
-                xBox->run();
-                LockFocusNotification( false );
-                // take care that the now valid selection is stored
-                LoseFocus();
-            }
+            LockFocusNotification( true );
+            OUString sInfo( SwResId( STR_SPELLING_COMPLETED ) );
+            // #i84610#
+            std::unique_ptr<weld::MessageDialog> xBox(
+                Application::CreateMessageDialog( GetWindow()->GetFrameWeld(),
+                                                  VclMessageType::Info,
+                                                  VclButtonsType::Ok,
+                                                  sInfo ) );
+            xBox->run();
+            LockFocusNotification( false );
+            // take care that the now valid selection is stored
+            LoseFocus();
         }
     }
     return aRet;


More information about the Libreoffice-commits mailing list