Kaydet (Commit) 33f6848d authored tarafından Szymon Kłos's avatar Szymon Kłos

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: 's avatarSzymon Kłos <szymon.klos@collabora.com>
üst 1500ec88
......@@ -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);
......
......@@ -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: */
......@@ -274,6 +274,7 @@ SwDoc::SwDoc()
mbClipBoard( false ),
mbColumnSelection( false ),
mbIsPrepareSelAll(false),
meDictionaryMissing( MissingDictionary::Undefined ),
mbContainsAtPageObjWithContentAnchor(false), //#i119292#, fdo#37024
meDocType(DOCTYPE_NATIVE)
......
......@@ -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() )
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment