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

Muhammet Kara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 30 19:38:08 UTC 2020


 include/sfx2/strings.hrc    |    1 +
 sfx2/source/doc/objserv.cxx |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

New commits:
commit be85a4d7cc7c15472de9d1584837d5bff7640bf9
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Mon Jun 29 22:38:16 2020 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Tue Jun 30 21:37:26 2020 +0200

    Resolves tdf#130436: Crash on redaction without Draw
    
    Change-Id: Iaa418e9ad5c6e9ba1892cbb428a8a381f52c4246
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97458
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>

diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index e845c514049a..c5e61d9ce440 100644
--- a/include/sfx2/strings.hrc
+++ b/include/sfx2/strings.hrc
@@ -208,6 +208,7 @@
 #define STR_REDACTION_JSON_FILE_FILTER          NC_("STR_REDACTION_JSON_FILE_FILTER", "Target Set (*.json)")
 #define STR_REDACTION_EDIT_TARGET               NC_("STR_REDACTION_EDIT_TARGET", "Edit Target")
 #define STR_REDACTION_TARGET_ADD_ERROR          NC_("STR_REDACTION_TARGET_ADD_ERROR", "An error occurred while adding new target. Please report this incident.")
+#define STR_REDACTION_NO_DRAW_WARNING           NC_("STR_REDACTION_NO_DRAW_WARNING", "Draw module is needed for redaction. Please make sure you have LibreOffice Draw installed and working correctly.")
 
 #define STR_SFX_FILEDLG_ACTUALVERSION           NC_("STR_SFX_FILEDLG_ACTUALVERSION", "Current version")
 #define STR_SFX_EXPLORERFILE_EXPORT             NC_("STR_SFX_EXPLORERFILE_EXPORT", "Export")
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 85406b99ace3..349cac3ac4d0 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -51,6 +51,7 @@
 #include <comphelper/string.hxx>
 #include <basic/sbxcore.hxx>
 #include <basic/sberrors.hxx>
+#include <unotools/moduleoptions.hxx>
 #include <unotools/saveopt.hxx>
 #include <svtools/DocumentToGraphicRenderer.hxx>
 #include <vcl/gdimtf.hxx>
@@ -601,6 +602,18 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
 
         case SID_AUTOREDACTDOC:
         {
+            // Actual redaction takes place on a newly generated Draw document
+            if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::DRAW))
+            {
+                std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
+                    pDialogParent, VclMessageType::Warning, VclButtonsType::Ok,
+                    SfxResId(STR_REDACTION_NO_DRAW_WARNING)));
+
+                xBox->run();
+
+                return;
+            }
+
             SfxAutoRedactDialog aDlg(pDialogParent);
             sal_Int16 nResult = aDlg.run();
 
@@ -625,6 +638,18 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
 
             uno::Reference< lang::XComponent > xSourceDoc( xModel );
 
+            // Actual redaction takes place on a newly generated Draw document
+            if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::DRAW))
+            {
+                std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(
+                    pDialogParent, VclMessageType::Warning, VclButtonsType::Ok,
+                    SfxResId(STR_REDACTION_NO_DRAW_WARNING)));
+
+                xBox->run();
+
+                return;
+            }
+
             DocumentToGraphicRenderer aRenderer(xSourceDoc, false);
 
             // Get the page margins of the original doc
@@ -645,6 +670,13 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
             uno::Reference<frame::XDesktop2> xDesktop = css::frame::Desktop::create(comphelper::getProcessComponentContext());
             uno::Reference<lang::XComponent> xComponent = xDesktop->loadComponentFromURL("private:factory/sdraw", "_default", 0, {});
 
+            if (!xComponent.is())
+            {
+                SAL_WARN("sfx.doc", "SID_REDACTDOC: Failed to load new draw component. loadComponentFromURL returned an empty reference.");
+
+                return;
+            }
+
             // Add the doc pages to the new draw document
             SfxRedactionHelper::addPagesToDraw(xComponent, nPages, aMetaFiles, aPageSizes, aPageMargins, aRedactionTargets, bIsAutoRedact);
 


More information about the Libreoffice-commits mailing list