[Libreoffice-commits] core.git: include/sot sot/source sw/source

Noel Grandin noel at peralex.com
Thu Mar 17 10:33:35 UTC 2016


 include/sot/storage.hxx         |    3 +--
 sot/source/sdstor/stgcache.cxx  |   18 ++++++++----------
 sot/source/sdstor/stgcache.hxx  |    4 ++--
 sot/source/sdstor/stgdir.cxx    |    8 ++++----
 sot/source/sdstor/stgstrms.cxx  |   12 ++++++------
 sot/source/sdstor/stgstrms.hxx  |    4 ++--
 sot/source/sdstor/storage.cxx   |    4 ++--
 sw/source/filter/ww8/ww8par.cxx |    2 +-
 8 files changed, 26 insertions(+), 29 deletions(-)

New commits:
commit 2a78e3eb92466ede9ea8fd3c3632c286fbd915a2
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Mar 17 10:04:45 2016 +0200

    loplugin:constantparam in sot
    
    Change-Id: I380b5a824b1bc8cd322471519d2d87ab7f2bca1c
    Reviewed-on: https://gerrit.libreoffice.org/23320
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/include/sot/storage.hxx b/include/sot/storage.hxx
index 326ef1e..2df5af5 100644
--- a/include/sot/storage.hxx
+++ b/include/sot/storage.hxx
@@ -78,8 +78,7 @@ protected:
    void                 CreateStorage( bool bUCBStorage, StreamMode, bool transacted );
 public:
                         SotStorage( const OUString &,
-                                    StreamMode = STREAM_STD_READWRITE,
-                                    bool transacted = false );
+                                    StreamMode = STREAM_STD_READWRITE );
                         SotStorage( bool bUCBStorage, const OUString &,
                                     StreamMode = STREAM_STD_READWRITE );
                         SotStorage( BaseStorage * );
diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx
index 832fde7..9360ce1 100644
--- a/sot/source/sdstor/stgcache.cxx
+++ b/sot/source/sdstor/stgcache.cxx
@@ -173,7 +173,7 @@ rtl::Reference< StgPage > StgCache::Get( sal_Int32 nPage, bool bForce )
     if( !p.is() )
     {
         p = Create( nPage );
-        if( !Read( nPage, p->GetData(), 1 ) && bForce )
+        if( !Read( nPage, p->GetData() ) && bForce )
         {
             Erase( p );
             p.clear();
@@ -223,7 +223,7 @@ bool StgCache::Commit()
               aWr != aToWrite.end(); ++aWr)
         {
             const rtl::Reference< StgPage > &pPage = *aWr;
-            if ( !Write( pPage->GetPage(), pPage->GetData(), 1 ) )
+            if ( !Write( pPage->GetPage(), pPage->GetData() ) )
                 return false;
         }
     }
@@ -318,7 +318,7 @@ void StgCache::Close()
 
 // low level I/O
 
-bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
+bool StgCache::Read( sal_Int32 nPage, void* pBuf )
 {
     if( Good() )
     {
@@ -331,21 +331,21 @@ bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
         else if ( nPage < m_nPages )
         {
             sal_uInt32 nPos = Page2Pos( nPage );
-            sal_Int32 nPg2 = ( ( nPage + nPg ) > m_nPages ) ? m_nPages - nPage : nPg;
+            sal_Int32 nPg2 = ( ( nPage + 1 ) > m_nPages ) ? m_nPages - nPage : 1;
             sal_uInt32 nBytes = nPg2 * m_nPageSize;
             // fixed address and size for the header
             if( nPage == -1 )
             {
                 nPos = 0L;
                 nBytes = 512;
-                nPg2 = nPg;
+                nPg2 = 1;
             }
             if( m_pStrm->Tell() != nPos )
             {
                 m_pStrm->Seek(nPos);
             }
             m_pStrm->Read( pBuf, nBytes );
-            if ( nPg != nPg2 )
+            if ( 1 != nPg2 )
                 SetError( SVSTREAM_READ_ERROR );
             else
                 SetError( m_pStrm->GetError() );
@@ -354,14 +354,12 @@ bool StgCache::Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
     return Good();
 }
 
-bool StgCache::Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPg )
+bool StgCache::Write( sal_Int32 nPage, void* pBuf )
 {
     if( Good() )
     {
         sal_uInt32 nPos = Page2Pos( nPage );
-        sal_uInt32 nBytes = 0;
-        if ( SAL_MAX_INT32 / nPg > m_nPageSize )
-            nBytes = nPg * m_nPageSize;
+        sal_uInt32 nBytes = m_nPageSize;
 
         // fixed address and size for the header
         // nPageSize must be >= 512, otherwise the header can not be written here, we check it on import
diff --git a/sot/source/sdstor/stgcache.hxx b/sot/source/sdstor/stgcache.hxx
index 9911f4b..3c0d866 100644
--- a/sot/source/sdstor/stgcache.hxx
+++ b/sot/source/sdstor/stgcache.hxx
@@ -79,8 +79,8 @@ public:
     void  ResetError();
     bool  Open( const OUString& rName, StreamMode );
     void  Close();
-    bool  Read( sal_Int32 nPage, void* pBuf, sal_Int32 nPages );
-    bool  Write( sal_Int32 nPage, void* pBuf, sal_Int32 nPages );
+    bool  Read( sal_Int32 nPage, void* pBuf );
+    bool  Write( sal_Int32 nPage, void* pBuf );
 
     // two routines for accessing FAT pages
     // Assume that the data is a FAT page and get/put FAT data.
diff --git a/sot/source/sdstor/stgdir.cxx b/sot/source/sdstor/stgdir.cxx
index e093936..3984525 100644
--- a/sot/source/sdstor/stgdir.cxx
+++ b/sot/source/sdstor/stgdir.cxx
@@ -346,7 +346,7 @@ bool StgDirEntry::SetSize( sal_Int32 nNewSize )
         {
             pOld = m_pStgStrm;
             nOldSize = (sal_uInt16) nNewSize;
-            m_pStgStrm = new StgSmallStrm( rIo, STG_EOF, 0 );
+            m_pStgStrm = new StgSmallStrm( rIo, STG_EOF );
         }
         // now set the new size
         if( m_pStgStrm->SetSize( nNewSize ) )
@@ -635,9 +635,9 @@ bool StgDirEntry::Tmp2Strm()
         StgIo& rIo = m_pStgStrm->GetIo();
         sal_uLong nThreshold = (sal_uLong) rIo.m_aHdr.GetThreshold();
         if( n < nThreshold )
-            pNewStrm = new StgSmallStrm( rIo, STG_EOF, 0 );
+            pNewStrm = new StgSmallStrm( rIo, STG_EOF );
         else
-            pNewStrm = new StgDataStrm( rIo, STG_EOF, 0 );
+            pNewStrm = new StgDataStrm( rIo, STG_EOF );
         if( pNewStrm->SetSize( n ) )
         {
             sal_uInt8 p[ 4096 ];
@@ -924,7 +924,7 @@ bool StgDirStrm::Store()
 void* StgDirStrm::GetEntry( sal_Int32 n, bool bDirty )
 {
     return n < 0 || n >= m_nSize / STGENTRY_SIZE
-        ? nullptr : GetPtr( n * STGENTRY_SIZE, true, bDirty );
+        ? nullptr : GetPtr( n * STGENTRY_SIZE, bDirty );
 }
 
 // Find a dir entry.
diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx
index ffc27a4..4f74948 100644
--- a/sot/source/sdstor/stgstrms.cxx
+++ b/sot/source/sdstor/stgstrms.cxx
@@ -871,11 +871,11 @@ bool StgDataStrm::SetSize( sal_Int32 nBytes )
 // If bForce = true, a read of non-existent data causes
 // a read fault.
 
-void* StgDataStrm::GetPtr( sal_Int32 Pos, bool bForce, bool bDirty )
+void* StgDataStrm::GetPtr( sal_Int32 Pos, bool bDirty )
 {
     if( Pos2Page( Pos ) )
     {
-        rtl::Reference< StgPage > pPg = m_rIo.Get( m_nPage, bForce );
+        rtl::Reference< StgPage > pPg = m_rIo.Get( m_nPage, true/*bForce*/ );
         if (pPg.is() && m_nOffset < pPg->GetSize())
         {
             if( bDirty )
@@ -919,7 +919,7 @@ sal_Int32 StgDataStrm::Read( void* pBuf, sal_Int32 n )
                 }
                 else
                     // do a direct (unbuffered) read
-                    nRes = (short) m_rIo.Read( m_nPage, p, 1 ) * m_nPageSize;
+                    nRes = (short) m_rIo.Read( m_nPage, p ) * m_nPageSize;
             }
             else
             {
@@ -979,7 +979,7 @@ sal_Int32 StgDataStrm::Write( const void* pBuf, sal_Int32 n )
                 }
                 else
                     // do a direct (unbuffered) write
-                    nRes = (short) m_rIo.Write( m_nPage, const_cast<void*>(p), 1 ) * m_nPageSize;
+                    nRes = (short) m_rIo.Write( m_nPage, const_cast<void*>(p) ) * m_nPageSize;
             }
             else
             {
@@ -1012,9 +1012,9 @@ sal_Int32 StgDataStrm::Write( const void* pBuf, sal_Int32 n )
 // is also a StgStream. The start of the FAT is in the header at DataRootPage,
 // the stream itself is pointed to by the root entry (it holds start & size).
 
-StgSmallStrm::StgSmallStrm( StgIo& r, sal_Int32 nBgn, sal_Int32 nLen ) : StgStrm( r )
+StgSmallStrm::StgSmallStrm( StgIo& r, sal_Int32 nBgn ) : StgStrm( r )
 {
-    Init( nBgn, nLen );
+    Init( nBgn, 0 );
 }
 
 StgSmallStrm::StgSmallStrm( StgIo& r, StgDirEntry& p ) : StgStrm( r )
diff --git a/sot/source/sdstor/stgstrms.hxx b/sot/source/sdstor/stgstrms.hxx
index ad544f0..808fc0a 100644
--- a/sot/source/sdstor/stgstrms.hxx
+++ b/sot/source/sdstor/stgstrms.hxx
@@ -116,7 +116,7 @@ class StgDataStrm : public StgStrm      // a physical data stream
 public:
     StgDataStrm( StgIo&, sal_Int32 nBgn, sal_Int32 nLen=-1 );
     StgDataStrm( StgIo&, StgDirEntry& );
-    void* GetPtr( sal_Int32 nPos, bool bForce, bool bDirty );
+    void* GetPtr( sal_Int32 nPos, bool bDirty );
     void SetIncrement( short n ) { m_nIncr = n ; }
     virtual bool SetSize( sal_Int32 ) override;
     virtual sal_Int32 Read( void*, sal_Int32 ) override;
@@ -133,7 +133,7 @@ class StgSmallStrm : public StgStrm     // a logical data stream
     StgStrm* m_pData;                     // the data stream
     void Init( sal_Int32 nBgn, sal_Int32 nLen );
 public:
-    StgSmallStrm( StgIo&, sal_Int32 nBgn, sal_Int32 nLen );
+    StgSmallStrm( StgIo&, sal_Int32 nBgn );
     StgSmallStrm( StgIo&, StgDirEntry& );
     virtual sal_Int32 Read( void*, sal_Int32 ) override;
     virtual sal_Int32 Write( const void*, sal_Int32 ) override;
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx
index 9abf9cc..936a7cf 100644
--- a/sot/source/sdstor/storage.cxx
+++ b/sot/source/sdstor/storage.cxx
@@ -294,11 +294,11 @@ SotStorage::SotStorage()
 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
 #include <ucbhelper/content.hxx>
 
-SotStorage::SotStorage( const OUString & rName, StreamMode nMode, bool transacted )
+SotStorage::SotStorage( const OUString & rName, StreamMode nMode )
     INIT_SotStorage()
 {
     m_aName = rName; // Namen merken
-    CreateStorage( true, nMode, transacted );
+    CreateStorage( true, nMode, false );
     if ( IsOLEStorage() )
         m_nVersion = SOFFICE_FILEFORMAT_50;
 }
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index be8df23..11a4ee8 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4885,7 +4885,7 @@ void SwWW8ImplReader::ReadGlobalTemplateSettings( const OUString& sCreatedFrom,
         if ( !aURL.endsWithIgnoreAsciiCase( ".dot" ) || ( !sCreatedFrom.isEmpty() && sCreatedFrom.equals( aURL ) ) )
             continue; // don't try and read the same document as ourselves
 
-        tools::SvRef<SotStorage> rRoot = new SotStorage( aURL, STREAM_STD_READWRITE, true );
+        tools::SvRef<SotStorage> rRoot = new SotStorage( aURL, STREAM_STD_READWRITE );
 
         BasicProjImportHelper aBasicImporter( *m_pDocShell );
         // Import vba via oox filter


More information about the Libreoffice-commits mailing list