oox/source/export/shapes.cxx |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

New commits:
commit 1a404361a2d888968068d1db2641d81966e54f42
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue Dec 2 13:35:34 2025 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Tue Dec 2 18:38:32 2025 +0100

    need to catch WrongStateException here
    
    I removed this catch block in
        commit 0e8c798a7f250f01146b21f371385cef19fde73f
        Author: Noel Grandin <[email protected]>
        Date:   Thu Nov 27 10:06:53 2025 +0200
        avoid some unnecessary exception throw/catch as control flow
    
    which is wrong, it was introduced as
       commit a951d70609fa125def231c3d7579e72c381334f5
       Author: Michael Stahl <[email protected]>
       Date:   Mon Jan 11 17:16:24 2016 +0100
       oox: getEntryName() could throw a WrongStateException
       let's guard against that.
    
    Change-Id: I32c46e62f3ec1f8e742aba765ef190701d36b52b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194922
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 695e06272b60..58707153ba8e 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -51,6 +51,7 @@
 #include <com/sun/star/embed/EmbedStates.hpp>
 #include <com/sun/star/embed/XEmbeddedObject.hpp>
 #include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <com/sun/star/embed/WrongStateException.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/graphic/XGraphic.hpp>
 #include <com/sun/star/i18n/ScriptType.hpp>
@@ -2849,7 +2850,17 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const 
Reference< XShape >& xShape )
             xParent->getPropertyValue(u"InteropGrabBag"_ustr) >>= grabBag;
             uno::Reference<embed::XEmbedPersist> xEmbedPersist(xObj, 
uno::UNO_QUERY);
             if (xEmbedPersist)
-                entryName = xEmbedPersist->getEntryName();
+            {
+                // getEntryName() could throw a WrongStateException
+                try
+                {
+                    entryName = xEmbedPersist->getEntryName();
+                }
+                catch (embed::WrongStateException const &)
+                {
+                    TOOLS_WARN_EXCEPTION("oox.shape", 
"ShapeExport::WriteOLE2Shape");
+                }
+            }
         }
     }
 

Reply via email to