Kaydet (Commit) 655154e4 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Justin Luth

tdf#118244 pdfexport: radio buttons can group with same name

The old implementation grouped radio buttons if their
object name was the same, and didn't have a groupname property.

The old implementation still works - so that still needs to be
supported, which this patch ensures.

Change-Id: Ied6ddc52d1c4ab5bca56b14da51258460ca2120c
Reviewed-on: https://gerrit.libreoffice.org/62812
Tested-by: Jenkins
Reviewed-by: 's avatarJustin Luth <justin_luth@sil.org>
üst 80400973
......@@ -132,7 +132,7 @@ namespace toolkitform
// host document makes it somewhat difficult ...
// Problem is that two form radio buttons belong to the same group if
// - they have the same parent
// - AND they have the same group name
// - AND they have the same name or group name
// This implies that we need some knowledge about (potentially) *all* radio button
// groups in the document.
......@@ -164,6 +164,7 @@ namespace toolkitform
do
{
std::unordered_map<OUString,sal_Int32> GroupNameMap;
std::unordered_map<OUString,sal_Int32> SharedNameMap;
sal_Int32 nCount = xCurrentContainer->getCount();
sal_Int32 i;
for ( i = nStartWithChild; i < nCount; ++i )
......@@ -203,12 +204,25 @@ namespace toolkitform
OUString sGroupName;
aProps->getPropertyValue("GroupName") >>= sGroupName;
// map: unique key is the group name, so attempts to add a different ID value
// for an existing group are ignored - keeping the first ID - perfect for this scenario.
GroupNameMap.emplace( sGroupName, nGroupsEncountered + i );
if ( !sGroupName.isEmpty() )
{
// map: unique key is the group name, so attempts to add a different ID value
// for an existing group are ignored - keeping the first ID - perfect for this scenario.
GroupNameMap.emplace( sGroupName, nGroupsEncountered + i );
if ( xElement.get() == xNormalizedLookup.get() )
return GroupNameMap[sGroupName];
}
else
{
// Old implementation didn't have a GroupName, just identical Control names.
aProps->getPropertyValue( FM_PROP_NAME ) >>= sGroupName;
SharedNameMap.emplace( sGroupName, nGroupsEncountered + i );
if ( xElement.get() == xNormalizedLookup.get() )
return SharedNameMap[sGroupName];
}
if ( xElement.get() == xNormalizedLookup.get() )
return GroupNameMap[sGroupName];
}
}
catch( uno::Exception& )
......
......@@ -902,13 +902,13 @@ void PdfExportTest::testTdf118244_radioButtonGroup()
{
size_t expectedSize = 2;
++nRadioGroups;
if ( nRadioGroups == 2 )
expectedSize = 5;
if ( nRadioGroups == 3 )
expectedSize = 3;
CPPUNIT_ASSERT_EQUAL(expectedSize, pKids->GetElements().size());
}
}
}
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of radio groups", sal_uInt32(2), nRadioGroups);
CPPUNIT_ASSERT_EQUAL_MESSAGE("# of radio groups", sal_uInt32(3), nRadioGroups);
}
#if HAVE_MORE_FONTS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment