[Libreoffice-commits] core.git: include/svl sc/qa sc/sdi sc/source sc/uiconfig sfx2/source
Eike Rathke
erack at redhat.com
Wed Nov 15 18:43:31 UTC 2017
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20171115/32b2cd44/attachment.sig>
More information about the LibreOffice
mailing list