From 402368f7ed1be95c12a1514e4341cd926e3d5a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sat, 15 Jun 2024 21:10:10 +0100 Subject: [PATCH] Resolves: tdf#159741 canceling printing results in 'modified' document MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I627487a79f819351ec38e34b3fac432c36670d7b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168915 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sfx2/source/view/viewprn.cxx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 6e646c9b1581..e1bc2c4ec915 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -68,6 +68,7 @@ class SfxPrinterController : public vcl::PrinterController, public SfxListener mutable Reference mxDevice; SfxViewShell* mpViewShell; SfxObjectShell* mpObjectShell; + bool m_bJobStarted; bool m_bOrigStatus; bool m_bNeedsChange; bool m_bApi; @@ -114,6 +115,7 @@ SfxPrinterController::SfxPrinterController( const VclPtr& i_rPrinter, , mpLastPrinter( nullptr ) , mpViewShell( pView ) , mpObjectShell(nullptr) + , m_bJobStarted( false ) , m_bOrigStatus( false ) , m_bNeedsChange( false ) , m_bApi(i_bApi) @@ -291,6 +293,8 @@ void SfxPrinterController::jobStarted() if ( !mpObjectShell ) return; + m_bJobStarted = true; + m_bOrigStatus = mpObjectShell->IsEnableSetModified(); // check configuration: shall update of printing information in DocInfo set the document to "modified"? @@ -348,10 +352,13 @@ void SfxPrinterController::jobFinished( css::view::PrintableState nState ) } case view::PrintableState_JOB_ABORTED : { - // printing not successful, reset DocInfo - uno::Reference xDocProps(mpObjectShell->getDocProperties()); - xDocProps->setPrintedBy(m_aLastPrintedBy); - xDocProps->setPrintDate(m_aLastPrinted); + // printing not successful, reset DocInfo if the job started and so DocInfo was modified + if (m_bJobStarted) + { + uno::Reference xDocProps(mpObjectShell->getDocProperties()); + xDocProps->setPrintedBy(m_aLastPrintedBy); + xDocProps->setPrintDate(m_aLastPrinted); + } break; }