[Libreoffice-commits] core.git: toolkit/source vcl/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Nov 5 05:54:12 UTC 2018
toolkit/source/helper/formpdfexport.cxx | 26 ++++++++++++++++++++------
vcl/qa/cppunit/pdfexport/pdfexport.cxx | 6 +++---
2 files changed, 23 insertions(+), 9 deletions(-)
New commits:
commit 655154e45abfe6c69b97ad5c615f231be4b3827a
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Sat Nov 3 18:01:42 2018 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Mon Nov 5 06:53:25 2018 +0100
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 <justin_luth at sil.org>
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<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& )
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 71fd198a0e35..80cb72fc1dff 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -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
More information about the Libreoffice-commits
mailing list