[Libreoffice-commits] core.git: embeddedobj/source include/svtools sfx2/source svtools/source

2023-09-28 Thread Mike Kaganski (via logerrit)
 embeddedobj/source/msole/olecomponent.cxx |   24 ++--
 include/svtools/ehdl.hxx  |5 +
 sfx2/source/view/ipclient.cxx |3 ++-
 svtools/source/misc/ehdl.cxx  |   12 
 4 files changed, 41 insertions(+), 3 deletions(-)

New commits:
commit 11aa86140eaac3d1d67db1f337fc1c76a511778f
Author: Mike Kaganski 
AuthorDate: Thu Sep 28 15:15:53 2023 +0300
Commit: Mike Kaganski 
CommitDate: Thu Sep 28 16:02:55 2023 +0200

Improve OleRun error reporting

1. Pass its error message up the call stack as the exception's message.
2. In case of REGDB_E_CLASSNOTREG, also obtain the object's class name
   and append it to the message.
3. Show this information in the message displayed for OLE activation
   error.

This introduces a new SetExtendedMessage method in SfxErrorContext to
store extra information for specific errors.

Change-Id: Id3863276266d992ae407fbfa5568acf5c57aa96f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157372
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/embeddedobj/source/msole/olecomponent.cxx 
b/embeddedobj/source/msole/olecomponent.cxx
index fcd659e369a3..f981a4304656 100644
--- a/embeddedobj/source/msole/olecomponent.cxx
+++ b/embeddedobj/source/msole/olecomponent.cxx
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -883,10 +884,29 @@ void OleComponent::RunObject()
 
 if ( FAILED( hr ) )
 {
+OUString error = WindowsErrorStringFromHRESULT(hr);
 if ( hr == REGDB_E_CLASSNOTREG )
-throw embed::UnreachableStateException(); // the object server 
is not installed
+{
+if (auto pOleObj
+= 
m_pNativeImpl->m_pObj.QueryInterface(sal::systools::COM_QUERY))
+{
+LPOLESTR lpUserType = nullptr;
+if (SUCCEEDED(pOleObj->GetUserType(USERCLASSTYPE_FULL, 
)))
+{
+error += OUString::Concat("\n") + 
o3tl::toU(lpUserType);
+sal::systools::COMReference pMalloc;
+hr = CoGetMalloc(1, ); // if fails there will 
be a memory leak
+SAL_WARN_IF(FAILED(hr) || !pMalloc, "embeddedobj.ole", 
"CoGetMalloc() failed");
+if (pMalloc)
+pMalloc->Free(lpUserType);
+}
+}
+throw embed::UnreachableStateException(
+error, getXWeak(), -1,
+css::embed::EmbedStates::RUNNING); // the object server is 
not installed
+}
 else
-throw io::IOException();
+throw io::IOException(error, getXWeak());
 }
 }
 }
diff --git a/include/svtools/ehdl.hxx b/include/svtools/ehdl.hxx
index d67f094f818e..78bcf1723dfe 100644
--- a/include/svtools/ehdl.hxx
+++ b/include/svtools/ehdl.hxx
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+#include 
+
 typedef std::pair ErrMsgCode;
 SVT_DLLPUBLIC extern const ErrMsgCode RID_ERRHDL[];
 SVT_DLLPUBLIC extern const ErrMsgCode RID_ERRCTX[];
@@ -40,11 +42,14 @@ public:
 const ErrMsgCode* pIds = nullptr, const std::locale& rResLocaleP = 
SvtResLocale());
 bool GetString(ErrCode nErrId, OUString ) override;
 
+void SetExtendedMessage(ErrCode nErrId, const OUString& rStr);
+
 private:
 sal_uInt16 nCtxId;
 const ErrMsgCode* pIds;
 std::locale aResLocale;
 OUString aArg1;
+std::unordered_map m_extMessages;
 };
 
 class SVT_DLLPUBLIC SfxErrorHandler : private ErrorHandler
diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx
index 367d3070938b..260bdff77f34 100644
--- a/sfx2/source/view/ipclient.cxx
+++ b/sfx2/source/view/ipclient.cxx
@@ -970,7 +970,7 @@ ErrCode SfxInPlaceClient::DoVerb(sal_Int32 nVerb)
 
 m_xImp->m_xObject->doVerb( nVerb );
 }
