sc/qa/unit/subsequent_export_test4.cxx | 6 +++--- sc/qa/unit/subsequent_filters_test3.cxx | 25 +++++++++++++++++++++++++ sc/source/filter/excel/xeescher.cxx | 13 +++++++++++-- sc/source/filter/inc/xeescher.hxx | 1 + 4 files changed, 40 insertions(+), 5 deletions(-)
New commits: commit 4ead3338cfe94453f10e717c884c679d03ab16b7 Author: Justin Luth <[email protected]> AuthorDate: Wed Dec 10 12:17:55 2025 -0500 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Dec 12 14:41:51 2025 +0100 xlsx: export activeX control background color make CppunitTest_sc_subsequent_filters_test3 \ CPPUNIT_TEST_NAME=testActiveXCheckboxXLSX Change-Id: I0ff17e37e315bfa8e677fe0a5fde6540f42c06ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195405 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> (cherry picked from commit e9e82e72097add5da29e6d4c904af97a49fb6295) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195460 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 3d02063626f3..2403bb9f2c18 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -1172,10 +1172,10 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testCheckboxFormControlXlsxExport) // without the fix, this was 1 (3d) CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nStyle); // flat - Color aColor; + Color aColor(COL_TRANSPARENT); xPropertySet->getPropertyValue(u"BackgroundColor"_ustr) >>= aColor; - // without the fix, this was white - CPPUNIT_ASSERT_EQUAL(COL_BLACK, aColor); // black apparently == transparent + // without the fix, this was COL_WHITE + CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, aColor); } CPPUNIT_TEST_FIXTURE(ScExportTest4, testButtonFormControlXlsxExport) diff --git a/sc/qa/unit/subsequent_filters_test3.cxx b/sc/qa/unit/subsequent_filters_test3.cxx index afdd54ef2ffc..4370d913b199 100644 --- a/sc/qa/unit/subsequent_filters_test3.cxx +++ b/sc/qa/unit/subsequent_filters_test3.cxx @@ -339,6 +339,31 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testActiveXCheckboxXLSX) sal_Int16 nState; xPropertySet->getPropertyValue(u"State"_ustr) >>= nState; CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState); + + saveAndReload(TestFilter::XLSX); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, UNO_QUERY_THROW); + xIA_DrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(0), UNO_QUERY_THROW); + xControlShape.set(xIA_DrawPage->getByIndex(0), UNO_QUERY_THROW); + xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY); + + xPropertySet->getPropertyValue(u"Label"_ustr) >>= sLabel; + CPPUNIT_ASSERT_EQUAL(u"Custom Caption"_ustr, sLabel); + + sal_Int16 nStyle; + xPropertySet->getPropertyValue(u"VisualEffect"_ustr) >>= nStyle; + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nStyle); // 3d + + nColor = COL_TRANSPARENT; + xPropertySet->getPropertyValue(u"BackgroundColor"_ustr) >>= nColor; + // without the fix, this was COL_WHITE + CPPUNIT_ASSERT_EQUAL(Color(0x316ac5), nColor); + + xPropertySet->getPropertyValue(u"TextColor"_ustr) >>= nColor; + //CPPUNIT_ASSERT_EQUAL(Color(0xD4D0C8), nColor); + + xPropertySet->getPropertyValue(u"State"_ustr) >>= nState; + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nState); } CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf60673) diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 00612e7da182..ccc6cde8174a 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -721,6 +721,10 @@ XclExpTbxControlObj::XclExpTbxControlObj( XclExpObjectManager& rRoot, Reference< aPropOpt.AddOpt( ESCHER_Prop_wzDescription, aAltTxt ); } + ::Color aBackColor; + if (aCtrlProp.GetProperty(aBackColor, u"BackgroundColor"_ustr)) + moBackgroundFill = aBackColor; + // write DFF property set to stream aPropOpt.Commit( mrEscherEx.GetStream() ); @@ -1103,6 +1107,7 @@ public: const OUString& sControlName, const OUString& sFmlaLink, OUString aLabel, OUString aMacroName, sal_Int16 nState); bool m_bLook3d = true; + std::optional<Color> m_oBackgroundFill; protected: using VMLExport::StartShape; @@ -1138,8 +1143,11 @@ sal_Int32 VmlFormControlExporter::StartShape() if (!m_sControlName.isEmpty()) AddShapeAttribute(XML_id, m_sControlName.toUtf8()); - // control background: set filled as false so the control is transparent instead of white - AddShapeAttribute(XML_filled, "f"); + if (m_oBackgroundFill.has_value()) + AddShapeAttribute(XML_fillcolor, + OUString("#" + m_oBackgroundFill->AsRGBHexString()).toUtf8()); + else + AddShapeAttribute(XML_filled, "f"); return VMLExport::StartShape(); } @@ -1224,6 +1232,7 @@ void XclExpTbxControlObj::SaveVml(XclExpXmlStream& rStrm) aFormControlExporter.SetSkipwzName(true); // use XML_id for legacyid, not XML_ID aFormControlExporter.OverrideShapeIDGen(true, "_x0000_s"_ostr); aFormControlExporter.m_bLook3d = !mbFlatButton; + aFormControlExporter.m_oBackgroundFill = moBackgroundFill; aFormControlExporter.AddSdrObject(*pObj, /*bIsFollowingTextFlow=*/false, /*eHOri=*/-1, /*eVOri=*/-1, /*eHRel=*/-1, /*eVRel=*/-1, /*pWrapAttrList=*/nullptr, /*bOOxmlExport=*/true, mnShapeId); diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx index 942c04853a9a..bca4b8801ef2 100644 --- a/sc/source/filter/inc/xeescher.hxx +++ b/sc/source/filter/inc/xeescher.hxx @@ -304,6 +304,7 @@ private: tools::Rectangle maAreaFrom; tools::Rectangle maAreaTo; XclExpObjectManager& mrRoot; + std::optional<::Color> moBackgroundFill; }; //#endif
