sfx2/source/view/viewprn.cxx |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 8ebe12e9921ea84b6f4dcf552618368d4340a100
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sat Jun 15 21:10:10 2024 +0100
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Sun Jun 16 22:54:24 2024 +0200

    Resolves: tdf#159741 canceling printing results in 'modified' document
    
    Change-Id: I627487a79f819351ec38e34b3fac432c36670d7b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168933
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 19fddbffdfa0..493440977776 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<awt::XDevice>         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<Printer>& 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<document::XDocumentProperties> 
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<document::XDocumentProperties> 
xDocProps(mpObjectShell->getDocProperties());
+                xDocProps->setPrintedBy(m_aLastPrintedBy);
+                xDocProps->setPrintDate(m_aLastPrinted);
+            }
             break;
         }
 

Reply via email to