summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMuhammet Kara <muhammet.kara@collabora.com>2020-06-29 22:38:16 +0300
committerMuhammet Kara <muhammet.kara@collabora.com>2020-06-30 21:37:26 +0200
commitbe85a4d7cc7c15472de9d1584837d5bff7640bf9 (patch)
tree3222586c4ae86cb23751505a4494f702b66ec2e1 /sfx2
parentd73c266552c2bd814a273312d724b9097580d41a (diff)
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@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/objserv.cxx32
1 files changed, 32 insertions, 0 deletions
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);