diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-10-20 22:05:11 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-11-24 18:20:18 +0100 |
commit | d5ede20e0a7be77ba0415996395cade8db04f797 (patch) | |
tree | 0510ccbbff866d70f2d121cae838751814ee3f1e /sfx2/source | |
parent | d5552b8bb29c01cab4624f07dc2539a9673e7482 (diff) |
lok: Log save errors and avoid infinite loop
Don't create synchronous dialogs on errors
which were causing infinite loops.
Just send error for logging purposes.
Change-Id: I88e57ae34502a6f82e44051033c91ca41c1a7b8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104579
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ash@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106418
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/doc/objserv.cxx | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 404b7422017c..ef9925549149 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -61,6 +61,8 @@ #include <vcl/weld.hxx> #include <comphelper/documentconstants.hxx> #include <comphelper/storagehelper.hxx> +#include <comphelper/lok.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <tools/link.hxx> #include <asyncfunc.hxx> @@ -107,6 +109,8 @@ #include <autoredactdialog.hxx> +#include <boost/property_tree/json_parser.hpp> + using namespace ::com::sun::star; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; @@ -438,6 +442,24 @@ uno::Reference<security::XCertificate> SfxObjectShell::GetSignPDFCertificate() c return uno::Reference<security::XCertificate>(it->second, uno::UNO_QUERY); } +static void sendErrorToLOK(ErrCode error) +{ + boost::property_tree::ptree aTree; + aTree.put("code", error); + aTree.put("kind", ""); + aTree.put("cmd", ""); + + std::unique_ptr<ErrorInfo> pInfo = ErrorInfo::GetErrorInfo(error); + OUString aErr; + if (ErrorStringFactory::CreateString(pInfo.get(), aErr)) + aTree.put("message", aErr.toUtf8()); + + std::stringstream aStream; + boost::property_tree::write_json(aStream, aTree); + + SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_CALLBACK_ERROR, aStream.str().c_str()); +} + void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) { weld::Window* pDialogParent = rReq.GetFrameWeld(); @@ -983,8 +1005,13 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) // may be nErrorCode should be shown in future if ( lErr != ERRCODE_IO_ABORT ) { - SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC,GetTitle()); - ErrorHandler::HandleError(lErr, pDialogParent); + if (comphelper::LibreOfficeKit::isActive()) + sendErrorToLOK(lErr); + else + { + SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC,GetTitle()); + ErrorHandler::HandleError(lErr, pDialogParent); + } } if (nId == SID_DIRECTEXPORTDOCASPDF && @@ -1150,7 +1177,11 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) SetModified( false ); ErrCode lErr = GetErrorCode(); - ErrorHandler::HandleError(lErr, pDialogParent); + + if (comphelper::LibreOfficeKit::isActive()) + sendErrorToLOK(lErr); + else + ErrorHandler::HandleError(lErr, pDialogParent); rReq.SetReturnValue( SfxBoolItem(0, true) ); rReq.Done(); |