Date: prev next · Thread: first prev next last
2017 Archives by date, by thread · List index


Hi Henry,

On Tuesday, 2017-11-14 16:44:18 -0400, Henry Castro wrote:

Spell checking in Calc does not work this way with a global document
language or paragraph language, language is a cell attribute (or in-cell
EditEngine text portion attribute).

Indeed, after reading code they are designed to cell attribute, but I did not
find anything to apply this, since they are not set, the cell take the global
document language

*If* not set then it's equal to the document language.

To obtain the font/spell-checking language attribute of the current
selection (single cell, range, or multi-selection) you could use
something like this

    ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
    const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
    LanguageType nLang = static_cast<const 
SvxLanguageItem&>(rAttrSet.Get(ATTR_FONT_LANGUAGE)).GetValue();
    if (nLang == LANGUAGE_SYSTEM)
        nLang = Application::GetSettings().GetLanguageTag().getLanguageType();

Note that for multiple cells the returned LanguageType may not match the
individual values if cells have different attribute values. You may want
to check if the ATTR_FONT_LANGUAGE SfxItem is actually set in the
SfxItemSet (rAttrSet.Get(ATTR_FONT_LANGUAGE).GetItemState() == SfxItemState::SET)
and otherwise use LANGUAGE_MULTIPLE. YMMV.

This is only the Western language attribute, if you also want CJK and
CTL (which are not used for spell-checking) check how it's done in

    LanguageType ScViewUtil::GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos )

and use pTabViewShell->GetSelectionScriptType().


To apply a new (Western) font language to the current selection use

    pTabViewShell->ApplyAttr( SvxLanguageItem( nLang, ATTR_FONT_LANGUAGE));

Do not use multiple consecutive ApplyAttr() calls, to apply more than
one attribute in one go there's ApplySelectionPattern(const ScPatternAttr& rAttr)


Hope this helps.

  Eike

-- 
LibreOffice Calc developer. Number formatter stricken i18n transpositionizer.
GPG key 0x6A6CD5B765632D3A - 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
Care about Free Software, support the FSFE https://fsfe.org/support/?erack

Attachment: signature.asc
Description: PGP signature


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.