From 8168e27362ff165211b9d228aed59df5894522ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Sat, 13 Feb 2010 15:44:17 +0000 Subject: [PATCH] * new InsetLayout tag to disallow spell checking. This actually brings Inset::allowSpellCheck() to use. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33467 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/doc/Customization.lyx | 40 ++++++++++++++++++++++++++++++++++-- lib/scripts/layout2layout.py | 9 +++++--- src/Paragraph.cpp | 3 +++ src/TextClass.cpp | 2 +- src/insets/InsetLayout.cpp | 9 ++++++-- src/insets/InsetLayout.h | 3 +++ src/insets/InsetText.h | 4 ++-- 7 files changed, 60 insertions(+), 10 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index a98dbcad37..1b0230ad54 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -1,5 +1,5 @@ #LyX 2.0.0svn created this file. For more info see http://www.lyx.org/ -\lyxformat 376 +\lyxformat 378 \begin_document \begin_header \textclass scrbook @@ -14199,7 +14199,7 @@ reference "des:Preamble" status collapsed \begin_layout Plain Layout -Requires +Requires \end_layout \end_inset @@ -14224,6 +14224,42 @@ reference "des:Requires" ). \end_layout +\begin_layout Description +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout +Spellcheck +\end_layout + +\end_inset + + [ +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout +0 +\end_layout + +\end_inset + +, +\begin_inset Flex CharStyle:Code +status collapsed + +\begin_layout Plain Layout + +\emph on +1 +\end_layout + +\end_inset + +] Spellcheck the contents of this inset. + Default is true. +\end_layout + \begin_layout Subsection Counters \begin_inset CommandInset label diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 2ab34031c0..e26c811de1 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -77,10 +77,13 @@ import os, re, string, sys # Incremented to format 21, 12 January 2010 by rgh # Added HTMLTocLayout and HTMLTitle tags. - + # Incremented to format 22, 20 January 2010 by rgh # Added HTMLFormat tag to Counters. +# Incremented to format 23, 13 February 2010 by spitz +# Added Spellcheck tag. + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). @@ -88,7 +91,7 @@ import os, re, string, sys # development/tools/updatelayouts.sh script to update all # layout files to the new format. -currentFormat = 22 +currentFormat = 23 def usage(prog_name): @@ -257,7 +260,7 @@ def convert(lines): continue # This just involved new features, not any changes to old ones - if format >= 14 and format <= 21: + if format >= 14 and format <= 22: i += 1 continue diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index af6158881d..4d51e2c69c 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3165,6 +3165,9 @@ bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl, if (!speller) return false; + if (!inInset().allowSpellCheck()) + return false; + locateWord(from, to, WHOLE_WORD); if (from == to || from >= pos_type(d->text_.size())) return false; diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 981dcd185c..6b8a0bc956 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -66,7 +66,7 @@ private: }; // Keep the changes documented in the Customization manual. -int const FORMAT = 22; +int const FORMAT = 23; bool layout2layout(FileName const & filename, FileName const & tempfile) diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index 9b466d1c25..ba1bbfb3e5 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -37,7 +37,7 @@ InsetLayout::InsetLayout() : htmlforcecss_ (false), htmlisblock_(true), multipar_(true), custompars_(true), forceplain_(false), passthru_(false), needprotect_(false), freespacing_(false), - keepempty_(false), forceltr_(false), intoc_(false) + keepempty_(false), forceltr_(false), intoc_(false), spellcheck_(true) { labelfont_.setColor(Color_error); } @@ -105,6 +105,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) IL_PASSTHRU, IL_PREAMBLE, IL_REQUIRES, + IL_SPELLCHECK, IL_END }; @@ -142,7 +143,8 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) { "needprotect", IL_NEEDPROTECT }, { "passthru", IL_PASSTHRU }, { "preamble", IL_PREAMBLE }, - { "requires", IL_REQUIRES } + { "requires", IL_REQUIRES }, + { "spellcheck", IL_SPELLCHECK } }; lex.pushTable(elementTags); @@ -322,6 +324,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) requires_.insert(req.begin(), req.end()); break; } + case IL_SPELLCHECK: + lex >> spellcheck_; + break; case IL_END: getout = true; break; diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index ff3674aa5b..0fcbad20d0 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -137,6 +137,7 @@ public: /// bool isInToc() const { return intoc_; } /// + bool spellcheck() const { return spellcheck_; } private: /// void makeDefaultCSS() const; @@ -217,6 +218,8 @@ private: bool forceltr_; /// should the contents be written to TOC strings? bool intoc_; + /// check spelling of this inset? + bool spellcheck_; }; /// diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 8c1f6842e7..d33b6bda32 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -149,8 +149,8 @@ public: ParagraphList const & paragraphs() const; /// bool insetAllowed(InsetCode) const { return !getLayout().isPassThru(); } - /// Allow spellchecking, except for insets with latex_language - bool allowSpellCheck() const { return !getLayout().isPassThru(); } + /// + bool allowSpellCheck() const { return getLayout().spellcheck() && !getLayout().isPassThru(); } /// virtual bool isMacroScope() const { return false; } /// -- 2.39.2