vcl/inc/pdf/EncryptionHashTransporter.hxx    |    6 ++----
 vcl/source/pdf/EncryptionHashTransporter.cxx |   27 +++------------------------
 2 files changed, 5 insertions(+), 28 deletions(-)

New commits:
commit f37c22cecba2483b2a88910aff02dc78b79c7589
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Nov 11 19:08:03 2024 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Dec 3 09:07:49 2024 +0100

    pdf: simplify EncryptionHashTransporter
    
    No need for a map to remember the implementation - we can just
    dynamic_cast to the actual implementation.
    
    Change-Id: If590316023be7f749d270c04b7ad3dc5fa1993b0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176453
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/vcl/inc/pdf/EncryptionHashTransporter.hxx 
b/vcl/inc/pdf/EncryptionHashTransporter.hxx
index 3ed1aa375561..596b6490570a 100644
--- a/vcl/inc/pdf/EncryptionHashTransporter.hxx
+++ b/vcl/inc/pdf/EncryptionHashTransporter.hxx
@@ -28,11 +28,9 @@ namespace vcl::pdf
 */
 class EncryptionHashTransporter : public 
cppu::WeakImplHelper<css::beans::XMaterialHolder>
 {
-    ::std::unique_ptr<::comphelper::Hash> m_pDigest;
-    sal_IntPtr maID;
+    std::unique_ptr<comphelper::Hash> m_pDigest;
     std::vector<sal_uInt8> maOValue;
-
-    static std::map<sal_IntPtr, EncryptionHashTransporter*> sTransporters;
+    sal_IntPtr maID;
 
 public:
     EncryptionHashTransporter();
diff --git a/vcl/source/pdf/EncryptionHashTransporter.cxx 
b/vcl/source/pdf/EncryptionHashTransporter.cxx
index 6ecd43396c3a..057925d57836 100644
--- a/vcl/source/pdf/EncryptionHashTransporter.cxx
+++ b/vcl/source/pdf/EncryptionHashTransporter.cxx
@@ -16,40 +16,19 @@ namespace vcl::pdf
 {
 EncryptionHashTransporter::EncryptionHashTransporter()
     : m_pDigest(new ::comphelper::Hash(::comphelper::HashType::MD5))
+    , maID(reinterpret_cast<sal_IntPtr>(this))
 {
-    maID = reinterpret_cast<sal_IntPtr>(this);
-    while (sTransporters.find(maID) != sTransporters.end()) // paranoia mode
-        maID++;
-    sTransporters[maID] = this;
 }
 
-EncryptionHashTransporter::~EncryptionHashTransporter()
-{
-    sTransporters.erase(maID);
-    SAL_INFO("vcl", "EncryptionHashTransporter freed");
-}
+EncryptionHashTransporter::~EncryptionHashTransporter() {}
 
 EncryptionHashTransporter* EncryptionHashTransporter::getEncHashTransporter(
     const uno::Reference<beans::XMaterialHolder>& xReference)
 {
-    EncryptionHashTransporter* pResult = nullptr;
-    if (xReference.is())
-    {
-        uno::Any aMat(xReference->getMaterial());
-        sal_Int64 nMat = 0;
-        if (aMat >>= nMat)
-        {
-            std::map<sal_IntPtr, EncryptionHashTransporter*>::iterator it
-                = sTransporters.find(static_cast<sal_IntPtr>(nMat));
-            if (it != sTransporters.end())
-                pResult = it->second;
-        }
-    }
+    EncryptionHashTransporter* pResult = 
dynamic_cast<EncryptionHashTransporter*>(xReference.get());
     return pResult;
 }
 
-std::map<sal_IntPtr, EncryptionHashTransporter*> 
EncryptionHashTransporter::sTransporters;
-
 } // end vcl::pdf
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to