tdf#158094 Can't remove trusted certificate in Macro Security
regression from
commit 6ed8c5a0f19901ab413c6610649326b2475c3a8c
Author: Noel Grandin <noelgrandin@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.grandin@collabora.co.uk>
(cherry picked from commit def8f7699661f3ca9d763b6bd5e81759cf5b4e12)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159585
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/unotools/source/config/securityoptions.cxx b/unotools/source/config/securityoptions.cxx
index b222b8e..516ba30 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>
@@ -243,6 +246,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 )
{