diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-10-04 11:34:57 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2015-10-27 13:59:09 +0100 |
commit | 7e89e2827489d0b3bbd488f6c9e5a9e7e404d732 (patch) | |
tree | ca34b4ec312dffbe8e71a8106a4c3d21478d64a1 | |
parent | 99628775132143936fcd00ca9e18a853616418e4 (diff) |
sal_uIntPtr to sal_uInt64, sal_uLong to sal_Size for streams
Change-Id: I062f1f6c5b20ca47734a9a3cd1a229d51763a206
-rw-r--r-- | include/tools/stream.hxx | 2 | ||||
-rw-r--r-- | oox/qa/unit/vba_compression.cxx | 28 | ||||
-rw-r--r-- | sd/source/filter/html/htmlex.cxx | 4 | ||||
-rw-r--r-- | sot/source/sdstor/stgstrms.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/edit/edglss.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 22 | ||||
-rw-r--r-- | sw/source/filter/html/htmlplug.cxx | 3 | ||||
-rw-r--r-- | tools/qa/cppunit/test_urlobj.cxx | 12 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 2 |
9 files changed, 44 insertions, 40 deletions
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx index 2ac01dbbfe41..9867a37fd318 100644 --- a/include/tools/stream.hxx +++ b/include/tools/stream.hxx @@ -695,7 +695,7 @@ public: virtual void ResetError() override; const void* GetBuffer(); - sal_uIntPtr GetSize(); + sal_uInt64 GetSize(); sal_Size GetEndOfData() const { return nEndOfData; } const void* GetData() { Flush(); return pBuf; } operator const void*() { Flush(); return pBuf; } diff --git a/oox/qa/unit/vba_compression.cxx b/oox/qa/unit/vba_compression.cxx index f31dc3b7730e..ff50f07fc019 100644 --- a/oox/qa/unit/vba_compression.cxx +++ b/oox/qa/unit/vba_compression.cxx @@ -96,9 +96,9 @@ void TestVbaCompression::testSimple1() const sal_uInt8* pReferenceData = static_cast<const sal_uInt8*>( aReferenceMemoryStream.GetData() ); const sal_uInt8* pData = static_cast<const sal_uInt8*>( aOutputMemoryStream.GetData() ); - size_t nSize = std::min(aReferenceMemoryStream.GetSize(), + const sal_uInt64 nSize = std::min(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize()); - for (size_t i = 0; i < nSize; ++i) + for (sal_uInt64 i = 0; i < nSize; ++i) { CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]); } @@ -118,9 +118,9 @@ void TestVbaCompression::testSimple2() const sal_uInt8* pReferenceData = static_cast<const sal_uInt8*>( aReferenceMemoryStream.GetData() ); const sal_uInt8* pData = static_cast<const sal_uInt8*>( aOutputMemoryStream.GetData() ); - size_t nSize = std::min(aReferenceMemoryStream.GetSize(), + const sal_uInt64 nSize = std::min(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize()); - for (size_t i = 0; i < nSize; ++i) + for (sal_uInt64 i = 0; i < nSize; ++i) { CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]); } @@ -140,9 +140,9 @@ void TestVbaCompression::testSimple3() const sal_uInt8* pReferenceData = static_cast<const sal_uInt8*>( aReferenceMemoryStream.GetData() ); const sal_uInt8* pData = static_cast<const sal_uInt8*>( aOutputMemoryStream.GetData() ); - size_t nSize = std::min(aReferenceMemoryStream.GetSize(), + const sal_uInt64 nSize = std::min(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize()); - for (size_t i = 0; i < nSize; ++i) + for (sal_uInt64 i = 0; i < nSize; ++i) { CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]); } @@ -162,9 +162,9 @@ void TestVbaCompression::testComplex1() const sal_uInt8* pReferenceData = static_cast<const sal_uInt8*>( aReferenceMemoryStream.GetData() ); const sal_uInt8* pData = static_cast<const sal_uInt8*>( aOutputMemoryStream.GetData() ); - size_t nSize = std::min(aReferenceMemoryStream.GetSize(), + const sal_uInt64 nSize = std::min(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize()); - for (size_t i = 0; i < nSize; ++i) + for (sal_uInt64 i = 0; i < nSize; ++i) { CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]); } @@ -184,9 +184,9 @@ void TestVbaCompression::testSpec321() const sal_uInt8* pReferenceData = static_cast<const sal_uInt8*>( aReferenceMemoryStream.GetData() ); const sal_uInt8* pData = static_cast<const sal_uInt8*>( aOutputMemoryStream.GetData() ); - size_t nSize = std::min(aReferenceMemoryStream.GetSize(), + const sal_uInt64 nSize = std::min(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize()); - for (size_t i = 0; i < nSize; ++i) + for (sal_uInt64 i = 0; i < nSize; ++i) { CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]); } @@ -206,9 +206,9 @@ void TestVbaCompression::testSpec322() const sal_uInt8* pReferenceData = static_cast<const sal_uInt8*>( aReferenceMemoryStream.GetData() ); const sal_uInt8* pData = static_cast<const sal_uInt8*>( aOutputMemoryStream.GetData() ); - size_t nSize = std::min(aReferenceMemoryStream.GetSize(), + const sal_uInt64 nSize = std::min(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize()); - for (size_t i = 0; i < nSize; ++i) + for (sal_uInt64 i = 0; i < nSize; ++i) { CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]); } @@ -228,9 +228,9 @@ void TestVbaCompression::testSpec323() const sal_uInt8* pReferenceData = static_cast<const sal_uInt8*>( aReferenceMemoryStream.GetData() ); const sal_uInt8* pData = static_cast<const sal_uInt8*>( aOutputMemoryStream.GetData() ); - size_t nSize = std::min(aReferenceMemoryStream.GetSize(), + const sal_uInt64 nSize = std::min(aReferenceMemoryStream.GetSize(), aOutputMemoryStream.GetSize()); - for (size_t i = 0; i < nSize; ++i) + for (sal_uInt64 i = 0; i < nSize; ++i) { CPPUNIT_ASSERT_EQUAL((int)pReferenceData[i], (int)pData[i]); } diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx index 56f4caf9d1a8..a52d5b3b7575 100644 --- a/sd/source/filter/html/htmlex.cxx +++ b/sd/source/filter/html/htmlex.cxx @@ -1080,7 +1080,9 @@ OUString HtmlExport::DocumentMetadata() const " ", RTL_TEXTENCODING_UTF8, &aNonConvertableCharacters); - OString aData(static_cast<const char*>(aStream.GetData()), aStream.GetSize()); + const sal_uInt64 nLen = aStream.GetSize(); + OSL_ENSURE(nLen < static_cast<sal_uInt64>(SAL_MAX_INT32), "Stream can't fit in OString"); + OString aData(static_cast<const char*>(aStream.GetData()), static_cast<sal_Int32>(nLen)); return OStringToOUString(aData, RTL_TEXTENCODING_UTF8); } diff --git a/sot/source/sdstor/stgstrms.hxx b/sot/source/sdstor/stgstrms.hxx index b3c8a18feb6c..94f304963453 100644 --- a/sot/source/sdstor/stgstrms.hxx +++ b/sot/source/sdstor/stgstrms.hxx @@ -145,8 +145,8 @@ class StgTmpStrm : public SvMemoryStream OUString m_aName; SvFileStream* m_pStrm; using SvMemoryStream::GetData; - virtual sal_uLong GetData( void* pData, sal_uLong nSize ) override; - virtual sal_uLong PutData( const void* pData, sal_uLong nSize ) override; + virtual sal_Size GetData( void* pData, sal_Size nSize ) override; + virtual sal_Size PutData( const void* pData, sal_Size nSize ) override; virtual sal_uInt64 SeekPos( sal_uInt64 nPos ) override; virtual void FlushData() override; @@ -155,7 +155,7 @@ public: virtual ~StgTmpStrm(); bool Copy( StgTmpStrm& ); virtual void SetSize( sal_uInt64 ) override; - sal_uLong GetSize() const; + sal_uInt64 GetSize() const; }; #endif diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 01d452287fa9..5ffbdfcfa1b2 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -325,8 +325,9 @@ bool SwEditShell::GetSelectedText( OUString &rBuf, int nHndlParaBrk ) rBuf = OUString(p); else { - sal_Size nLen = aStream.GetSize(); - rtl_uString *pStr = rtl_uString_alloc(nLen / sizeof( sal_Unicode )); + const sal_uInt64 nLen = aStream.GetSize(); + OSL_ENSURE( nLen/sizeof( sal_Unicode )<static_cast<sal_uInt64>(SAL_MAX_INT32), "Stream can't fit in OUString" ); + rtl_uString *pStr = rtl_uString_alloc(static_cast<sal_Int32>(nLen / sizeof( sal_Unicode ))); aStream.Seek( 0 ); aStream.ResetError(); //endian specific?, yipes! diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 6dc51fd6fc3f..5309a624c6e7 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -187,20 +187,20 @@ void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer) const bool bOldShowProgress = xWrt->bShowProgress; xWrt->bShowProgress = false; - long lLen; - if( !IsError( aWriter.Write( xWrt ) ) && - 0x7ffffff > (( lLen = aStream.GetSize() ) - / sizeof( sal_Unicode )) + 1 ) + if( !IsError( aWriter.Write( xWrt ) ) ) { - aStream.WriteUInt16( '\0' ); + const sal_uInt64 lUniLen = aStream.GetSize()/sizeof( sal_Unicode ); + if (lUniLen < static_cast<sal_uInt64>(SAL_MAX_INT32-1)) + { + aStream.WriteUInt16( '\0' ); - aStream.Seek( 0 ); - aStream.ResetError(); + aStream.Seek( 0 ); + aStream.ResetError(); - long lUniLen = (lLen / sizeof( sal_Unicode )); - rtl_uString *pStr = rtl_uString_alloc(lUniLen); - aStream.Read(pStr->buffer, lUniLen * sizeof(sal_Unicode)); - rBuffer = OUString(pStr, SAL_NO_ACQUIRE); + rtl_uString *pStr = rtl_uString_alloc(lUniLen); + aStream.Read(pStr->buffer, lUniLen * sizeof(sal_Unicode)); + rBuffer = OUString(pStr, SAL_NO_ACQUIRE); + } } xWrt->bShowProgress = bOldShowProgress; } diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 95e8e57fd8ba..f189dd3f95e0 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -1299,7 +1299,8 @@ Writer& OutHTML_FrameFormatOLENodeGrf( Writer& rWrt, const SwFrameFormat& rFrame aMediaDescriptor["FilterOptions"] <<= OUString("SkipHeaderFooter"); aMediaDescriptor["OutputStream"] <<= xOutputStream; xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); - OString aData(static_cast<const char*>(aStream.GetData()), aStream.GetSize()); + SAL_WARN_IF(aStream.GetSize()>=static_cast<sal_uInt64>(SAL_MAX_INT32), "sw.html", "Stream can't fit in OString"); + OString aData(static_cast<const char*>(aStream.GetData()), static_cast<sal_Int32>(aStream.GetSize())); // Wrap output in a <span> tag to avoid 'HTML parser error: Unexpected end tag: p' HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_span); rWrt.Strm().WriteCharPtr(aData.getStr()); diff --git a/tools/qa/cppunit/test_urlobj.cxx b/tools/qa/cppunit/test_urlobj.cxx index 0c01830fc30b..d0cab0abc03f 100644 --- a/tools/qa/cppunit/test_urlobj.cxx +++ b/tools/qa/cppunit/test_urlobj.cxx @@ -255,14 +255,14 @@ namespace tools_urlobj CPPUNIT_ASSERT(!url.HasError()); strm = url.getData(); CPPUNIT_ASSERT(strm != 0); - CPPUNIT_ASSERT_EQUAL(sal_uIntPtr(0), strm->GetSize()); + CPPUNIT_ASSERT_EQUAL(sal_uInt64(0), strm->GetSize()); strm.reset(); url = INetURLObject("data:,,%C3%A4%90"); CPPUNIT_ASSERT(!url.HasError()); strm = url.getData(); CPPUNIT_ASSERT(strm != 0); - CPPUNIT_ASSERT_EQUAL(sal_uIntPtr(4), strm->GetSize()); + CPPUNIT_ASSERT_EQUAL(sal_uInt64(4), strm->GetSize()); buf = static_cast<unsigned char const *>(strm->GetData()); CPPUNIT_ASSERT_EQUAL(0x2C, int(buf[0])); CPPUNIT_ASSERT_EQUAL(0xC3, int(buf[1])); @@ -279,21 +279,21 @@ namespace tools_urlobj CPPUNIT_ASSERT(!url.HasError()); strm = url.getData(); CPPUNIT_ASSERT(strm != 0); - CPPUNIT_ASSERT_EQUAL(sal_uIntPtr(0), strm->GetSize()); + CPPUNIT_ASSERT_EQUAL(sal_uInt64(0), strm->GetSize()); strm.reset(); url = INetURLObject("data:;bAsE64,"); CPPUNIT_ASSERT(!url.HasError()); strm = url.getData(); CPPUNIT_ASSERT(strm != 0); - CPPUNIT_ASSERT_EQUAL(sal_uIntPtr(0), strm->GetSize()); + CPPUNIT_ASSERT_EQUAL(sal_uInt64(0), strm->GetSize()); strm.reset(); url = INetURLObject("data:;base64,YWJjCg=="); CPPUNIT_ASSERT(!url.HasError()); strm = url.getData(); CPPUNIT_ASSERT(strm != 0); - CPPUNIT_ASSERT_EQUAL(sal_uIntPtr(4), strm->GetSize()); + CPPUNIT_ASSERT_EQUAL(sal_uInt64(4), strm->GetSize()); buf = static_cast<unsigned char const *>(strm->GetData()); CPPUNIT_ASSERT_EQUAL(0x61, int(buf[0])); CPPUNIT_ASSERT_EQUAL(0x62, int(buf[1])); @@ -315,7 +315,7 @@ namespace tools_urlobj CPPUNIT_ASSERT(!url.HasError()); strm = url.getData(); CPPUNIT_ASSERT(strm != 0); - CPPUNIT_ASSERT_EQUAL(sal_uIntPtr(4), strm->GetSize()); + CPPUNIT_ASSERT_EQUAL(sal_uInt64(4), strm->GetSize()); buf = static_cast<unsigned char const *>(strm->GetData()); CPPUNIT_ASSERT_EQUAL(0x59, int(buf[0])); CPPUNIT_ASSERT_EQUAL(0x51, int(buf[1])); diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index da91a21a6b82..e1c5b174e007 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1718,7 +1718,7 @@ const void* SvMemoryStream::GetBuffer() return GetData(); } -sal_uIntPtr SvMemoryStream::GetSize() +sal_uInt64 SvMemoryStream::GetSize() { Flush(); sal_uInt64 const nTemp = Tell(); |