unotools/source/config/securityoptions.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
New commits: commit def8f7699661f3ca9d763b6bd5e81759cf5b4e12 Author: Noel Grandin <noelgran...@collabora.co.uk> AuthorDate: Wed Nov 15 10:03:13 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Nov 15 12:03:47 2023 +0100 tdf#158094 Can't remove trusted certificate in Macro Security regression from commit 6ed8c5a0f19901ab413c6610649326b2475c3a8c Author: Noel Grandin <noelgran...@gmail.com> Date: Sun Jul 25 21:35:05 2021 +0200 use officecfg for security options where I accidentally dropped the chunk of code that removes existing entries. Change-Id: I0b183d3c4dc55d5671b4f172e02afd2e4422a37e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159431 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/unotools/source/config/securityoptions.cxx b/unotools/source/config/securityoptions.cxx index 2a9346a3e945..3197c60797d5 100644 --- a/unotools/source/config/securityoptions.cxx +++ b/unotools/source/config/securityoptions.cxx @@ -25,6 +25,9 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/container/XHierarchicalNameAccess.hpp> +#include <com/sun/star/util/XChangesBatch.hpp> #include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> #include <tools/urlobj.hxx> @@ -255,6 +258,18 @@ void SetTrustedAuthors( const std::vector< Certificate >& rAuthors ) // return; Reference<css::container::XHierarchicalNameAccess> xHierarchyAccess = utl::ConfigManager::acquireTree(u"Office.Common/Security/Scripting"); + + // first, clear existing entries + { + Reference<css::container::XNameContainer> xCont; + xHierarchyAccess->getByHierarchicalName(PROPERTYNAME_MACRO_TRUSTEDAUTHORS) >>= xCont; + const Sequence< OUString > aNames = xCont->getElementNames(); + Reference<css::util::XChangesBatch> xBatch(xHierarchyAccess, UNO_QUERY); + for (const OUString& rName : aNames) + xCont->removeByName(rName); + xBatch->commitChanges(); + } + sal_Int32 nCnt = rAuthors.size(); for( sal_Int32 i = 0; i < nCnt; ++i ) {