[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 3 commits - include/sfx2 package/inc package/source sfx2/sdi sfx2/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jul 16 14:56:16 UTC 2018


 include/sfx2/docfile.hxx                 |    2 ++
 include/sfx2/sfxsids.hrc                 |    3 ++-
 package/inc/ZipPackage.hxx               |    1 +
 package/source/xstor/xfactory.cxx        |    7 +++++++
 package/source/xstor/xstorage.cxx        |    4 +++-
 package/source/zippackage/ZipPackage.cxx |    4 +++-
 sfx2/sdi/sfx.sdi                         |    4 ++--
 sfx2/source/appl/appuno.cxx              |    1 +
 sfx2/source/doc/docfile.cxx              |   30 ++++++++++++++++++++++++------
 sfx2/source/doc/guisaveas.cxx            |    3 +++
 sfx2/source/doc/objstor.cxx              |    8 ++++++++
 sfx2/source/doc/sfxbasemodel.cxx         |    3 ++-
 12 files changed, 58 insertions(+), 12 deletions(-)

New commits:
commit 913119dc9561269b80072f0b5383418cd729d605
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Mon Jan 15 15:10:22 2018 +0100
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Mon Jul 16 16:55:54 2018 +0200

    sfx2 store: handle NoFileSync for Save (not SaveAs)
    
    The code-path in SfxMedium and lower layers is the same, but not in
    SfxObjectShell.
    
    Change-Id: I85542d17cd6b3c2a0d257f5ff196e6504a194e51
    Reviewed-on: https://gerrit.libreoffice.org/47903
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit e90a16d71cdcfbd785401613a2e5a29cb1167acf)

diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index de632285788f..5f5144498d2d 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3501,7 +3501,7 @@ SfxVoidItem SaveSimple SID_SAVESIMPLE
 ]
 
 SfxStringItem Save SID_SAVEDOC
-(SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem Author SID_DOCINFO_AUTHOR,SfxBoolItem DontTerminateEdit FN_PARAM_1)
+(SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem Author SID_DOCINFO_AUTHOR,SfxBoolItem DontTerminateEdit FN_PARAM_1,SfxBoolItem NoFileSync SID_NO_FILE_SYNC)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 1da245af8a2e..f2982fbc04b8 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -699,6 +699,7 @@ sal_Int8 ModelData_Impl::CheckStateForSave()
     const OUString aInteractionHandlerString("InteractionHandler");
     const OUString aStatusIndicatorString("StatusIndicator");
     const OUString aFailOnWarningString("FailOnWarning");
+    const OUString aNoFileSync("NoFileSync");
 
     if ( GetMediaDescr().find( aVersionCommentString ) != GetMediaDescr().end() )
         aAcceptedArgs[ aVersionCommentString ] = GetMediaDescr()[ aVersionCommentString ];
@@ -712,6 +713,8 @@ sal_Int8 ModelData_Impl::CheckStateForSave()
         aAcceptedArgs[ aStatusIndicatorString ] = GetMediaDescr()[ aStatusIndicatorString ];
     if ( GetMediaDescr().find( aFailOnWarningString ) != GetMediaDescr().end() )
         aAcceptedArgs[ aFailOnWarningString ] = GetMediaDescr()[ aFailOnWarningString ];
+    if (GetMediaDescr().find(aNoFileSync) != GetMediaDescr().end())
+        aAcceptedArgs[aNoFileSync] = GetMediaDescr()[aNoFileSync];
 
     // remove unacceptable entry if there is any
     DBG_ASSERT( GetMediaDescr().size() == aAcceptedArgs.size(),
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 9b48caac795c..dad9c424891c 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2501,6 +2501,10 @@ bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs )
     if ( pxInteractionItem && ( pxInteractionItem->GetValue() >>= xInteract ) && xInteract.is() )
         pMediumTmp->GetItemSet()->Put( SfxUnoAnyItem( SID_INTERACTIONHANDLER, makeAny( xInteract ) ) );
 
