diff options
author | Fred Kruse <f.kruse@freenet.de> | 2018-05-28 13:04:48 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-06-01 03:57:31 +0200 |
commit | 7e428cac54c0a10aa7885923b836562e8fa82235 (patch) | |
tree | fc4af7abd1ed710a85fb80b6f3db4be0fdfe906b /sw | |
parent | 85849a28bf45a16f76ebf9b82ba59de15670c0f4 (diff) |
linguistic: add functionality to change spellcheck color
This adds a way for the grammar checker extension to change color
and line type of the 'wiggly lines' LibreOffice uses to highlight
spelling or grammar errors.
Change-Id: Idd669cf362da34f8cfcdcec14f1f80df1ddb1f9e
Reviewed-on: https://gerrit.libreoffice.org/54927
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/wrong.hxx | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/sw/source/core/inc/wrong.hxx b/sw/source/core/inc/wrong.hxx index 3bca9d8d6fa0..0aa575434483 100644 --- a/sw/source/core/inc/wrong.hxx +++ b/sw/source/core/inc/wrong.hxx @@ -76,6 +76,66 @@ public: SwWrongList* pSubList); private: + static Color getGrammarColor ( css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag) + { + try + { + if (xPropertyBag.is()) + { + const OUString colorKey("LineColor"); + css::uno::Any aLineColor = xPropertyBag->getValue(colorKey); + css::util::Color lineColor = 0; + + if (aLineColor >>= lineColor) + { + return Color( lineColor ); + } + } + } + catch(const css::container::NoSuchElementException&) + { + } + catch(const css::uno::RuntimeException&) + { + } + + return COL_LIGHTBLUE; + } + + static WrongAreaLineType getGrammarLineType( css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag ) + { + try + { + if (xPropertyBag.is()) + { + const OUString typeKey("LineType"); + css::uno::Any aLineType = xPropertyBag->getValue(typeKey); + ::sal_Int16 lineType = 0; + + if (!(aLineType >>= lineType)) + { + return WRONGAREA_WAVE; + } + if (css::awt::FontUnderline::DASH == lineType) + { + return WRONGAREA_DASHED; + } + if (css::awt::FontUnderline::SMALLWAVE == lineType) + { + return WRONGAREA_WAVE; //Code draws wave height based on space that fits. + } + } + } + catch(const css::container::NoSuchElementException&) + { + } + catch(const css::uno::RuntimeException&) + { + } + + return WRONGAREA_WAVE; + } + static Color getSmartColor ( css::uno::Reference< css::container::XStringKeyMap > const & xPropertyBag) { try @@ -145,7 +205,7 @@ private: } else if (WRONGLIST_GRAMMAR == listType) { - return COL_LIGHTBLUE; + return getGrammarColor(xPropertyBag); } else if (WRONGLIST_SMARTTAG == listType) { @@ -164,7 +224,7 @@ private: } else if (WRONGLIST_GRAMMAR == listType) { - return WRONGAREA_WAVE; + return getGrammarLineType(xPropertyBag); } else if (WRONGLIST_SMARTTAG == listType) { |