From 655154e45abfe6c69b97ad5c615f231be4b3827a Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Sat, 3 Nov 2018 18:01:42 +0300 Subject: 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: Justin Luth --- toolkit/source/helper/formpdfexport.cxx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'toolkit') diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx index dd225934a790..4277a72c83ba 100644 --- a/toolkit/source/helper/formpdfexport.cxx +++ b/toolkit/source/helper/formpdfexport.cxx @@ -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 GroupNameMap; + std::unordered_map 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& ) -- cgit v1.2.3