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 /linguistic | |
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 'linguistic')
-rw-r--r-- | linguistic/source/gciterator.cxx | 62 | ||||
-rw-r--r-- | linguistic/source/gciterator.hxx | 28 |
2 files changed, 90 insertions, 0 deletions
diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index b1dce0de8543..a1bba7cbf739 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -233,6 +233,50 @@ static lang::Locale lcl_GetPrimaryLanguageOfSentence( } +SwXStringKeyMap::SwXStringKeyMap() {} + +void SAL_CALL SwXStringKeyMap::insertValue(const OUString& aKey, const css::uno::Any& aValue) +{ + std::map<OUString, css::uno::Any>::const_iterator aIter = maMap.find(aKey); + if (aIter != maMap.end()) + throw css::container::ElementExistException(); + + maMap[aKey] = aValue; +} + +css::uno::Any SAL_CALL SwXStringKeyMap::getValue(const OUString& aKey) +{ + std::map<OUString, css::uno::Any>::const_iterator aIter = maMap.find(aKey); + if (aIter == maMap.end()) + throw css::container::NoSuchElementException(); + + return (*aIter).second; +} + +sal_Bool SAL_CALL SwXStringKeyMap::hasValue(const OUString& aKey) +{ + return maMap.find(aKey) != maMap.end(); +} + +::sal_Int32 SAL_CALL SwXStringKeyMap::getCount() { return maMap.size(); } + +OUString SAL_CALL SwXStringKeyMap::getKeyByIndex(::sal_Int32 nIndex) +{ + if (static_cast<sal_uInt32>(nIndex) >= maMap.size()) + throw css::lang::IndexOutOfBoundsException(); + + return OUString(); +} + +css::uno::Any SAL_CALL SwXStringKeyMap::getValueByIndex(::sal_Int32 nIndex) +{ + if (static_cast<sal_uInt32>(nIndex) >= maMap.size()) + throw css::lang::IndexOutOfBoundsException(); + + return css::uno::Any(); +} + + GrammarCheckingIterator::GrammarCheckingIterator() : m_bEnd( false ), m_aCurCheckedDocId(), @@ -382,6 +426,24 @@ void GrammarCheckingIterator::ProcessResult( // differently for example. But no special handling right now. if (rDesc.nType == text::TextMarkupType::SPELLCHECK) rDesc.nType = text::TextMarkupType::PROOFREADING; + + uno::Reference< container::XStringKeyMap > xKeyMap( + new SwXStringKeyMap()); + for( const beans::PropertyValue& rProperty : rError.aProperties ) + { + if ( rProperty.Name == "LineColor" ) + { + xKeyMap->insertValue(rProperty.Name, + rProperty.Value); + rDesc.xMarkupInfoContainer = xKeyMap; + } + else if ( rProperty.Name == "LineType" ) + { + xKeyMap->insertValue(rProperty.Name, + rProperty.Value); + rDesc.xMarkupInfoContainer = xKeyMap; + } + } } // at pos nErrors -> sentence markup diff --git a/linguistic/source/gciterator.hxx b/linguistic/source/gciterator.hxx index 568a30f50150..9241b4136dd7 100644 --- a/linguistic/source/gciterator.hxx +++ b/linguistic/source/gciterator.hxx @@ -37,6 +37,10 @@ #include <osl/thread.h> #include <rtl/instance.hxx> +#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <com/sun/star/uno/Any.hxx> +#include <cppu/unotype.hxx> + #include <map> #include <deque> @@ -180,6 +184,30 @@ public: }; +/** Implementation of the css::container::XStringKeyMap interface + */ +class SwXStringKeyMap : public ::cppu::WeakImplHelper<css::container::XStringKeyMap> +{ +public: + SwXStringKeyMap(); + + virtual css::uno::Any SAL_CALL getValue(const OUString& aKey) override; + virtual sal_Bool SAL_CALL hasValue(const OUString& aKey) override; + virtual void SAL_CALL insertValue(const OUString& aKey, const css::uno::Any& aValue) override; + virtual ::sal_Int32 SAL_CALL getCount() override; + virtual OUString SAL_CALL getKeyByIndex(::sal_Int32 nIndex) override; + virtual css::uno::Any SAL_CALL getValueByIndex(::sal_Int32 nIndex) override; + +private: + SwXStringKeyMap(SwXStringKeyMap&) = delete; + void operator=(SwXStringKeyMap&) = delete; + + ~SwXStringKeyMap() override{}; + + std::map<OUString, css::uno::Any> maMap; +}; + + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |