include/vcl/errinf.hxx | 6 ++++++ sfx2/source/doc/objserv.cxx | 35 ++++++++++++++++++++++++++++++++--- vcl/source/window/errinf.cxx | 6 ------ 3 files changed, 38 insertions(+), 9 deletions(-)
New commits: commit 1a463987633bfdd58aac60a39ce6eb09ff8c500d Author: Szymon Kłos <[email protected]> AuthorDate: Tue Oct 20 22:05:11 2020 +0200 Commit: Szymon Kłos <[email protected]> CommitDate: Wed Oct 21 10:48:27 2020 +0200 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 <[email protected]> Reviewed-by: Ashod Nakashian <[email protected]> diff --git a/include/vcl/errinf.hxx b/include/vcl/errinf.hxx index 76ee7aca37aa..b3029e7c5de3 100644 --- a/include/vcl/errinf.hxx +++ b/include/vcl/errinf.hxx @@ -39,6 +39,12 @@ class DynamicErrorInfo; class ImplDynamicErrorInfo; enum class DialogMask; +class VCL_DLLPUBLIC ErrorStringFactory +{ +public: + static bool CreateString(const ErrorInfo*, OUString&); +}; + typedef void (* DisplayFnPtr)(); typedef DialogMask WindowDisplayErrorFunc( diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 55e36ff69cbb..3ebb1feb5f70 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -69,6 +69,8 @@ #include <comphelper/documentconstants.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/storagehelper.hxx> +#include <comphelper/lok.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <tools/link.hxx> #include <sfx2/asyncfunc.hxx> @@ -454,6 +456,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(); @@ -956,8 +976,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 && @@ -1123,7 +1148,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(); diff --git a/vcl/source/window/errinf.cxx b/vcl/source/window/errinf.cxx index 31bec6e085a0..19b01c0e1a4a 100644 --- a/vcl/source/window/errinf.cxx +++ b/vcl/source/window/errinf.cxx @@ -30,12 +30,6 @@ class ErrorHandler; class TheErrorRegistry: public rtl::Static<ErrorRegistry, TheErrorRegistry> {}; -class ErrorStringFactory -{ -public: - static bool CreateString(const ErrorInfo*, OUString&); -}; - bool ErrorStringFactory::CreateString(const ErrorInfo* pInfo, OUString& rStr) { for(const ErrorHandler *pHdlr : TheErrorRegistry::get().errorHandlers) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