+    const SfxBoolItem* pNoFileSync = pArgs->GetItem<SfxBoolItem>(SID_NO_FILE_SYNC, false);
+    if (pNoFileSync && pNoFileSync->GetValue())
+        pMediumTmp->DisableFileSync(true);
+
     bool bSaved = false;
     if( !GetError() && SaveTo_Impl( *pMediumTmp, pArgs ) )
     {
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 577562aa974c..a679c8f6c7fa 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1482,7 +1482,8 @@ void SAL_CALL SfxBaseModel::storeSelf( const    Sequence< beans::PropertyValue >
               && aSeqArgs[nInd].Name != "InteractionHandler" && aSeqArgs[nInd].Name != "StatusIndicator"
               && aSeqArgs[nInd].Name != "VersionMajor"
               && aSeqArgs[nInd].Name != "FailOnWarning"
-              && aSeqArgs[nInd].Name != "CheckIn" )
+              && aSeqArgs[nInd].Name != "CheckIn"
+              && aSeqArgs[nInd].Name != "NoFileSync" )
             {
                 const OUString aMessage( "Unexpected MediaDescriptor parameter: " + aSeqArgs[nInd].Name );
                 throw lang::IllegalArgumentException( aMessage, Reference< XInterface >(), 1 );
commit db3002eae843056dcfbd6d7ad0ad333ee53251f9
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Thu Jan 11 17:11:06 2018 +0100
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Mon Jul 16 16:55:54 2018 +0200

    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).
    
    Change-Id: I2aab6c9e6baf133b211620004dcea66bd41ffc6f
    Reviewed-on: https://gerrit.libreoffice.org/47766
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 16a522361698ea53ab253d67e31cb51802210d71)

diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
index f46eb33b0172..1cb3ba7836f5 100644
--- a/package/inc/ZipPackage.hxx
+++ b/package/inc/ZipPackage.hxx
@@ -99,6 +99,7 @@ class ZipPackage final : public cppu::WeakImplHelper
     const css::uno::Reference < css::uno::XComponentContext > m_xContext;
 
     std::unique_ptr<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 bc956e0e362b..4562dffaafdb 100644
--- a/package/source/xstor/xfactory.cxx
+++ b/package/source/xstor/xfactory.cxx
@@ -223,6 +223,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!" );
             }
diff --git a/package/source/xstor/xstorage.cxx b/package/source/xstor/xstorage.cxx
index 48bc0d6aeb04..12a3066fc9d1 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -429,8 +429,10 @@ void OStorage_Impl::OpenOwnPackage()
             for ( sal_Int32 aInd = 0; aInd < m_xProperties.getLength(); aInd++ )
             {
                 if ( m_xProperties[aInd].Name == "RepairPackage"
-                  || m_xProperties[aInd].Name == "ProgressHandler" )
+                  || m_xProperties[aInd].Name == "ProgressHandler"
+                  || 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 f7464ed8f30f..346f509d2250 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -728,6 +728,8 @@ void SAL_CALL ZipPackage::initialize( const uno::Sequence< Any >& aArguments )
                     aNamedValue.Value >>= m_bAllowRemoveOnInsert;
                     m_xRootFolder->setRemoveOnInsertMode_Impl( m_bAllowRemoveOnInsert );
                 }
+                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" )
@@ -1319,7 +1321,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 c6e4a55e2091..c79e2246eae4 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -124,6 +124,7 @@
 #include <openflag.hxx>
 #include <sfx2/sfxresid.hxx>
 #include <officecfg/Office/Common.hxx>
+#include <comphelper/propertysequence.hxx>
 
 #include <com/sun/star/io/WrongFormatException.hpp>
 
@@ -1428,6 +1429,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() )
     {
commit 27d0abe7eca73722980228520f3a3ccdf3f844a3
Author:     Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Wed Jan 10 11:39:21 2018 +0100
Commit:     Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Mon Jul 16 16:55:53 2018 +0200

    sfx2 store: add API to allow avoiding the fsync of the output file
    
    The use-case is when the consumer of the output file will read it right
    after SfxBaseModel::storeToURL() returns, in which case an expensive
    fsync is pointless.
    
    Times for 100 hello world inputs: 8516 -> 2785 ms is spent in ODT-load + HTML
    export + close (33% of original).
    
    Change-Id: I05e424a43ebfeea363f82b57af60f5aaa28696b4
    Reviewed-on: https://gerrit.libreoffice.org/47695
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit d03a754722980a4eaf14fce38d73ae23b604295b)

diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index a2a66640529c..468e11dd2e7b 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -171,6 +171,8 @@ public:
     LockFileResult      LockOrigFileOnDemand( bool bLoading, bool bNoUI, bool bTryIgnoreLockFile = false );
     void                DisableUnlockWebDAV( bool bDisableUnlockWebDAV = true );
     void                UnlockFile( bool bReleaseLockStream );
+    /// Lets Transfer_Impl() not fsync the output file.
+    void DisableFileSync(bool bDisableFileSync);
 
     css::uno::Reference< css::embed::XStorage > GetStorage( bool bCreateTempIfNo = true );
     css::uno::Reference< css::embed::XStorage > GetOutputStorage();
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 7bac74572f8f..e4c757ae756a 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -243,8 +243,9 @@
 #define SID_BLUETOOTH_SENDDOC               (SID_SFX_START + 1726)
 #define SID_TEMPLATE_MANAGER                (SID_SFX_START + 1727)
 #define SID_TOOLBAR_MODE                    (SID_SFX_START + 1728)
