cui/source/tabpages/paragrph.cxx | 26 ++++++++++++++++++-------- sw/qa/uitest/writer_tests2/formatParagraph.py | 10 +++++----- sw/qa/uitest/writer_tests3/tdf79236.py | 20 ++++++++++---------- 3 files changed, 33 insertions(+), 23 deletions(-)
New commits: commit aa64eff44b3b6d0bf5c96f851e5181ce1909d604 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Aug 22 13:14:38 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Aug 25 09:33:22 2023 +0200 tdf#101895 don't unconditionally default to ch[ar]/line if CJK typography is available. Given that we choose to show cm vs inch based on SvtSysLocaleOptions::GetRealLanguageTag() also choose to use ch[ar] and line based on that setting when bApplyCharUnit is enabled. Change-Id: I812d05e0639f7e214d5c3d4dcca01b0709126fd9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155948 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155949 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/cui/source/tabpages/paragrph.cxx b/cui/source/tabpages/paragrph.cxx index f03464c70d73..2f81e4f4ddb2 100644 --- a/cui/source/tabpages/paragrph.cxx +++ b/cui/source/tabpages/paragrph.cxx @@ -45,11 +45,14 @@ #include <editeng/lrspitem.hxx> #include <editeng/formatbreakitem.hxx> #include <editeng/keepitem.hxx> +#include <i18nlangtag/languagetag.hxx> +#include <i18nlangtag/mslangid.hxx> #include <svx/dlgutil.hxx> #include <sfx2/htmlmode.hxx> #include <editeng/paravertalignitem.hxx> #include <svl/eitem.hxx> #include <svl/intitem.hxx> +#include <unotools/syslocaleoptions.hxx> const WhichRangesContainer SvxStdParagraphTabPage::pStdRanges( svl::Items< @@ -407,6 +410,19 @@ bool SvxStdParagraphTabPage::FillItemSet( SfxItemSet* rOutSet ) return bModified; } +static bool UseCharUnitInUI(const SfxItemSet& rSet) +{ + const bool bApplyCharUnit = GetApplyCharUnit(rSet); + if (!bApplyCharUnit) + return false; + if (!SvtCJKOptions::IsAsianTypographyEnabled()) + return false; + // tdf#101895 Given that we choose to show cm vs inch based on this Locale + // setting, also choose to use ch[ar] and line based on that locale when + // bApplyCharUnit is enabled. + return MsLangId::isCJK(SvtSysLocaleOptions().GetRealLanguageTag().getLanguageType()); +} + void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) { SfxItemPool* pPool = rSet->GetPool(); @@ -414,10 +430,7 @@ void SvxStdParagraphTabPage::Reset( const SfxItemSet* rSet ) // adjust metric FieldUnit eFUnit = GetModuleFieldUnit( *rSet ); - - bool bApplyCharUnit = GetApplyCharUnit( *rSet ); - - if(SvtCJKOptions::IsAsianTypographyEnabled() && bApplyCharUnit ) + if (UseCharUnitInUI(*rSet)) eFUnit = FieldUnit::CHAR; m_xLeftIndent->SetFieldUnit(eFUnit); @@ -1599,10 +1612,7 @@ void SvxExtParagraphTabPage::Reset( const SfxItemSet* rSet ) // adjust metric FieldUnit eFUnit = GetModuleFieldUnit( *rSet ); - - bool bApplyCharUnit = GetApplyCharUnit( *rSet ); - - if( SvtCJKOptions::IsAsianTypographyEnabled() && bApplyCharUnit ) + if (UseCharUnitInUI(*rSet)) eFUnit = FieldUnit::CHAR; sal_uInt16 _nWhich = GetWhich( SID_ATTR_PARA_HYPHENZONE ); diff --git a/sw/qa/uitest/writer_tests2/formatParagraph.py b/sw/qa/uitest/writer_tests2/formatParagraph.py index cd72dbf7efe7..e90d0fd7f980 100644 --- a/sw/qa/uitest/writer_tests2/formatParagraph.py +++ b/sw/qa/uitest/writer_tests2/formatParagraph.py @@ -58,12 +58,12 @@ class formatParagraph(UITestCase): xLineSpacing = xDialog.getChild("comboLB_LINEDIST") xActivate = xDialog.getChild("checkCB_REGISTER") - self.assertEqual(get_state_as_dict(xBeforeText)["Text"], "0.50 ch") - self.assertEqual(get_state_as_dict(xAfterText)["Text"], "0.50 ch") - self.assertEqual(get_state_as_dict(xFirstLine)["Text"], "0.50 ch") + self.assertEqual(get_state_as_dict(xBeforeText)["Text"], "0.02″") + self.assertEqual(get_state_as_dict(xAfterText)["Text"], "0.02″") + self.assertEqual(get_state_as_dict(xFirstLine)["Text"], "0.02″") self.assertEqual(get_state_as_dict(xAutomaticChk)["Selected"], "true") - self.assertEqual(get_state_as_dict(xAbovePar)["Text"], "0.50 line") - self.assertEqual(get_state_as_dict(xBelowPar)["Text"], "0.50 line") + self.assertEqual(get_state_as_dict(xAbovePar)["Text"], "0.02″") + self.assertEqual(get_state_as_dict(xBelowPar)["Text"], "0.02″") self.assertEqual(get_state_as_dict(xChkspace)["Selected"], "true") self.assertEqual(get_state_as_dict(xLineSpacing)["SelectEntryText"], "Double") self.assertEqual(get_state_as_dict(xActivate)["Selected"], "true") diff --git a/sw/qa/uitest/writer_tests3/tdf79236.py b/sw/qa/uitest/writer_tests3/tdf79236.py index c8e857188c9c..d7b59da19f63 100644 --- a/sw/qa/uitest/writer_tests3/tdf79236.py +++ b/sw/qa/uitest/writer_tests3/tdf79236.py @@ -59,11 +59,11 @@ class tdf79236(UITestCase): xTopSpnBtn.executeAction("UP", tuple()) - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaLeftMargin, 3704) - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaRightMargin, 3704) - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaTopMargin, 5503) - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaBottomMargin, 5503) - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaFirstLineIndent, 3704) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaLeftMargin, 1016) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaRightMargin, 1016) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaTopMargin, 1016) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaBottomMargin, 1016) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaFirstLineIndent, 1016) with self.ui_test.execute_dialog_through_command(".uno:ParagraphDialog") as xParagraphDlg: @@ -98,11 +98,11 @@ class tdf79236(UITestCase): self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaLeftMargin, 3704) - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaRightMargin, 3704) - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaTopMargin, 5503) - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaBottomMargin, 5503) - self.assertEqual(document.CurrentSelection.getByIndex(0).ParaFirstLineIndent, 3704) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaLeftMargin, 1016) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaRightMargin, 1016) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaTopMargin, 1016) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaBottomMargin, 1016) + self.assertEqual(document.CurrentSelection.getByIndex(0).ParaFirstLineIndent, 1016) self.xUITest.executeCommand(".uno:Undo")