From aa2f02a4dc8a05f49e679a26f2beebb9d66b2325 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 12 Dec 2014 10:45:32 +0200 Subject: remove operator>> and operator<< methods in favour of ReadXXX/WriteXXX methods Change-Id: I69eebee3a8ce5b40301db7940a1d85915c0bf6f4 --- include/oox/dump/dumperbase.hxx | 21 +++++---------- include/oox/helper/binaryinputstream.hxx | 43 +++++++++++++------------------ include/oox/helper/binaryoutputstream.hxx | 23 +++++++++++------ include/oox/ole/axbinaryreader.hxx | 4 +++ include/oox/ole/axbinarywriter.hxx | 5 ++++ oox/source/crypto/DocumentDecryption.cxx | 25 +++++++++--------- oox/source/crypto/DocumentEncryption.cxx | 4 +-- oox/source/crypto/Standard2007Engine.cxx | 4 +-- oox/source/dump/dffdumper.cxx | 6 ++--- oox/source/dump/dumperbase.cxx | 17 ++++++------ oox/source/dump/oledumper.cxx | 12 ++++----- oox/source/helper/binaryinputstream.cxx | 8 ++++-- oox/source/ole/axbinaryreader.cxx | 4 +-- oox/source/ole/axcontrol.cxx | 37 ++++++++++++++++---------- oox/source/ole/olehelper.cxx | 16 ++++++++---- oox/source/ole/vbacontrol.cxx | 3 ++- oox/source/ole/vbahelper.cxx | 3 ++- oox/source/ole/vbainputstream.cxx | 2 +- sc/source/filter/inc/biffinputstream.hxx | 2 +- sc/source/filter/oox/biffinputstream.cxx | 8 +++--- sc/source/filter/oox/stylesbuffer.cxx | 5 +++- 21 files changed, 139 insertions(+), 113 deletions(-) diff --git a/include/oox/dump/dumperbase.hxx b/include/oox/dump/dumperbase.hxx index a747de53bd6f..9a89f0ae5973 100644 --- a/include/oox/dump/dumperbase.hxx +++ b/include/oox/dump/dumperbase.hxx @@ -1557,8 +1557,7 @@ typedef ::boost::shared_ptr< InputObjectBase > InputObjectRef; template< typename Type > Type InputObjectBase::dumpName( const String& rName, const NameListWrapper& rListWrp ) { - Type nData; - *mxStrm >> nData; + Type nData = mxStrm->readValue(); writeNameItem( rName, nData, rListWrp ); return nData; } @@ -1566,8 +1565,7 @@ Type InputObjectBase::dumpName( const String& rName, const NameListWrapper& rLis template< typename Type > Type InputObjectBase::dumpDec( const String& rName, const NameListWrapper& rListWrp ) { - Type nData; - *mxStrm >> nData; + Type nData = mxStrm->readValue(); writeDecItem( rName, nData, rListWrp ); return nData; } @@ -1575,8 +1573,7 @@ Type InputObjectBase::dumpDec( const String& rName, const NameListWrapper& rList template< typename Type > Type InputObjectBase::dumpHex( const String& rName, const NameListWrapper& rListWrp ) { - Type nData; - *mxStrm >> nData; + Type nData = mxStrm->readValue(); writeHexItem( rName, nData, rListWrp ); return nData; } @@ -1584,8 +1581,7 @@ Type InputObjectBase::dumpHex( const String& rName, const NameListWrapper& rList template< typename Type > Type InputObjectBase::dumpBin( const String& rName, const NameListWrapper& rListWrp ) { - Type nData; - *mxStrm >> nData; + Type nData = mxStrm->readValue(); writeBinItem( rName, nData, rListWrp ); return nData; } @@ -1593,8 +1589,7 @@ Type InputObjectBase::dumpBin( const String& rName, const NameListWrapper& rList template< typename Type > Type InputObjectBase::dumpFix( const String& rName, const NameListWrapper& rListWrp ) { - Type nData; - *mxStrm >> nData; + Type nData = mxStrm->readValue(); writeFixItem( rName, nData, rListWrp ); return nData; } @@ -1602,8 +1597,7 @@ Type InputObjectBase::dumpFix( const String& rName, const NameListWrapper& rList template< typename Type > Type InputObjectBase::dumpBool( const String& rName, const NameListWrapper& rListWrp ) { - Type nData; - *mxStrm >> nData; + Type nData = mxStrm->readValue(); writeDecBoolItem( rName, nData, rListWrp ); return nData; } @@ -1611,8 +1605,7 @@ Type InputObjectBase::dumpBool( const String& rName, const NameListWrapper& rLis template< typename Type > Type InputObjectBase::dumpValue( const ItemFormat& rItemFmt ) { - Type nData; - *mxStrm >> nData; + Type nData = mxStrm->readValue(); writeValueItem( rItemFmt, nData ); return nData; } diff --git a/include/oox/helper/binaryinputstream.hxx b/include/oox/helper/binaryinputstream.hxx index 0ddc1abb1fd6..49186054954e 100644 --- a/include/oox/helper/binaryinputstream.hxx +++ b/include/oox/helper/binaryinputstream.hxx @@ -78,28 +78,19 @@ public: All data types supported by the ByteOrderConverter class can be used. */ template< typename Type > - void readValue( Type& ornValue ); - - /** Reads a value from the stream and converts it to platform byte order. - All data types supported by the ByteOrderConverter class can be used. - */ - template< typename Type > - Type readValue() { Type nValue; readValue( nValue ); return nValue; } - - /** Stream operator for all data types supported by the readValue() function. */ - template< typename Type > - BinaryInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } - - sal_Int8 readInt8() { return readValue< sal_Int8 >(); } - sal_uInt8 readuInt8() { return readValue< sal_uInt8 >(); } - sal_Int16 readInt16() { return readValue< sal_Int16 >(); } - sal_uInt16 readuInt16() { return readValue< sal_uInt16 >(); } - sal_Int32 readInt32() { return readValue< sal_Int32 >(); } - sal_uInt32 readuInt32() { return readValue< sal_uInt32 >(); } - sal_Int64 readInt64() { return readValue< sal_Int64 >(); } - sal_uInt64 readuInt64() { return readValue< sal_uInt64 >(); } - float readFloat() { return readValue< float >(); } - double readDouble() { return readValue< double >(); } + Type readValue(); + + sal_Int8 readInt8() { return readValue(); } + sal_uInt8 readuInt8() { return readValue(); } + sal_Int16 readInt16() { return readValue(); } + sal_uInt16 readuInt16() { return readValue(); } + sal_Int32 readInt32() { return readValue(); } + sal_uInt32 readuInt32() { return readValue(); } + sal_Int64 readInt64() { return readValue(); } + sal_uInt64 readuInt64() { return readValue(); } + float readFloat() { return readValue(); } + double readDouble() { return readValue(); } + unsigned char readuChar() { return readValue(); } /** Reads a (preallocated!) C array of values from the stream. @@ -226,10 +217,12 @@ typedef ::boost::shared_ptr< BinaryInputStream > BinaryInputStreamRef; template< typename Type > -void BinaryInputStream::readValue( Type& ornValue ) +Type BinaryInputStream::readValue() { + Type ornValue; readMemory( &ornValue, static_cast< sal_Int32 >( sizeof( Type ) ), sizeof( Type ) ); ByteOrderConverter::convertLittleEndian( ornValue ); + return ornValue; } template< typename Type > @@ -309,7 +302,7 @@ public: /** Stream operator for all data types supported by the readValue() function. */ template< typename Type > - BinaryXInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } + BinaryXInputStream& operator>>( Type& ornValue ) { ornValue = readValue(); return *this; } private: StreamDataSequence maBuffer; ///< Data buffer used in readMemory() function. @@ -350,7 +343,7 @@ public: /** Stream operator for all data types supported by the readValue() function. */ template< typename Type > - SequenceInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } + SequenceInputStream& operator>>( Type& ornValue ) { ornValue = readValue(); return *this; } private: /** Returns the number of bytes available in the sequence for the passed byte count. */ diff --git a/include/oox/helper/binaryoutputstream.hxx b/include/oox/helper/binaryoutputstream.hxx index 4ccc58523bdc..0674481ccdc4 100644 --- a/include/oox/helper/binaryoutputstream.hxx +++ b/include/oox/helper/binaryoutputstream.hxx @@ -58,21 +58,28 @@ public: */ virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) = 0; - /** Writes a value to the stream and converts it to platform byte order. - All data types supported by the ByteOrderConverter class can be used. - */ - template< typename Type > - void writeValue( Type nValue ); - template< typename Type > void writeArray( Type* opnArray, sal_Int32 nElemCount ); template< typename Type > void writeArray( const Type* opnArray, sal_Int32 nElemCount ); - /** Stream operator for all data types supported by the writeValue() function. */ + /** Writes a value to the stream and converts it to platform byte order. + All data types supported by the ByteOrderConverter class can be used. + */ template< typename Type > - BinaryOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; } + void writeValue( Type nValue ); + + BinaryOutputStream& WriteInt8(sal_Int8 x) { writeValue(x); return *this; } + BinaryOutputStream& WriteUInt8(sal_uInt8 x) { writeValue(x); return *this; } + BinaryOutputStream& WriteInt16(sal_Int16 x) { writeValue(x); return *this; } + BinaryOutputStream& WriteUInt16(sal_uInt16 x) { writeValue(x); return *this; } + BinaryOutputStream& WriteInt32(sal_Int32 x) { writeValue(x); return *this; } + BinaryOutputStream& WriteUInt32(sal_uInt32 x) { writeValue(x); return *this; } + BinaryOutputStream& WriteInt64(sal_Int64 x) { writeValue(x); return *this; } + BinaryOutputStream& WriteUInt64(sal_uInt64 x) { writeValue(x); return *this; } + BinaryOutputStream& WriteFloat(float x) { writeValue(x); return *this; } + BinaryOutputStream& WriteDouble(double x) { writeValue(x); return *this; } void writeCompressedUnicodeArray( const OUString& rString, bool bCompressed, bool bAllowNulChars = false ); diff --git a/include/oox/ole/axbinaryreader.hxx b/include/oox/ole/axbinaryreader.hxx index 7905e987a941..116d809a25f4 100644 --- a/include/oox/ole/axbinaryreader.hxx +++ b/include/oox/ole/axbinaryreader.hxx @@ -68,6 +68,10 @@ public: position of the wrapped stream at construction time). */ void align( size_t nSize ); + /** Stream operator for all data types supported by the readValue() function. */ + template< typename Type > + AxAlignedInputStream& operator>>( Type& ornValue ) { ornValue = readValue(); return *this; } + /** Aligns the stream according to the passed type and reads a value. */ template< typename Type > Type readAligned() { align( sizeof( Type ) ); return readValue< Type >(); } diff --git a/include/oox/ole/axbinarywriter.hxx b/include/oox/ole/axbinarywriter.hxx index 62029bb2f8ac..05d6c60bc7b9 100644 --- a/include/oox/ole/axbinarywriter.hxx +++ b/include/oox/ole/axbinarywriter.hxx @@ -55,6 +55,11 @@ public: void align( size_t nSize ); void pad( sal_Int32 nBytes, size_t nAtomSize = 1); + + /** Stream operator for all data types supported by the writeValue() function. */ + template< typename Type > + AxAlignedOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; } + /** Aligns the stream according to the passed type and reads a value. */ template< typename Type > void writeAligned( Type nVal ) { align( sizeof( Type ) ); writeValue( nVal ); } diff --git a/oox/source/crypto/DocumentDecryption.cxx b/oox/source/crypto/DocumentDecryption.cxx index 50a886875c11..fc93e0b46a31 100644 --- a/oox/source/crypto/DocumentDecryption.cxx +++ b/oox/source/crypto/DocumentDecryption.cxx @@ -264,33 +264,32 @@ bool DocumentDecryption::readStandard2007EncryptionInfo(BinaryInputStream& rStre mEngine.reset(engine); StandardEncryptionInfo& info = engine->getInfo(); - rStream >> info.header.flags; + info.header.flags = rStream.readuInt32(); if( getFlag( info.header.flags, ENCRYPTINFO_EXTERNAL ) ) return false; - sal_uInt32 nHeaderSize; - rStream >> nHeaderSize; + sal_uInt32 nHeaderSize = rStream.readuInt32(); sal_uInt32 actualHeaderSize = sizeof(info.header); if( (nHeaderSize < actualHeaderSize) ) return false; - rStream >> info.header.flags; - rStream >> info.header.sizeExtra; - rStream >> info.header.algId; - rStream >> info.header.algIdHash; - rStream >> info.header.keyBits; - rStream >> info.header.providedType; - rStream >> info.header.reserved1; - rStream >> info.header.reserved2; + info.header.flags = rStream.readuInt32(); + info.header.sizeExtra = rStream.readuInt32(); + info.header.algId = rStream.readuInt32(); + info.header.algIdHash = rStream.readuInt32(); + info.header.keyBits = rStream.readuInt32(); + info.header.providedType = rStream.readuInt32(); + info.header.reserved1 = rStream.readuInt32(); + info.header.reserved2 = rStream.readuInt32(); rStream.skip( nHeaderSize - actualHeaderSize ); - rStream >> info.verifier.saltSize; + info.verifier.saltSize = rStream.readuInt32(); rStream.readArray(info.verifier.salt, SAL_N_ELEMENTS(info.verifier.salt)); rStream.readArray(info.verifier.encryptedVerifier, SAL_N_ELEMENTS(info.verifier.encryptedVerifier)); - rStream >> info.verifier.encryptedVerifierHashSize; + info.verifier.encryptedVerifierHashSize = rStream.readuInt32(); rStream.readArray(info.verifier.encryptedVerifierHash, SAL_N_ELEMENTS(info.verifier.encryptedVerifierHash)); if( info.verifier.saltSize != 16 ) diff --git a/oox/source/crypto/DocumentEncryption.cxx b/oox/source/crypto/DocumentEncryption.cxx index 8928101a9bc2..cd6527aa95a2 100644 --- a/oox/source/crypto/DocumentEncryption.cxx +++ b/oox/source/crypto/DocumentEncryption.cxx @@ -59,8 +59,8 @@ bool DocumentEncryption::encrypt() BinaryXInputStream aDocumentInputStream( xInputStream, false ); aDocumentInputStream.seekToStart(); - aEncryptedPackageStream.writeValue( aLength ); // size - aEncryptedPackageStream.writeValue( 0 ); // reserved + aEncryptedPackageStream.WriteUInt32( aLength ); // size + aEncryptedPackageStream.WriteUInt32( 0U ); // reserved mEngine.encrypt(aDocumentInputStream, aEncryptedPackageStream); diff --git a/oox/source/crypto/Standard2007Engine.cxx b/oox/source/crypto/Standard2007Engine.cxx index c59e840c7b3d..311fea7f930e 100644 --- a/oox/source/crypto/Standard2007Engine.cxx +++ b/oox/source/crypto/Standard2007Engine.cxx @@ -221,7 +221,7 @@ bool Standard2007Engine::writeEncryptionInfo(const OUString& password, BinaryXOu if (!generateVerifier()) return false; - rStream.writeValue(VERSION_INFO_2007_FORMAT); + rStream.WriteUInt32(VERSION_INFO_2007_FORMAT); sal_uInt32 cspNameSize = (lclCspName.getLength() * 2) + 2; @@ -233,7 +233,7 @@ bool Standard2007Engine::writeEncryptionInfo(const OUString& password, BinaryXOu rStream.writeMemory(&mInfo.header, encryptionHeaderSize); rStream.writeUnicodeArray(lclCspName); - rStream.writeValue(0); + rStream.WriteUInt16(0); sal_uInt32 encryptionVerifierSize = static_cast(sizeof(EncryptionVerifierAES)); rStream.writeMemory(&mInfo.verifier, encryptionVerifierSize); diff --git a/oox/source/dump/dffdumper.cxx b/oox/source/dump/dffdumper.cxx index 318a129541ea..e2f76a1e25ae 100644 --- a/oox/source/dump/dffdumper.cxx +++ b/oox/source/dump/dffdumper.cxx @@ -47,9 +47,9 @@ const sal_uInt16 DFF_OPT_FLAGSMASK = 0x003F; bool DffStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) { - sal_uInt16 nRecId; - rBaseStrm >> mnInstVer >> nRecId >> mnRealSize; - ornRecId = nRecId; + mnInstVer = rBaseStrm.readuInt16(); + ornRecId = rBaseStrm.readuInt16(); + mnRealSize = rBaseStrm.readInt32(); ornRecSize = isContainer() ? 0 : mnRealSize; return !rBaseStrm.isEof(); } diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index 2dac7bc006b4..556b685ab5c4 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -2157,8 +2157,7 @@ void InputObjectBase::dumpArray( const String& rName, sal_Int32 nBytes, sal_Unic sal_Unicode InputObjectBase::dumpUnicode( const String& rName ) { - sal_uInt16 nChar; - *mxStrm >> nChar; + sal_uInt16 nChar = mxStrm->readuInt16(); sal_Unicode cChar = static_cast< sal_Unicode >( nChar ); writeCharItem( rName( "char" ), cChar ); return cChar; @@ -2185,7 +2184,9 @@ OUString InputObjectBase::dumpUnicodeArray( const String& rName, sal_Int32 nLen, { OUStringBuffer aBuffer; for( sal_Int32 nIndex = 0; !mxStrm->isEof() && (nIndex < nLen); ++nIndex ) + { aBuffer.append( static_cast< sal_Unicode >( mxStrm->readuInt16() ) ); + } OUString aString = aBuffer.makeStringAndClear(); if( bHideTrailingNul ) aString = StringHelper::trimTrailingNul( aString ); @@ -2249,23 +2250,23 @@ OUString InputObjectBase::dumpGuid( const String& rName ) sal_uInt16 nData16; sal_uInt8 nData8; - *mxStrm >> nData32; + nData32 = mxStrm->readuInt32(); StringHelper::appendHex( aBuffer, nData32, false ); aBuffer.append( '-' ); - *mxStrm >> nData16; + nData16 = mxStrm->readuInt16(); StringHelper::appendHex( aBuffer, nData16, false ); aBuffer.append( '-' ); - *mxStrm >> nData16; + nData16 = mxStrm->readuInt16(); StringHelper::appendHex( aBuffer, nData16, false ); aBuffer.append( '-' ); - *mxStrm >> nData8; + nData8 = mxStrm->readuChar(); StringHelper::appendHex( aBuffer, nData8, false ); - *mxStrm >> nData8; + nData8 = mxStrm->readuChar( ); StringHelper::appendHex( aBuffer, nData8, false ); aBuffer.append( '-' ); for( int nIndex = 0; nIndex < 6; ++nIndex ) { - *mxStrm >> nData8; + nData8 = mxStrm->readuChar( ); StringHelper::appendHex( aBuffer, nData8, false ); } StringHelper::enclose( aBuffer, '{', '}' ); diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx index a16ea7121d54..feb51ff08ebf 100644 --- a/oox/source/dump/oledumper.cxx +++ b/oox/source/dump/oledumper.cxx @@ -546,8 +546,8 @@ bool ComCtlObjectBase::dumpComCtlHeader( sal_uInt32 nExpId, sal_uInt16 nExpMajor // no idea if all this is correct... sal_uInt32 nId = dumpHex< sal_uInt32 >( "header-id", "COMCTL-HEADER-IDS" ); ItemGuard aItem( mxOut, "version" ); - sal_uInt16 nMinor, nMajor; - *mxStrm >> nMinor >> nMajor; + sal_uInt16 nMinor = mxStrm->readuInt16(); + sal_uInt16 nMajor = mxStrm->readuInt16(); mxOut->writeDec( nMajor ); mxOut->writeChar( '.' ); mxOut->writeDec( nMinor ); @@ -1042,8 +1042,8 @@ void AxPropertyObjectBase::constructAxPropObj( const String& rPropNameList, bool void AxPropertyObjectBase::dumpVersion() { ItemGuard aItem( mxOut, "version" ); - sal_uInt8 nMinor, nMajor; - *mxStrm >> nMinor >> nMajor; + sal_uInt8 nMinor = mxStrm->readuChar(); + sal_uInt8 nMajor = mxStrm->readuChar(); mxOut->writeDec( nMajor ); mxOut->writeChar( '.' ); mxOut->writeDec( nMinor ); @@ -1885,8 +1885,8 @@ bool VbaDirStreamObject::implIsValid() const bool VbaDirStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) { - ornRecId = rBaseStrm.readuInt16(); - ornRecSize = rBaseStrm.readInt32(); + ornRecId = rBaseStrm.readuInt16(); + ornRecSize = rBaseStrm.readInt32(); // for no obvious reason, PROJECTVERSION record contains size field of 4, but is 6 bytes long if( ornRecId == 9 ) diff --git a/oox/source/helper/binaryinputstream.cxx b/oox/source/helper/binaryinputstream.cxx index b514beb70fba..7597981c29ec 100644 --- a/oox/source/helper/binaryinputstream.cxx +++ b/oox/source/helper/binaryinputstream.cxx @@ -42,8 +42,12 @@ const sal_Int32 INPUTSTREAM_BUFFERSIZE = 0x8000; OUString BinaryInputStream::readNulUnicodeArray() { OUStringBuffer aBuffer; - for( sal_uInt16 nChar = readuInt16(); !mbEof && (nChar > 0); readValue( nChar ) ) - aBuffer.append( static_cast< sal_Unicode >( nChar ) ); + for (;;) + { + sal_uInt16 nChar = readuInt16(); + if ( mbEof || (nChar < 0) ) break; + aBuffer.append( static_cast< sal_Unicode >( nChar ) ); + } return aBuffer.makeStringAndClear(); } diff --git a/oox/source/ole/axbinaryreader.cxx b/oox/source/ole/axbinaryreader.cxx index cee80c4fa08a..b06910786669 100644 --- a/oox/source/ole/axbinaryreader.cxx +++ b/oox/source/ole/axbinaryreader.cxx @@ -175,11 +175,11 @@ AxBinaryPropertyReader::AxBinaryPropertyReader( BinaryInputStream& rInStrm, bool { // version and size of property block maInStrm.skip( 2 ); - sal_uInt16 nBlockSize = maInStrm.readValue< sal_uInt16 >(); + sal_uInt16 nBlockSize = maInStrm.readuInt16(); mnPropsEnd = maInStrm.tell() + nBlockSize; // flagfield containing existing properties if( b64BitPropFlags ) - maInStrm >> mnPropFlags; + mnPropFlags = maInStrm.readInt64(); else mnPropFlags = maInStrm.readuInt32(); mnNextProp = 1; diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 4dca8af8d198..8efc05bf952c 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -663,7 +663,9 @@ bool ComCtlModelBase::importBinaryModel( BinaryInputStream& rInStrm ) if( importSizePart( rInStrm ) && readPartHeader( rInStrm, getDataPartId(), mnVersion ) ) { // if flags part exists, the first int32 of the data part contains its size - sal_uInt32 nCommonPartSize = mbCommonPart ? rInStrm.readuInt32() : 0; + sal_uInt32 nCommonPartSize = 0; + if (mbCommonPart) + nCommonPartSize = rInStrm.readuInt32(); // implementations must read the exact amount of data, stream must point to its end afterwards importControlData( rInStrm ); // read following parts @@ -706,9 +708,9 @@ sal_uInt32 ComCtlModelBase::getDataPartId() const bool ComCtlModelBase::readPartHeader( BinaryInputStream& rInStrm, sal_uInt32 nExpPartId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor ) { // no idea if all this is correct... - sal_uInt32 nPartId; - sal_uInt16 nMajor, nMinor; - rInStrm >> nPartId >> nMinor >> nMajor; + sal_uInt32 nPartId = rInStrm.readuInt32(); + sal_uInt16 nMinor = rInStrm.readuInt16(); + sal_uInt16 nMajor = rInStrm.readuInt16(); bool bPartId = nPartId == nExpPartId; OSL_ENSURE( bPartId, "ComCtlObjectBase::readPartHeader - unexpected part identifier" ); bool bVersion = ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor)); @@ -720,7 +722,8 @@ bool ComCtlModelBase::importSizePart( BinaryInputStream& rInStrm ) { if( readPartHeader( rInStrm, COMCTL_ID_SIZE, 0, 8 ) ) { - rInStrm >> maSize.first >> maSize.second; + maSize.first = rInStrm.readInt32(); + maSize.second = rInStrm.readInt32(); return !rInStrm.isEof(); } return false; @@ -732,7 +735,7 @@ bool ComCtlModelBase::importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 n if( (nPartSize >= 16) && readPartHeader( rInStrm, COMCTL_ID_COMMONDATA, 5, 0 ) ) { rInStrm.skip( 4 ); - rInStrm >> mnFlags; + mnFlags = rInStrm.readuInt32(); // implementations may read less than the exact amount of data importCommonExtraData( rInStrm ); rInStrm.seek( nEndPos ); @@ -747,8 +750,7 @@ bool ComCtlModelBase::importComplexPart( BinaryInputStream& rInStrm ) { if( readPartHeader( rInStrm, COMCTL_ID_COMPLEXDATA, 5, 1 ) ) { - sal_uInt32 nContFlags; - rInStrm >> nContFlags; + sal_uInt32 nContFlags = rInStrm.readuInt32(); bool bReadOk = (!getFlag( nContFlags, COMCTL_COMPLEX_FONT ) || OleHelper::importStdFont( maFontData, rInStrm, true )) && (!getFlag( nContFlags, COMCTL_COMPLEX_MOUSEICON ) || OleHelper::importStdPic( maMouseIcon, rInStrm, true )); @@ -783,7 +785,12 @@ void ComCtlScrollBarModel::convertProperties( PropertyMap& rPropMap, const Contr void ComCtlScrollBarModel::importControlData( BinaryInputStream& rInStrm ) { - rInStrm >> mnScrollBarFlags >> mnLargeChange >> mnSmallChange >> mnMin >> mnMax >> mnPosition; + mnScrollBarFlags = rInStrm.readuInt32(); + mnLargeChange = rInStrm.readInt32(); + mnSmallChange = rInStrm.readInt32(); + mnMin = rInStrm.readInt32(); + mnMax = rInStrm.readInt32(); + mnPosition = rInStrm.readInt32(); } ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion ) : @@ -813,9 +820,13 @@ void ComCtlProgressBarModel::convertProperties( PropertyMap& rPropMap, const Con void ComCtlProgressBarModel::importControlData( BinaryInputStream& rInStrm ) { - rInStrm >> mfMin >> mfMax; + mfMin = rInStrm.readFloat(); + mfMax = rInStrm.readFloat(); if( mnVersion == COMCTL_VERSION_60 ) - rInStrm >> mnVertical >> mnSmooth; + { + mnVertical = rInStrm.readuInt16(); + mnSmooth = rInStrm.readuInt16(); + } } AxControlModelBase::AxControlModelBase() @@ -2478,9 +2489,7 @@ bool AxMultiPageModel::importPageAndMultiPageProperties( BinaryInputStream& rInS // IDs for ( sal_uInt32 count = 0; count < nPageCount; ++count ) { - sal_Int32 nID = 0; - rInStrm >> nID; - mnIDs.push_back( nID ); + mnIDs.push_back( rInStrm.readInt32() ); } return true; } diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index 92aacef2d05d..e6c854c370cf 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -260,9 +260,9 @@ sal_uInt32 OleHelper::encodeOleColor( sal_Int32 nRgbColor ) void OleHelper::exportGuid( BinaryOutputStream& rOStr, const SvGlobalName& rId ) { - rOStr << rId.GetCLSID().Data1; - rOStr << rId.GetCLSID().Data2; - rOStr << rId.GetCLSID().Data3; + rOStr.WriteUInt32( rId.GetCLSID().Data1 ); + rOStr.WriteUInt16( rId.GetCLSID().Data2 ); + rOStr.WriteUInt16( rId.GetCLSID().Data3 ); rOStr.writeArray( rId.GetCLSID().Data4, 8 ); } @@ -296,7 +296,12 @@ bool OleHelper::importStdFont( StdFontInfo& orFontInfo, BinaryInputStream& rInSt } sal_uInt8 nVersion, nNameLen; - rInStrm >> nVersion >> orFontInfo.mnCharSet >> orFontInfo.mnFlags >> orFontInfo.mnWeight >> orFontInfo.mnHeight >> nNameLen; + nVersion = rInStrm.readuChar(); + orFontInfo.mnCharSet = rInStrm.readuInt16(); + orFontInfo.mnFlags = rInStrm.readuChar(); + orFontInfo.mnWeight = rInStrm.readuInt16(); + orFontInfo.mnHeight = rInStrm.readuInt32(); + nNameLen = rInStrm.readuChar(); // according to spec the name is ASCII orFontInfo.maName = rInStrm.readCharArrayUC( nNameLen, RTL_TEXTENCODING_ASCII_US ); OSL_ENSURE( nVersion <= 1, "OleHelper::importStdFont - wrong version" ); @@ -315,7 +320,8 @@ bool OleHelper::importStdPic( StreamDataSequence& orGraphicData, BinaryInputStre sal_uInt32 nStdPicId; sal_Int32 nBytes; - rInStrm >> nStdPicId >> nBytes; + nStdPicId = rInStrm.readuInt32(); + nBytes = rInStrm.readInt32(); OSL_ENSURE( nStdPicId == OLE_STDPIC_ID, "OleHelper::importStdPic - unexpected header version" ); return !rInStrm.isEof() && (nStdPicId == OLE_STDPIC_ID) && (nBytes > 0) && (rInStrm.readData( orGraphicData, nBytes ) == nBytes); } diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx index 30d7e00eb9f0..ddfb303035d0 100644 --- a/oox/source/ole/vbacontrol.cxx +++ b/oox/source/ole/vbacontrol.cxx @@ -527,7 +527,8 @@ bool VbaFormControl::importEmbeddedSiteModels( BinaryInputStream& rInStrm ) { sal_uInt64 nAnchorPos = rInStrm.tell(); sal_uInt32 nSiteCount, nSiteDataSize; - rInStrm >> nSiteCount >> nSiteDataSize; + nSiteCount = rInStrm.readuInt32(); + nSiteDataSize = rInStrm.readuInt32(); sal_Int64 nSiteEndPos = rInStrm.tell() + nSiteDataSize; // skip the site info structure diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx index d47726f88873..c523688e0583 100644 --- a/oox/source/ole/vbahelper.cxx +++ b/oox/source/ole/vbahelper.cxx @@ -31,7 +31,8 @@ bool VbaHelper::readDirRecord( sal_uInt16& rnRecId, StreamDataSequence& rRecData { // read the record header sal_Int32 nRecSize; - rInStrm >> rnRecId >> nRecSize; + rnRecId = rInStrm.readuInt16(); + nRecSize = rInStrm.readInt32(); // for no obvious reason, PROJECTVERSION record contains size field of 4, but is 6 bytes long if( rnRecId == VBA_ID_PROJECTVERSION ) { diff --git a/oox/source/ole/vbainputstream.cxx b/oox/source/ole/vbainputstream.cxx index 15a926e28c6f..bd19460340ed 100644 --- a/oox/source/ole/vbainputstream.cxx +++ b/oox/source/ole/vbainputstream.cxx @@ -185,7 +185,7 @@ bool VbaInputStream::updateChunk() else { maChunk.resize( maChunk.size() + 1 ); - *mpInStrm >> maChunk.back(); + maChunk.back() = mpInStrm->readuChar(); ++nChunkPos; } } diff --git a/sc/source/filter/inc/biffinputstream.hxx b/sc/source/filter/inc/biffinputstream.hxx index c392cd149604..7eb816a6ae98 100644 --- a/sc/source/filter/inc/biffinputstream.hxx +++ b/sc/source/filter/inc/biffinputstream.hxx @@ -225,7 +225,7 @@ public: /** Stream operator for integral and floating-point types. */ template< typename Type > - inline BiffInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; } + inline BiffInputStream& operator>>( Type& ornValue ) { ornValue = readValue(); return *this; } // byte strings ----------------------------------------------------------- diff --git a/sc/source/filter/oox/biffinputstream.cxx b/sc/source/filter/oox/biffinputstream.cxx index 1e86645cfab4..3b1da98d31b7 100644 --- a/sc/source/filter/oox/biffinputstream.cxx +++ b/sc/source/filter/oox/biffinputstream.cxx @@ -76,7 +76,8 @@ bool BiffInputRecordBuffer::startRecord( sal_Int64 nHeaderPos ) { mnHeaderPos = nHeaderPos; mrInStrm.seek( nHeaderPos ); - mrInStrm >> mnRecId >> mnRecSize; + mnRecId = mrInStrm.readuInt16(); + mnRecSize = mrInStrm.readuInt16(); mnBodyPos = mrInStrm.tell(); mnNextHeaderPos = mnBodyPos + mnRecSize; mbValidHeader = !mrInStrm.isEof() && (mnNextHeaderPos <= mrInStrm.size()); @@ -103,7 +104,7 @@ sal_uInt16 BiffInputRecordBuffer::getNextRecId() if( mbValidHeader && (mnNextHeaderPos + 4 <= mrInStrm.size()) ) { mrInStrm.seek( mnNextHeaderPos ); - mrInStrm >> nRecId; + nRecId = mrInStrm.readuInt16(); } return nRecId; } @@ -445,8 +446,7 @@ bool BiffInputStream::jumpToNextStringContinue( bool& rb16BitChars ) } // trying to read the flags invalidates stream, if no CONTINUE record has been found - sal_uInt8 nFlags; - readValue( nFlags ); + sal_uInt8 nFlags = readuInt8(); rb16BitChars = getFlag( nFlags, BIFF_STRF_16BIT ); return !mbEof; } diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx index 498241f1f7c7..1a78749b0116 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -207,7 +207,10 @@ const sal_uInt8 BIFF_FONTUNDERL_DOUBLE_ACC = 34; sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm ) { sal_uInt8 nR, nG, nB, nA; - rStrm >> nR >> nG >> nB >> nA; + nR = rStrm.readuChar(); + nG = rStrm.readuChar(); + nB = rStrm.readuChar(); + nA = rStrm.readuChar(); sal_Int32 nValue = nA; nValue <<= 8; nValue |= nR; -- cgit