tdf#92144 Enable relative font sizes in Calc cell styles
Writer paragraph styles already support percentage-based (80%, 115%) and point-relative (+2pt, -4pt) font sizes for child styles inheriting from a parent. Calc cell styles lacked this despite using the same underlying SvxCharNamePage and FontSizeBox widgets. The root cause was that Calc's ScStyleDlg::PageCreated() did not pass the SVX_RELATIVE_MODE flag when creating the font tab page, so FontSizeBox::EnableRelativeMode() and EnablePtRelativeMode() were never called. The fix adds a single SfxUInt32Item(SID_FLAG_TYPE, SVX_RELATIVE_MODE) to the item set passed to the font page, matching what Writer's SwTemplateDlgController already does. No changes are needed in the core: SvxFontHeightItem::SetHeight() already pre-calculates absolute values from relative ones, and ScPatternAttr works correctly with these pre-calculated values. Fix found with the help of Claude Sonnet 4.6 extended. Change-Id: I3d759c028564a4722f96b325499ea0bfe8e4ba07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200885 Tested-by: Jakub Trzebiatowski <ubap.dev@gmail.com> Tested-by: Jenkins Reviewed-by: Jakub Trzebiatowski <ubap.dev@gmail.com>
This commit is contained in:
committed by
Jakub Trzebiatowski
parent
f78206e5da
commit
42cdc47554
@@ -304,6 +304,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sc,\
|
||||
UITest_calc_tests9 \
|
||||
UITest_function_wizard \
|
||||
UITest_manual_tests \
|
||||
UITest_sc_styleui \
|
||||
))
|
||||
|
||||
ifneq ($(or $(ENABLE_LPSOLVE),$(ENABLE_COINMP)),)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*-
|
||||
#
|
||||
# This file is part of the LibreOffice project.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
|
||||
$(eval $(call gb_UITest_UITest,sc_styleui))
|
||||
$(eval $(call gb_UITest_add_modules,sc_styleui,$(SRCDIR)/sc/qa/uitest,\
|
||||
styleui/ \
|
||||
))
|
||||
$(eval $(call gb_UITest_set_defs,sc_styleui, \
|
||||
TDOC="$(SRCDIR)/sc/qa/uitest/data" \
|
||||
))
|
||||
$(eval $(call gb_UITest_avoid_oneprocess,sc_styleui))
|
||||
|
||||
# vim: set noet sw=4 ts=4:
|
||||
@@ -0,0 +1,167 @@
|
||||
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
|
||||
#
|
||||
# This file is part of the LibreOffice project.
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
"""Tests for tdf#92144 - relative font sizes in Calc cell styles."""
|
||||
|
||||
from uitest.framework import UITestCase
|
||||
from uitest.uihelper.common import get_state_as_dict
|
||||
from uitest.uihelper.common import select_pos
|
||||
from uitest.uihelper.common import type_text
|
||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||
|
||||
|
||||
class tdf92144(UITestCase):
|
||||
|
||||
def test_percentage_font_size_in_cell_style(self):
|
||||
"""Test that percentage font size is preserved in cell style."""
|
||||
with self.ui_test.create_doc_in_start_center("calc"):
|
||||
|
||||
# Create a new cell style
|
||||
with self.ui_test.execute_dialog_through_command(
|
||||
".uno:StyleNewByExample") as xDialog:
|
||||
xStyleName = xDialog.getChild("stylename")
|
||||
xStyleName.executeAction("CLEAR", tuple())
|
||||
type_text(xStyleName, "Test Percent Size")
|
||||
|
||||
# Edit the style and set 80%
|
||||
with self.ui_test.execute_blocking_action(
|
||||
self.xUITest.executeCommandWithParameters,
|
||||
args=(".uno:EditStyle",
|
||||
mkPropertyValues({"Param": "Test Percent Size",
|
||||
"Family": "CellStyles"}))) as xDialog:
|
||||
|
||||
# Go to Font tab
|
||||
xTabs = xDialog.getChild("tabcontrol")
|
||||
select_pos(xTabs, "2")
|
||||
# Set percentage
|
||||
xSizeField = xDialog.getChild("cbWestSize")
|
||||
xSizeField.executeAction("CLEAR", tuple())
|
||||
type_text(xSizeField, "80%")
|
||||
|
||||
# Reopen the style and verify it's still 80%
|
||||
with self.ui_test.execute_blocking_action(
|
||||
self.xUITest.executeCommandWithParameters,
|
||||
args=(".uno:EditStyle",
|
||||
mkPropertyValues({"Param": "Test Percent Size",
|
||||
"Family": "CellStyles"}))) as xDialog:
|
||||
|
||||
# Go to Font tab
|
||||
xTabs = xDialog.getChild("tabcontrol")
|
||||
select_pos(xTabs, "2")
|
||||
# Read the value
|
||||
xSizeField = xDialog.getChild("cbWestSize")
|
||||
displayed_value = get_state_as_dict(xSizeField)["Text"]
|
||||
|
||||
# Verify it's still 80% (not converted to absolute value)
|
||||
self.assertEqual(displayed_value, "80%",
|
||||
"Percentage value was not preserved")
|
||||
|
||||
def test_point_relative_font_size_in_cell_style(self):
|
||||
"""Test that +2pt font size is preserved in cell style."""
|
||||
with self.ui_test.create_doc_in_start_center("calc"):
|
||||
|
||||
# Create a new cell style
|
||||
with self.ui_test.execute_dialog_through_command(
|
||||
".uno:StyleNewByExample") as xDialog:
|
||||
xStyleName = xDialog.getChild("stylename")
|
||||
xStyleName.executeAction("CLEAR", tuple())
|
||||
type_text(xStyleName, "Test PtRelative Size")
|
||||
|
||||
# Edit the style and set +2pt
|
||||
with self.ui_test.execute_blocking_action(
|
||||
self.xUITest.executeCommandWithParameters,
|
||||
args=(".uno:EditStyle",
|
||||
mkPropertyValues({"Param": "Test PtRelative Size",
|
||||
"Family": "CellStyles"}))) as xDialog:
|
||||
|
||||
# Go to Font tab
|
||||
xTabs = xDialog.getChild("tabcontrol")
|
||||
select_pos(xTabs, "2")
|
||||
# Set +2pt
|
||||
xSizeField = xDialog.getChild("cbWestSize")
|
||||
xSizeField.executeAction("CLEAR", tuple())
|
||||
type_text(xSizeField, "+2pt")
|
||||
|
||||
# Reopen and verify
|
||||
with self.ui_test.execute_blocking_action(
|
||||
self.xUITest.executeCommandWithParameters,
|
||||
args=(".uno:EditStyle",
|
||||
mkPropertyValues({"Param": "Test PtRelative Size",
|
||||
"Family": "CellStyles"}))) as xDialog:
|
||||
|
||||
# Go to Font tab
|
||||
xTabs = xDialog.getChild("tabcontrol")
|
||||
select_pos(xTabs, "2")
|
||||
# Read the value
|
||||
xSizeField = xDialog.getChild("cbWestSize")
|
||||
displayed_value = get_state_as_dict(xSizeField)["Text"]
|
||||
|
||||
# Verify it's still +2pt (accept both "+2pt" and "+2 pt")
|
||||
self.assertIn(displayed_value.replace(" ", ""), ["+2pt"],
|
||||
f"Expected '+2pt' or '+2 pt', got '{displayed_value}'")
|
||||
|
||||
def test_negative_point_relative_font_size(self):
|
||||
"""Test that -2pt font size is preserved in cell style."""
|
||||
with self.ui_test.create_doc_in_start_center("calc"):
|
||||
|
||||
# Create a new cell style
|
||||
with self.ui_test.execute_dialog_through_command(
|
||||
".uno:StyleNewByExample") as xDialog:
|
||||
xStyleName = xDialog.getChild("stylename")
|
||||
xStyleName.executeAction("CLEAR", tuple())
|
||||
type_text(xStyleName, "Test NegRelative Size")
|
||||
|
||||
# Edit the style and set -2pt
|
||||
with self.ui_test.execute_blocking_action(
|
||||
self.xUITest.executeCommandWithParameters,
|
||||
args=(".uno:EditStyle",
|
||||
mkPropertyValues({"Param": "Test NegRelative Size",
|
||||
"Family": "CellStyles"}))) as xDialog:
|
||||
|
||||
# Go to Font tab
|
||||
xTabs = xDialog.getChild("tabcontrol")
|
||||
select_pos(xTabs, "2")
|
||||
# Set -2pt
|
||||
xSizeField = xDialog.getChild("cbWestSize")
|
||||
xSizeField.executeAction("CLEAR", tuple())
|
||||
type_text(xSizeField, "-2pt")
|
||||
|
||||
# Reopen and verify
|
||||
with self.ui_test.execute_blocking_action(
|
||||
self.xUITest.executeCommandWithParameters,
|
||||
args=(".uno:EditStyle",
|
||||
mkPropertyValues({"Param": "Test NegRelative Size",
|
||||
"Family": "CellStyles"}))) as xDialog:
|
||||
|
||||
# Go to Font tab
|
||||
xTabs = xDialog.getChild("tabcontrol")
|
||||
select_pos(xTabs, "2")
|
||||
# Read the value
|
||||
xSizeField = xDialog.getChild("cbWestSize")
|
||||
displayed_value = get_state_as_dict(xSizeField)["Text"]
|
||||
|
||||
# Verify it's still -2pt (accept both "-2pt" and "-2 pt")
|
||||
self.assertIn(displayed_value.replace(" ", ""), ["-2pt"],
|
||||
f"Expected '-2pt' or '-2 pt', got '{displayed_value}'")
|
||||
|
||||
def test_edit_root_style_relative_font_size_no_crash(self):
|
||||
"""Test that setting a relative font size on root Default style (no parent) does not crash."""
|
||||
with self.ui_test.create_doc_in_start_center("calc"):
|
||||
with self.ui_test.execute_blocking_action(
|
||||
self.xUITest.executeCommandWithParameters,
|
||||
args=(".uno:EditStyle",
|
||||
mkPropertyValues({"Param": "Default",
|
||||
"Family": "CellStyles"}))) as xDialog:
|
||||
xTabs = xDialog.getChild("tabcontrol")
|
||||
select_pos(xTabs, "2")
|
||||
xSizeField = xDialog.getChild("cbWestSize")
|
||||
xSizeField.executeAction("CLEAR", tuple())
|
||||
type_text(xSizeField, "80%")
|
||||
|
||||
|
||||
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|
||||
@@ -20,6 +20,7 @@
|
||||
#undef SC_DLLIMPLEMENTATION
|
||||
|
||||
#include <svx/drawitem.hxx>
|
||||
#include <svx/flagsdef.hxx>
|
||||
#include <svx/ofaitem.hxx>
|
||||
#include <svx/svdview.hxx>
|
||||
#include <svx/numinf.hxx>
|
||||
@@ -136,6 +137,8 @@ void ScStyleDlg::PageCreated(const OUString& rPageId, SfxTabPage& rTabPage)
|
||||
assert(pInfoItem && "FontListItem not found!");
|
||||
|
||||
aSet.Put(SvxFontListItem(pInfoItem->GetFontList(), SID_ATTR_CHAR_FONTLIST));
|
||||
if (rTabPage.GetItemSet().GetParent())
|
||||
aSet.Put(SfxUInt32Item(SID_FLAG_TYPE, SVX_RELATIVE_MODE));
|
||||
rTabPage.PageCreated(aSet);
|
||||
}
|
||||
else if (rPageId == "background")
|
||||
|
||||
Reference in New Issue
Block a user