-catch ( embed::UnreachableStateException& )
+catch ( embed::UnreachableStateException& e )
 {
 if (nVerb == embed::EmbedVerbs::MS_OLEVERB_PRIMARY || 
nVerb == embed::EmbedVerbs::MS_OLEVERB_OPEN || nVerb == 
embed::EmbedVerbs::MS_OLEVERB_SHOW)
 {
@@ -997,6 +997,7 @@ ErrCode SfxInPlaceClient::DoVerb(sal_Int32 nVerb)
 {
 TOOLS_WARN_EXCEPTION("embeddedobj", 
"SfxInPlaceClient::DoVerb: -9 fallback path");
 nError = ERRCODE_SO_GENERALERROR;
+aEc.SetExtendedMessage(ERRCODE_SO_GENERALERROR, 
e.Message);
 }
 }
 }
diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx
index a2cd3ef63323..ef35b3975fca 100644
--- a/svtools/source/misc/ehdl.cxx
+++ 

[Libreoffice-commits] core.git: embeddedobj/source include/svtools

2022-05-11 Thread Andrea Gelmini (via logerrit)
 embeddedobj/source/commonembedding/miscobj.cxx |2 +-
 include/svtools/embedhlp.hxx   |2 +-
 include/svtools/filechangedchecker.hxx |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit c61a88d9d23366274d4d2283a961a578911e5ddc
Author: Andrea Gelmini 
AuthorDate: Tue May 10 10:17:41 2022 +0200
Commit: Bartosz Kosiorek 
CommitDate: Wed May 11 10:25:52 2022 +0200

Fix typos

Change-Id: Ie15016f4cbed703f15d7d47c25b7bfc2b41dbadb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134106
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek 

diff --git a/embeddedobj/source/commonembedding/miscobj.cxx 
b/embeddedobj/source/commonembedding/miscobj.cxx
index f41d35957b5d..d8d9a74700c1 100644
--- a/embeddedobj/source/commonembedding/miscobj.cxx
+++ b/embeddedobj/source/commonembedding/miscobj.cxx
@@ -436,7 +436,7 @@ void OCommonEmbeddedObject::handleLinkedOLE( 
CopyBackToOLELink eState )
 else if ( ( eState == CopyBackToOLELink::CopyLinkToTemp ) && bTmpFileChg )
 {
 // Refresh pressed,  but the Temp-file is changed, question to user 
for overwrite
-// it is not importent it has bLnkFileChg, always overwite the 
temp-file
+// it is not important it has bLnkFileChg, always overwrite the 
temp-file
 if ( ShowMsgDialog( STR_OVERWRITE_TEMP, m_aLinkURL ) == RET_CANCEL )
 eState = CopyBackToOLELink::NoCopy;
 }
diff --git a/include/svtools/embedhlp.hxx b/include/svtools/embedhlp.hxx
index 4930e5b7630b..e87ebfbf9b6e 100644
--- a/include/svtools/embedhlp.hxx
+++ b/include/svtools/embedhlp.hxx
@@ -102,7 +102,7 @@ public:
 const css::uno::Reference< css::io::XInputStream >& 
xInGrStream,
 const OUString& rMediaType );
 
-// bUpdateOle = false udate the Link-Objects
+// bUpdateOle = false update the Link-Objects
 //= true  update the OLE-Objects
 voidUpdateReplacement( bool bUpdateOle = false );
 voidUpdateReplacementOnDemand();
diff --git a/include/svtools/filechangedchecker.hxx 
b/include/svtools/filechangedchecker.hxx
index 9800654678fa..d50fea631a92 100644
--- a/include/svtools/filechangedchecker.hxx
+++ b/include/svtools/filechangedchecker.hxx
@@ -40,6 +40,6 @@ public:
 bool hasFileChanged(bool bUpdate = true);
 FileChangedChecker(const OUString& rFilename,
 const ::std::function& rCallback);
-// with out Timer function
+// without Timer function
 FileChangedChecker(const OUString& rFilename);
 };