include/vcl/errinf.hxx | 6 ++++++ sfx2/source/doc/objserv.cxx | 37 ++++++++++++++++++++++++++++++++++--- vcl/source/window/errinf.cxx | 6 ------ 3 files changed, 40 insertions(+), 9 deletions(-)
New commits: commit 61b1aae3c56f604a84cdc6c5bef21a9b2048188e Author: Szymon Kłos <[email protected]> AuthorDate: Tue Oct 20 22:05:11 2020 +0200 Commit: Andras Timar <[email protected]> CommitDate: Tue Apr 6 21:31:11 2021 +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]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106418 Tested-by: Jenkins Reviewed-by: Szymon Kłos <[email protected]> diff --git a/include/vcl/errinf.hxx b/include/vcl/errinf.hxx index 4a0edc75b259..88f4a3bb2390 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 83327103c1f0..09ae778082af 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; @@ -443,6 +447,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(); @@ -988,8 +1010,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 && @@ -1155,7 +1182,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 8e08dc361acd..d9c4310f0a06 100644 --- a/vcl/source/window/errinf.cxx +++ b/vcl/source/window/errinf.cxx @@ -35,12 +35,6 @@ 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
