[Libreoffice-commits] core.git: sfx2/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Feb 4 12:50:30 UTC 2016


 sfx2/source/doc/objserv.cxx  |    2 ++
 sfx2/source/doc/objstor.cxx  |    6 ++++++
 sfx2/source/doc/objxtor.cxx  |    1 +
 sfx2/source/inc/objshimp.hxx |    2 ++
 4 files changed, 11 insertions(+)

New commits:
commit 46f74ab5f97415b8777b1043bbd7bf9839163075
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Feb 4 12:47:16 2016 +0100

    sfx2: fix locking after signing OOXML documents
    
    File -> digital signatures looks like a way to view and modify digital
    signatures, internally it's a sign action, that at the end may not modify
    signatures after all. For this to work, SfxObjectShell::ImplSign() calls
    GetMedium()->CloseAndRelease() to release the document's lock file, invokes the
    signing dialog, then DoSaveCompleted() creates the lockfile again.
    
    When signing OOXML documents, the lock file is not re-created, as
    DoSaveCompleted() only creates the lockfile in case
    IsPackageStorageFormat_Impl() (== own format) is true. Fix this by adding a
    mode that creates the lock file, even in case of a foreign format.
    
    With this, closing the digital signatures dialog for OOXML documents no longer
    results in a confusing "Document in Use" dialog after closing the signatures
    dialog.
    
    Change-Id: Ie9e56b88768825e61765669b27a89082cdc1981f

diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 57946d0..ef2795f 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1486,7 +1486,9 @@ void SfxObjectShell::ImplSign( bool bScriptingContent )
             || pImp->nDocumentSignatureState == SignatureState::NOTVALIDATED
             || pImp->nDocumentSignatureState == SignatureState::PARTIAL_OK);
 
+        pImp->m_bSavingForSigning = true;
         DoSaveCompleted( GetMedium() );
+        pImp->m_bSavingForSigning = false;
 
         if ( bSigned )
         {
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 01d7435..8751873 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2009,6 +2009,12 @@ bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed )
         }
         else
         {
+            if (pImp->m_bSavingForSigning && pFilter && pFilter->GetSupportsSigning())
+                // So that pMedium->pImp->xStream becomes a non-empty
+                // reference, and at the end we attempt locking again in
+                // SfxMedium::LockOrigFileOnDemand().
+                pMedium->GetMedium_Impl();
+
             if( pMedium->GetOpenMode() & StreamMode::WRITE )
                 pMedium->GetInStream();
             xStorage = GetStorage();
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index de21929..94ed0f2 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -264,6 +264,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell )
     ,m_bIncomplEncrWarnShown( false )
     ,m_nModifyPasswordHash( 0 )
     ,m_bModifyPasswordEntered( false )
+    ,m_bSavingForSigning( false )
 {
     SfxObjectShell* pDoc = &_rDocShell;
     SfxObjectShellArr_Impl &rArr = SfxGetpApp()->GetObjectShells_Impl();
diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx
index fb94a8e..1a338be 100644
--- a/sfx2/source/inc/objshimp.hxx
+++ b/sfx2/source/inc/objshimp.hxx
@@ -146,6 +146,8 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess
     sal_uInt32          m_nModifyPasswordHash;
     css::uno::Sequence< css::beans::PropertyValue > m_aModifyPasswordInfo;
     bool                m_bModifyPasswordEntered;
+    /// If true, then this is not a real save, just the signatures change.
+    bool m_bSavingForSigning;
 
     SfxObjectShell_Impl( SfxObjectShell& _rDocShell );
     virtual ~SfxObjectShell_Impl();


More information about the Libreoffice-commits mailing list