diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-09-27 21:46:18 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2018-09-28 09:57:28 +0200 |
commit | 9f969799629fe6bdf8b922d8cb922846aa646ece (patch) | |
tree | d3a805f0bf8def11edc1b1f076c388e1ce24a23f /sc | |
parent | 598f2ee618a2bb14a13630168dd82601e2c8f69f (diff) |
tdf#111980 oox: connect empty radio groups
affects doc, docx, xls, xlsx (at least). Handling optionbutton
groups is new since 2017, so incremental enhancements are OK.
In LO, if an option button with an empty groupName (like any form
control which has no groupName option), then it stands alone,
which is a ridiculous position to be in for a radio button.
So, lets put them all together into an automatic group.
In MSO, buttons without any explicit group stick together,
so the effective group is the entire document, or entire sheet.
One complication is that ActiveX radio buttons don't
interact with Form radio buttons, even if all of them
have no group name. That situation is not handled by
this patch (and not very likely to happen since ActiveX
defaults the group name to the sheet name).
(A Group Box can also be used, which automatically groups
all buttons fully within its area. That will be much harder
to implement since every object will need to first be
categorized as groupbox or optionControl - meaning that everything
must first be imported. That implies a function call from every
application doing the import.)
Change-Id: I204adaea75ce99999a16c0cc4e9c3b8b08da9433
Reviewed-on: https://gerrit.libreoffice.org/61064
Tested-by: Jenkins
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf111980_radioButtons.xlsx | bin | 0 -> 20005 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 32 |
2 files changed, 32 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/tdf111980_radioButtons.xlsx b/sc/qa/unit/data/xlsx/tdf111980_radioButtons.xlsx Binary files differnew file mode 100644 index 000000000000..9f97d9e00a48 --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf111980_radioButtons.xlsx diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index b896d3e47370..ef2b5ee22aef 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -177,6 +177,7 @@ public: //test shape import void testControlImport(); + void testActiveXOptionButtonGroup(); void testChartImportODS(); #if HAVE_MORE_FONTS void testChartImportXLS(); @@ -290,6 +291,7 @@ public: CPPUNIT_TEST(testCellValueXLSX); CPPUNIT_TEST(testRowIndex1BasedXLSX); CPPUNIT_TEST(testControlImport); + CPPUNIT_TEST(testActiveXOptionButtonGroup); CPPUNIT_TEST(testChartImportODS); #if HAVE_MORE_FONTS CPPUNIT_TEST(testChartImportXLS); @@ -1676,6 +1678,36 @@ void ScFiltersTest::testControlImport() xDocSh->DoClose(); } +void ScFiltersTest::testActiveXOptionButtonGroup() +{ + ScDocShellRef xDocSh = loadDoc("tdf111980_radioButtons.", FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load singlecontrol.xlsx", xDocSh.is()); + uno::Reference< frame::XModel > xModel = xDocSh->GetModel(); + uno::Reference< sheet::XSpreadsheetDocument > xDoc(xModel, UNO_QUERY_THROW); + uno::Reference< container::XIndexAccess > xIA(xDoc->getSheets(), UNO_QUERY_THROW); + uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xIA->getByIndex(0), UNO_QUERY_THROW); + uno::Reference< container::XIndexAccess > xIA_DrawPage(xDrawPageSupplier->getDrawPage(), UNO_QUERY_THROW); + + OUString sGroupName; + uno::Reference< drawing::XControlShape > xControlShape(xIA_DrawPage->getByIndex(0), UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY_THROW); + xPropertySet->getPropertyValue("GroupName") >>= sGroupName; + CPPUNIT_ASSERT_EQUAL(OUString("Sheet1"), sGroupName); + + // Form optionbuttons (without Group names) were not grouped. + // The two optionbuttons should have the same auto-generated group name. + xControlShape.set(xIA_DrawPage->getByIndex(4), uno::UNO_QUERY_THROW); + xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY_THROW); + xPropertySet->getPropertyValue("GroupName") >>= sGroupName; + CPPUNIT_ASSERT_EQUAL(false, sGroupName.isEmpty()); + + OUString sGroupName5; + xControlShape.set(xIA_DrawPage->getByIndex(5), uno::UNO_QUERY_THROW); + xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY_THROW); + xPropertySet->getPropertyValue("GroupName") >>= sGroupName5; + CPPUNIT_ASSERT_EQUAL(sGroupName, sGroupName5); +} + void ScFiltersTest::testChartImportODS() { ScDocShellRef xDocSh = loadDoc("chart-import-basic.", FORMAT_ODS); |