xmloff/qa/unit/data/tdf156707_text_form_control_borders.odt |binary xmloff/qa/unit/style.cxx | 25 ++++++++++++ xmloff/source/forms/controlpropertyhdl.cxx | 7 ++- 3 files changed, 31 insertions(+), 1 deletion(-)
New commits: commit 5a617f77ee803eb65051e93f659ef66433879052 Author: Justin Luth <[email protected]> AuthorDate: Wed Oct 9 17:22:07 2024 -0400 Commit: Justin Luth <[email protected]> CommitDate: Thu Oct 10 18:52:22 2024 +0200 tdf#156707 xmloff import: always provide ControlBorder property The problem was that 3d textbox form controls were imported as flat. The default value for ControlBorder is 3d. Since caolan's 7.5.4 63b8e8bda29efbdde0e0bd7f7d2b18d5a9b7b135, all textboxes are initially created with a flat border instead of 3d. Since 3d is the fo:border default (and never specified), the newly created control had no override to force it to 3d. So this patch forces passing a ControlBorder property. On export, since the 3d property is the default value, ControlBorder is no even provided as something to be exported, and therefore only "solid" and "none" are ever exported as fo:border qualifiers. make CppunitTest_xmloff_style CPPUNIT_TEST_NAME=testTdf156707 Change-Id: Ib4541d5e3599dc42af6055062fd709e105bf5d14 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174754 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> diff --git a/xmloff/qa/unit/data/tdf156707_text_form_control_borders.odt b/xmloff/qa/unit/data/tdf156707_text_form_control_borders.odt new file mode 100644 index 000000000000..680832ef347d Binary files /dev/null and b/xmloff/qa/unit/data/tdf156707_text_form_control_borders.odt differ diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx index 29ab7a248d5b..4961989aeb2a 100644 --- a/xmloff/qa/unit/style.cxx +++ b/xmloff/qa/unit/style.cxx @@ -297,6 +297,31 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) } } +CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testTdf156707) +{ + // The file contains a shape with linear gradient fill from red #ff0000 to yellow #ffff00, + // named 'red2yellow' + loadFromFile(u"tdf156707_text_form_control_borders.odt"); + saveAndReload(u"writer8"_ustr); + + uno::Reference<drawing::XShape> xShape = getShape(0); + uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY_THROW); + + sal_uInt16 nBorderStyle = 0; // 0 = none, 1 = 3d [default], 2 = flat + xShapeProperties->getPropertyValue(u"ControlBorder"_ustr) >>= nBorderStyle; + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), nBorderStyle); + + xShape = getShape(1); + xShapeProperties.set(xShape, uno::UNO_QUERY_THROW); + xShapeProperties->getPropertyValue(u"ControlBorder"_ustr) >>= nBorderStyle; + CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), nBorderStyle); + + xShape = getShape(2); + xShapeProperties.set(xShape, uno::UNO_QUERY_THROW); + xShapeProperties->getPropertyValue(u"ControlBorder"_ustr) >>= nBorderStyle; + CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), nBorderStyle); +} + CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew) { // The file contains a shape with linear gradient fill from red #ff0000 to yellow #ffff00, diff --git a/xmloff/source/forms/controlpropertyhdl.cxx b/xmloff/source/forms/controlpropertyhdl.cxx index 162fb0cbe82b..eceb9e67aab3 100644 --- a/xmloff/source/forms/controlpropertyhdl.cxx +++ b/xmloff/source/forms/controlpropertyhdl.cxx @@ -212,8 +212,13 @@ namespace xmloff if ( SvXMLUnitConverter::convertEnum( nStyle, sToken, aBorderTypeMap ) ) { _rValue <<= nStyle; - return true; } + else + { + // The internal LO default is flat, which deviates from the import default of 3d + _rValue <<= sal_uInt16(1); + } + return true; } // try interpreting it as color value
