From 03ec3b7dd11656c8b64a94efb172e17d97ea662e Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Mon, 14 Oct 2019 00:12:23 +0300 Subject: tdf#125191: Disable Undo during pptx save Change-Id: I07fe6895cc2ba43dfa1716e67bdbb4e697e3420c Reviewed-on: https://gerrit.libreoffice.org/80727 Tested-by: Jenkins Reviewed-by: Jim Raykowski --- oox/source/ppt/pptimport.cxx | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'oox/source') diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index b154196de2ac..01f572a54dcf 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -231,17 +232,28 @@ sal_Bool SAL_CALL PowerPointImport::filter( const Sequence< PropertyValue >& rDe Reference aFactory(getComponentContext()->getServiceManager(), UNO_QUERY_THROW); Reference< XExporter > xExporter(aFactory->createInstanceWithArguments("com.sun.star.comp.Impress.oox.PowerPointExport", aArguments), UNO_QUERY); - if (xExporter.is()) + if (Reference xFilter{ xExporter, UNO_QUERY }) { - Reference< XComponent > xDocument( getModel(), UNO_QUERY ); - Reference< XFilter > xFilter( xExporter, UNO_QUERY ); - - if (xFilter.is()) + Reference xUndoManager; + bool bWasUnLocked = true; + if (Reference xUMS{ getModel(), UNO_QUERY }) { - xExporter->setSourceDocument( xDocument ); - if( xFilter->filter( rDescriptor ) ) - return true; + xUndoManager = xUMS->getUndoManager(); + if (xUndoManager.is()) + { + bWasUnLocked = !xUndoManager->isLocked(); + xUndoManager->lock(); + } } + comphelper::ScopeGuard aGuard([xUndoManager, bWasUnLocked] { + if (xUndoManager && bWasUnLocked) + xUndoManager->unlock(); + }); + + Reference< XComponent > xDocument(getModel(), UNO_QUERY); + xExporter->setSourceDocument(xDocument); + if (xFilter->filter(rDescriptor)) + return true; } } -- cgit