+#define SID_NO_FILE_SYNC                    (SID_SFX_START + 1729)
 
-//      SID_SFX_free_START                  (SID_SFX_START + 1729)
+//      SID_SFX_free_START                  (SID_SFX_START + 1730)
 //      SID_SFX_free_END                    (SID_SFX_START + 3999)
 
 #define SID_OPEN_NEW_VIEW                   (SID_SFX_START + 520)
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 659e3763bfd1..de632285788f 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3538,7 +3538,7 @@ SfxVoidItem SaveAll SID_SAVEDOCS
 
 
 SfxStringItem SaveAs SID_SAVEASDOC
-(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxBoolItem PasswordInteraction SID_PASSWORDINTERACTION,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO)
+(SfxStringItem URL SID_FILE_NAME,SfxStringItem FilterName SID_FILTER_NAME,SfxStringItem Password SID_PASSWORD,SfxBoolItem PasswordInteraction SID_PASSWORDINTERACTION,SfxStringItem FilterOptions SID_FILE_FILTEROPTIONS,SfxStringItem VersionComment SID_DOCINFO_COMMENTS,SfxStringItem VersionAuthor SID_DOCINFO_AUTHOR,SfxBoolItem Overwrite SID_OVERWRITE,SfxBoolItem Unpacked SID_UNPACK,SfxBoolItem SaveTo SID_SAVETO,SfxBoolItem NoFileSync SID_NO_FILE_SYNC)
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index a5bc1ea0b959..a0bf23d483f6 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -105,6 +105,7 @@ SfxFormalArgument const aFormalArgs[] = {
     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "Unpacked", SID_UNPACK },
     { reinterpret_cast<SfxType*>(&aSfxInt16Item_Impl), "Version", SID_VERSION },
     { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "SaveACopy", SID_SAVEACOPYITEM },
+    { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "NoFileSync", SID_NO_FILE_SYNC },
 };
 
 static sal_uInt16 nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 273d201e94d0..c6e4a55e2091 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -194,6 +194,7 @@ public:
     bool m_bRemote:1;
     bool m_bInputStreamIsReadOnly:1;
     bool m_bInCheckIn:1;
+    bool m_bDisableFileSync = false;
 
     OUString m_aName;
     OUString m_aLogicName;
@@ -2024,13 +2025,16 @@ void SfxMedium::Transfer_Impl()
         {
             TransactedTransferForFS_Impl( aSource, aDest, xComEnv );
 
-            // Hideous - no clean way to do this, so we re-open the file just to fsync it
-            osl::File aFile( aDestURL );
-            if ( aFile.open( osl_File_OpenFlag_Write ) == osl::FileBase::E_None )
+            if (!pImpl->m_bDisableFileSync)
             {
-                aFile.sync();
-                SAL_INFO( "sfx.doc", "fsync'd saved file '" << aDestURL << "'" );
-                aFile.close();
+                // Hideous - no clean way to do this, so we re-open the file just to fsync it
+                osl::File aFile( aDestURL );
+                if ( aFile.open( osl_File_OpenFlag_Write ) == osl::FileBase::E_None )
+                {
+                    aFile.sync();
+                    SAL_INFO( "sfx.doc", "fsync'd saved file '" << aDestURL << "'" );
+                    aFile.close();
+                }
             }
         }
         else
@@ -2786,6 +2790,11 @@ void SfxMedium::DisableUnlockWebDAV( bool bDisableUnlockWebDAV )
     pImpl->m_bDisableUnlockWebDAV = bDisableUnlockWebDAV;
 }
 
+void SfxMedium::DisableFileSync(bool bDisableFileSync)
+{
+    pImpl->m_bDisableFileSync = bDisableFileSync;
+}
+
 void SfxMedium::UnlockFile( bool bReleaseLockStream )
 {
 #if !HAVE_FEATURE_MULTIUSER_ENVIRONMENT
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index de065085c217..9b48caac795c 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -2751,6 +2751,10 @@ bool SfxObjectShell::PreDoSaveAs_Impl(const OUString& rFileName, const OUString&
     // create a medium for the target URL
     SfxMedium *pNewFile = new SfxMedium( rFileName, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC, nullptr, pMergedParams );
 
+    const SfxBoolItem* pNoFileSync = pMergedParams->GetItem<SfxBoolItem>(SID_NO_FILE_SYNC, false);
+    if (pNoFileSync && pNoFileSync->GetValue())
+        pNewFile->DisableFileSync(true);
+
     // set filter; if no filter is given, take the default filter of the factory
     if ( !aFilterName.isEmpty() )
         pNewFile->SetFilter( GetFactory().GetFilterContainer()->GetFilter4FilterName( aFilterName ) );


More information about the Libreoffice-commits mailing list