[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - include/sfx2 sfx2/source

Muhammet Kara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 30 23:37:46 UTC 2020


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

New commits:
commit 49109fa3e450017acd32d119c07f6f27056d75e3
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Mon Jun 29 22:38:16 2020 +0300
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Wed Jul 1 01:37:12 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>
    (cherry picked from commit be85a4d7cc7c15472de9d1584837d5bff7640bf9)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97505
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc
index 0c76294bd1f5..4faaf048a6e4 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 7e367a88e53e..4f4eebd34a55 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>
@@ -532,6 +533,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();
 
@@ -556,6 +569,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
@@ -576,6 +601,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