[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - package/inc package/source sfx2/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 18 12:37:59 UTC 2018


 package/inc/ZipPackage.hxx               |    1 +
 package/source/xstor/xfactory.cxx        |    7 +++++++
 package/source/xstor/xstorage.cxx        |    4 +++-
 package/source/zippackage/ZipPackage.cxx |    4 +++-
 sfx2/source/doc/docfile.cxx              |    9 +++++++++
 5 files changed, 23 insertions(+), 2 deletions(-)

New commits:
commit d16bfbda418da5ce43133b93c833ff118bd3b04f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 11 17:11:06 2018 +0100

    ODT export: handle NoFileSync store option
    
    SfxMedium already had a m_bDisableFileSync member; if the medium has a
    storage, then forward this flag to it, so at the end
    SwitchablePersistenceStream::waitForCompletion() (and the called
    fileaccess::XStream_impl::waitForCompletion()) does not call
    osl_syncFile(), either.
    
    Times for 100 hello world inputs: 12594 -> 5281 ms is spent in XHTML-load + ODT
    export + close (42% of original).
    
    (cherry picked from commit 16a522361698ea53ab253d67e31cb51802210d71)
    
    Conflicts:
            package/inc/ZipPackage.hxx
            package/source/xstor/xstorage.cxx
    
    Change-Id: I2aab6c9e6baf133b211620004dcea66bd41ffc6f
    Reviewed-on: https://gerrit.libreoffice.org/47979
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
index 378876962b0d..7ab93288f076 100644
--- a/package/inc/ZipPackage.hxx
+++ b/package/inc/ZipPackage.hxx
@@ -99,6 +99,7 @@ protected:
 
     ZipPackageFolder *m_pRootFolder;
     ZipFile          *m_pZipFile;
+    bool m_bDisableFileSync = false;
 
     bool isLocalFile() const;
 
diff --git a/package/source/xstor/xfactory.cxx b/package/source/xstor/xfactory.cxx
index d5031b4dbc03..57530cf08890 100644
--- a/package/source/xstor/xfactory.cxx
+++ b/package/source/xstor/xfactory.cxx
@@ -227,6 +227,13 @@ uno::Reference< uno::XInterface > SAL_CALL OStorageFactory::createInstanceWithAr
                     else
                         throw lang::IllegalArgumentException( THROW_WHERE, uno::Reference< uno::XInterface >(), 1 );
                 }
+                else if (aDescr[nInd].Name == "NoFileSync")
+                {
+                    // Forward NoFileSync to the storage.
+                    aPropsToSet.realloc(++nNumArgs);
+                    aPropsToSet[nNumArgs - 1].Name = aDescr[nInd].Name;
+                    aPropsToSet[nNumArgs - 1].Value = aDescr[nInd].Value;
+                }
                 else
                     OSL_FAIL( "Unacceptable property, will be ignored!\n" );
             }
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index dedf4a15ce6b..308eb525e7dc 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -468,8 +468,10 @@ void OStorage_Impl::OpenOwnPackage()
             {
                 if ( m_xProperties[aInd].Name == "RepairPackage"
                   || m_xProperties[aInd].Name == "ProgressHandler"
-                  || m_xProperties[aInd].Name == "UseBufferedStream" )
+                  || m_xProperties[aInd].Name == "UseBufferedStream"
+                  || m_xProperties[aInd].Name == "NoFileSync" )
                 {
+                    // Forward these to the package.
                     beans::NamedValue aNamedValue( m_xProperties[aInd].Name,
                                                     m_xProperties[aInd].Value );
                     aArguments.realloc( ++nArgNum );
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index faaab714ee85..ca2df1558b51 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -704,6 +704,8 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
                 {
                     aNamedValue.Value >>= bUseBufferedStream;
                 }
+                else if (aNamedValue.Name == "NoFileSync")
+                    aNamedValue.Value >>= m_bDisableFileSync;
 
                 // for now the progress handler is not used, probably it will never be
                 // if ( aNamedValue.Name == "ProgressHandler" )
@@ -1265,7 +1267,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
             // in case the stream is based on a file it will implement the following interface
             // the call should be used to be sure that the contents are written to the file system
             uno::Reference< io::XAsyncOutputMonitor > asyncOutputMonitor( xTempOut, uno::UNO_QUERY );
-            if ( asyncOutputMonitor.is() )
+            if (asyncOutputMonitor.is() && !m_bDisableFileSync)
                 asyncOutputMonitor->waitForCompletion();
 
             // no need to postpone switching to the new stream since the target was written directly
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 100241c7c8b5..68f85eff772c 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -121,6 +121,7 @@
 #include <sfx2/sfxresid.hxx>
 #include "sfxacldetect.hxx"
 #include <officecfg/Office/Common.hxx>
+#include <comphelper/propertysequence.hxx>
 
 #include <memory>
 
@@ -1371,6 +1372,14 @@ uno::Reference < embed::XStorage > SfxMedium::GetStorage( bool bCreateTempIfNo )
         aArgs[0] <<= pImpl->xStream;
         aArgs[1] <<= embed::ElementModes::READWRITE;
         pImpl->bStorageBasedOnInStream = true;
+        if (pImpl->m_bDisableFileSync)
+        {
+            // Forward NoFileSync to the storage factory.
+            aArgs.realloc(3);
+            uno::Sequence<beans::PropertyValue> aProperties(
+                comphelper::InitPropertySequence({ { "NoFileSync", uno::makeAny(true) } }));
+            aArgs[2] <<= aProperties;
+        }
     }
     else if ( pImpl->xInputStream.is() )
     {


More information about the Libreoffice-commits mailing list