summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmlerror.cxx26
-rw-r--r--xmloff/source/core/xmlexp.cxx7
-rw-r--r--xmloff/source/core/xmlimp.cxx2
3 files changed, 32 insertions, 3 deletions
diff --git a/xmloff/source/core/xmlerror.cxx b/xmloff/source/core/xmlerror.cxx
index 75315f78e077..6079797e823b 100644
--- a/xmloff/source/core/xmlerror.cxx
+++ b/xmloff/source/core/xmlerror.cxx
@@ -27,6 +27,10 @@
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <rtl/ustrbuf.hxx>
+#include <comphelper/lok.hxx>
+#include <tools/json_writer.hxx>
+#include <vcl/IDialogRenderable.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Sequence;
@@ -78,7 +82,8 @@ ErrorRecord::ErrorRecord( sal_Int32 nID, const Sequence<OUString>& rParams,
{
}
-XMLErrors::XMLErrors()
+XMLErrors::XMLErrors(vcl::ILibreOfficeKitNotifier* pNotifier)
+ : mpNotifier(pNotifier)
{
}
@@ -98,6 +103,25 @@ void XMLErrors::AddRecord(
m_aErrors.emplace_back( nId, rParams, rExceptionMessage,
nRow, nColumn, rPublicId, rSystemId );
+ if (comphelper::LibreOfficeKit::isActive() && mpNotifier)
+ {
+ // The outer error is logged in sfx2, mentioning just the stream name. Also log here the
+ // inner error, which potentially contains the location of an uncaught exception.
+ sal_Int32 nFlags = (nId & XMLERROR_MASK_FLAG);
+ if (nFlags & (XMLERROR_FLAG_ERROR | XMLERROR_FLAG_SEVERE | XMLERROR_API))
+ {
+ tools::JsonWriter aWriter;
+ {
+ aWriter.put("classification", "error");
+ aWriter.put("code", "");
+ aWriter.put("kind", "");
+ aWriter.put("cmd", "");
+ aWriter.put("message", rExceptionMessage);
+ }
+ mpNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_ERROR, aWriter.finishAndGetAsOString());
+ }
+ }
+
#ifdef DBG_UTIL
// give detailed assertion on this message
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 2cec3eb32f89..4d77d6bc26db 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -2286,7 +2286,7 @@ void SvXMLExport::SetError(
// create error list on demand
if ( mpXMLErrors == nullptr )
- mpXMLErrors.reset( new XMLErrors() );
+ mpXMLErrors.reset( new XMLErrors(mpNotifier) );
// save error information
mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator );
@@ -2442,6 +2442,11 @@ OUString const & SvXMLExport::GetImageFilterName() const
return msImgFilterName;
}
+void SvXMLExport::SetLibreOfficeKitNotifier(vcl::ILibreOfficeKitNotifier* pNotifier)
+{
+ mpNotifier = pNotifier;
+}
+
void SvXMLElementExport::StartElement(
const sal_uInt16 nPrefixKey,
const OUString& rLName,
diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx
index 3c405d21a0d0..94bf7e41b7a7 100644
--- a/xmloff/source/core/xmlimp.cxx
+++ b/xmloff/source/core/xmlimp.cxx
@@ -1784,7 +1784,7 @@ void SvXMLImport::SetError(
{
// create error list on demand
if ( !mpXMLErrors )
- mpXMLErrors = std::make_unique<XMLErrors>();
+ mpXMLErrors = std::make_unique<XMLErrors>(nullptr);
// save error information
// use document locator (if none supplied)