sc/qa/unit/subsequent_export_test4.cxx | 25 ++++++++++++++++++++++++- sc/source/filter/excel/xeescher.cxx | 8 ++++++++ 2 files changed, 32 insertions(+), 1 deletion(-)
New commits: commit df5974ca5bb15eb58295fea7db00f5db72344bc8 Author: Justin Luth <[email protected]> AuthorDate: Mon Dec 8 21:29:24 2025 -0500 Commit: Justin Luth <[email protected]> CommitDate: Wed Dec 10 20:46:49 2025 +0100 xlsx: export activeX control as transparent Using Excel 2024, I saved the control with a black, a blue, and a transparent background. The only differences in the files were in the activeX/activeX1.bin file, and in the media/image1.emf file. Currently we can't use LO to save different colours anyway, so if we are only going to support one choice, then the best choice is transparent - which is the default of a new control. make CppunitTest_sc_subsequent_export_test4 \ CPPUNIT_TEST_NAME=testCheckboxFormControlXlsxExport Change-Id: I6d4a24fa43d4c12ce412d5bf3abb02e7347d3efc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195263 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195309 diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 5aa6ab7dbb0d..c5796a169842 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -1104,6 +1104,11 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testCheckboxFormControlXlsxExport) xPropertySet->getPropertyValue(u"VisualEffect"_ustr) >>= nStyle; // without the fix, this was 1 (3d) CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nStyle); // flat + + Color aColor; + xPropertySet->getPropertyValue(u"BackgroundColor"_ustr) >>= aColor; + // without the fix, this was white + CPPUNIT_ASSERT_EQUAL(COL_BLACK, aColor); // black apparently == transparent } CPPUNIT_TEST_FIXTURE(ScExportTest4, testButtonFormControlXlsxExport) diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index f7e0e3005cc2..dfc43605c732 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1138,6 +1138,9 @@ 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"); + return VMLExport::StartShape(); } commit f515255cf5ef11a7bee38094f8b1781eca77d668 Author: Justin Luth <[email protected]> AuthorDate: Mon Dec 8 20:17:31 2025 -0500 Commit: Justin Luth <[email protected]> CommitDate: Wed Dec 10 20:46:34 2025 +0100 xlsx: export activeX control's 3D/Flat style make CppunitTest_sc_subsequent_export_test4 \ CPPUNIT_TEST_NAME=testCheckboxFormControlXlsxExport Change-Id: I2a059254e212eabf3a2d90d510167236154ac24b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195262 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195308 diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index e3d84bc5cfda..5aa6ab7dbb0d 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -47,6 +47,7 @@ #include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <com/sun/star/drawing/LineJoint.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XDrawPages.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> @@ -1079,13 +1080,30 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testCheckboxFormControlXlsxExport) createScDoc("xlsx/checkbox-form-control.xlsx"); // When exporting to XLSX: - save(TestFilter::XLSX); + saveAndReload(TestFilter::XLSX); // Then make sure its VML markup is written and it has a correct position + size: xmlDocUniquePtr pDoc = parseExport(u"xl/drawings/vmlDrawing1.vml"_ustr); // Without the fix in place, this test would have failed as there was no such stream. CPPUNIT_ASSERT(pDoc); assertXPathContent(pDoc, "/xml/v:shape/xx:ClientData/xx:Anchor", u"1, 22, 3, 3, 3, 30, 6, 1"); + + // reloaded document: make sure it still has a flat (non-3d) look + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIA_DrawPage( + xDrawPagesSupplier->getDrawPages()->getByIndex(0), UNO_QUERY_THROW); + uno::Reference<drawing::XControlShape> xControlShape(xIA_DrawPage->getByIndex(0), + UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY); + + OUString sLabel; + xPropertySet->getPropertyValue(u"Label"_ustr) >>= sLabel; + CPPUNIT_ASSERT_EQUAL(u"Check Box 1"_ustr, sLabel); + + sal_Int16 nStyle; + xPropertySet->getPropertyValue(u"VisualEffect"_ustr) >>= nStyle; + // without the fix, this was 1 (3d) + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), nStyle); // flat } CPPUNIT_TEST_FIXTURE(ScExportTest4, testButtonFormControlXlsxExport) diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 7b9225cc491e..f7e0e3005cc2 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1102,6 +1102,7 @@ public: const tools::Rectangle& rAreaFrom, const tools::Rectangle& rAreaTo, const OUString& sControlName, const OUString& sFmlaLink, OUString aLabel, OUString aMacroName, sal_Int16 nState); + bool m_bLook3d = true; protected: using VMLExport::StartShape; @@ -1180,6 +1181,9 @@ void VmlFormControlExporter::EndShape(sal_Int32 nShapeElement) XclXmlUtils::WriteElement(pVmlDrawing, FSNS(XML_x, XML_Checked), "1"); } + if (!m_bLook3d) + pVmlDrawing->singleElement(FSNS(XML_x, XML_NoThreeD)); + // XclExpOcxControlObj::WriteSubRecs() has the same fixed values. if (m_nObjType == EXC_OBJTYPE_BUTTON) { @@ -1216,6 +1220,7 @@ void XclExpTbxControlObj::SaveVml(XclExpXmlStream& rStrm) mnState); aFormControlExporter.SetSkipwzName(true); // use XML_id for legacyid, not XML_ID aFormControlExporter.OverrideShapeIDGen(true, "_x0000_s"_ostr); + aFormControlExporter.m_bLook3d = !mbFlatButton; aFormControlExporter.AddSdrObject(*pObj, /*bIsFollowingTextFlow=*/false, /*eHOri=*/-1, /*eVOri=*/-1, /*eHRel=*/-1, /*eVRel=*/-1, /*pWrapAttrList=*/nullptr, /*bOOxmlExport=*/true, mnShapeId);
