@@ -27,11 +27,11 @@ __all__ = [ "lang", "locales", "pkg", "name", "version", "author", \ "load", "parse", "getSpellChecker", \ "setOption", "setOptions", "getOptions", "getDefaultOptions", "getOptionsLabels", "resetOptions", "displayOptions", \ - "ignoreRule", "resetIgnoreRules", "reactivateRule", "listRules", "displayRules" ] + "ignoreRule", "resetIgnoreRules", "reactivateRule", "listRules", "displayRules", "setWriterUnderliningStyle" ] __version__ = "${version}" lang = "${lang}" @@ -51,10 +51,13 @@ _dOptionsColors = None _oSpellChecker = None _oTokenizer = None _aIgnoredRules = set() +# Writer underlining style +_bMulticolor = True +_nUnderliningStyle = 0 #### Initialization def load (sContext="Python", sColorType="aRGB"): @@ -189,10 +192,29 @@ def resetOptions (): "set options to default values" global _dOptions _dOptions = getDefaultOptions() + +def setWriterUnderliningStyle (sStyle="BOLDWAVE", bMulticolor=True): + "set underlining style for Writer (WAVE, BOLDWAVE, BOLD)" + global _nUnderliningStyle + global _bMulticolor + # https://api.libreoffice.org/docs/idl/ref/FontUnderline_8idl.html + # WAVE: 10, BOLD: 12, BOLDWAVE: 18 DASH: 5 + if sStyle == "WAVE": + _nUnderliningStyle = 0 # 0 for default Writer setting + elif sStyle == "BOLDWAVE": + _nUnderliningStyle = 18 + elif sStyle == "BOLD": + _nUnderliningStyle = 12 + elif sStyle == "DASH": + _nUnderliningStyle = 5 + else: + _nUnderliningStyle = 0 + _bMulticolor = bMulticolor + #### Parsing def parse (sText, sCountry="${country_default}", bDebug=False, dOptions=None, bContext=False, bFullInfo=False): "init point to analyse and returns an iterable of errors or (with option ) paragraphs errors and sentences with tokens and errors" @@ -661,14 +683,15 @@ xErr.aRuleIdentifier = sRuleId xErr.aShortComment = sMessage # sMessage.split("|")[0] # in context menu xErr.aFullComment = sMessage # sMessage.split("|")[-1] # in dialog xErr.aSuggestions = tuple(lSugg) # Properties - lProperties = [ - PropertyValue(Name="LineType", Value=18), # WAVE: 10, DASH: 5, BOLD: 12, BOLDWAVE: 18 https://api.libreoffice.org/docs/idl/ref/FontUnderline_8idl.html - PropertyValue(Name="LineColor", Value=_dOptionsColors.get(sOption, 33023)) - ] + lProperties = [] + if _nUnderliningStyle: + lProperties.append(PropertyValue(Name="LineType", Value=_nUnderliningStyle)) + if _bMulticolor: + lProperties.append(PropertyValue(Name="LineColor", Value=_dOptionsColors.get(sOption, 33023))) if sURL: lProperties.append(PropertyValue(Name="FullCommentURL", Value=sURL)) xErr.aProperties = lProperties return xErr