summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tools/stream.hxx1
-rw-r--r--svl/source/items/cenumitm.cxx4
-rw-r--r--svl/source/items/ctypeitm.cxx4
-rw-r--r--svl/source/items/visitem.cxx4
-rw-r--r--svl/source/numbers/zformat.cxx10
-rw-r--r--tools/source/stream/stream.cxx24
6 files changed, 36 insertions, 11 deletions
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 4f8085d6864b..d04109f39dbc 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -308,6 +308,7 @@ public:
SvStream& ReadSChar( signed char& rChar );
SvStream& ReadChar( char& rChar );
SvStream& ReadUChar( unsigned char& rChar );
+ SvStream& ReadCharAsBool( bool& rBool );
SvStream& ReadFloat( float& rFloat );
SvStream& ReadDouble( double& rDouble );
SvStream& ReadStream( SvStream& rStream );
diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx
index 74a631430b78..bf13761371b4 100644
--- a/svl/source/items/cenumitm.cxx
+++ b/svl/source/items/cenumitm.cxx
@@ -169,8 +169,8 @@ TYPEINIT1_AUTOFACTORY(SfxBoolItem, SfxPoolItem);
SfxBoolItem::SfxBoolItem(sal_uInt16 const nWhich, SvStream & rStream)
: SfxPoolItem(nWhich)
{
- unsigned char tmp = 0;
- rStream.ReadUChar( tmp );
+ bool tmp = false;
+ rStream.ReadCharAsBool( tmp );
m_bValue = tmp;
}
diff --git a/svl/source/items/ctypeitm.cxx b/svl/source/items/ctypeitm.cxx
index d2299ae61ce5..16a8bf8760fb 100644
--- a/svl/source/items/ctypeitm.cxx
+++ b/svl/source/items/ctypeitm.cxx
@@ -71,8 +71,8 @@ SfxPoolItem* CntContentTypeItem::Create( SvStream& rStream,
rStream.ReadUInt32( nMagic );
if (nMagic == CNTSTRINGITEM_STREAM_MAGIC)
{
- unsigned char bEncrypted = sal_False;
- rStream.ReadUChar( bEncrypted );
+ bool bEncrypted = false;
+ rStream.ReadCharAsBool( bEncrypted );
DBG_ASSERT(!bEncrypted,
"CntContentTypeItem::Create() reads encrypted data");
}
diff --git a/svl/source/items/visitem.cxx b/svl/source/items/visitem.cxx
index dbd8ec5c37cf..8adc76228ca2 100644
--- a/svl/source/items/visitem.cxx
+++ b/svl/source/items/visitem.cxx
@@ -33,8 +33,8 @@ SfxVisibilityItem::SfxVisibilityItem(sal_uInt16 which, SvStream & rStream):
SfxPoolItem(which)
{
DBG_CTOR(SfxVisibilityItem, 0);
- unsigned char bValue = 0;
- rStream.ReadUChar( bValue );
+ bool bValue = false;
+ rStream.ReadCharAsBool( bValue );
m_nValue.bVisible = bValue;
}
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 73072a3cb283..6bf72257087c 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -184,8 +184,8 @@ void ImpSvNumberformatInfo::Load(SvStream& rStream, sal_uInt16 nAnz)
sStrArray[i] = SvNumberformat::LoadString( rStream );
rStream.ReadInt16( nTypeArray[i] );
}
- unsigned char bStreamThousand;
- rStream.ReadInt16( eScannedType ).ReadUChar( bStreamThousand ).ReadUInt16( nThousand )
+ bool bStreamThousand;
+ rStream.ReadInt16( eScannedType ).ReadCharAsBool( bStreamThousand ).ReadUInt16( nThousand )
.ReadUInt16( nCntPre ).ReadUInt16( nCntPost ).ReadUInt16( nCntExp );
bThousand = bStreamThousand;
}
@@ -1702,9 +1702,9 @@ NfHackConversion SvNumberformat::Load( SvStream& rStream,
rHdr.StartEntry();
sal_uInt16 nOp1, nOp2;
sFormatstring = SvNumberformat::LoadString( rStream );
- unsigned char bStreamStandard, bStreamUsed;
+ bool bStreamStandard, bStreamUsed;
rStream.ReadInt16( eType ).ReadDouble( fLimit1 ).ReadDouble( fLimit2 )
- .ReadUInt16( nOp1 ).ReadUInt16( nOp2 ).ReadUChar( bStreamStandard ).ReadUChar( bStreamUsed );
+ .ReadUInt16( nOp1 ).ReadUInt16( nOp2 ).ReadCharAsBool( bStreamStandard ).ReadCharAsBool( bStreamUsed );
bStandard = bStreamStandard;
bIsUsed = bStreamUsed;
NfHackConversion eHackConversion = NF_CONVERT_NONE;
@@ -1795,7 +1795,7 @@ NfHackConversion SvNumberformat::Load( SvStream& rStream,
}
break;
case nNewStandardFlagVersionId :
- rStream.ReadUChar( bStreamStandard ); // the real standard flag
+ rStream.ReadCharAsBool( bStreamStandard ); // the real standard flag
bStandard = bStreamStandard;
break;
default:
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index ea34d30fedf9..acd48dd1e653 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1004,6 +1004,30 @@ SvStream& SvStream::ReadUChar( unsigned char& r )
return *this;
}
+SvStream& SvStream::ReadCharAsBool( bool& r )
+{
+ if( (bIoRead || !bIsConsistent) &&
+ sizeof(char) <= nBufFree )
+ {
+ SAL_WARN_IF(
+ *pBufPos > 1, "tools.stream", unsigned(*pBufPos) << " not 0/1");
+ r = *pBufPos != 0;
+ nBufActualPos += sizeof(char);
+ pBufPos += sizeof(char);
+ nBufFree -= sizeof(char);
+ }
+ else
+ {
+ unsigned char c;
+ if (Read(&c, 1) == 1)
+ {
+ SAL_WARN_IF(c > 1, "tools.stream", unsigned(c) << " not 0/1");
+ r = c != 0;
+ }
+ }
+ return *this;
+}
+
SvStream& SvStream::ReadFloat(float& r)
{
float n = 0;