summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-27 11:18:42 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-04-27 06:48:18 +0200
commitcae53cf14d59bc2fa6317c9493197804928d6e5e (patch)
tree4420d17bf2c9f1aa001c98c5c140ebd7ed04c30e /vcl
parent55e28737e973b40f72d398c9bb7a4a41307eb562 (diff)
Decouple reading/writing of Color into GenericTypeSerializer
This adds GenericTypeSerializer, which is now responsible of serializing the Color into a stream (other types will follow), but only for the older version of the binary format. The new version we just write the sal_UInt32 mValue directly. This is a start of decoupling the serialization of generic types in tools and vcl module from the actual type, so we can in the future replace those with basegfx variant. Change-Id: I92738e7c178cac5cbca882dcbe45c80cc8269466 Reviewed-on: https://gerrit.libreoffice.org/71404 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/dibtools.cxx13
-rw-r--r--vcl/source/gdi/gradient.cxx11
-rw-r--r--vcl/source/gdi/graphictools.cxx20
-rw-r--r--vcl/source/gdi/hatch.cxx21
-rw-r--r--vcl/source/gdi/metaact.cxx32
-rw-r--r--vcl/source/gdi/svmconverter.cxx5
-rw-r--r--vcl/source/gdi/wall.cxx12
7 files changed, 68 insertions, 46 deletions
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index b04296259f50..fabd86045a33 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -28,6 +28,7 @@
#include <tools/stream.hxx>
#include <tools/fract.hxx>
#include <tools/helpers.hxx>
+#include <tools/GenericTypeSerializer.hxx>
#include <unotools/configmgr.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/bitmapaccess.hxx>
@@ -35,7 +36,6 @@
#include <bitmapwriteaccess.hxx>
#include <memory>
-
#define DIBCOREHEADERSIZE ( 12UL )
#define DIBINFOHEADERSIZE ( sizeof(DIBInfoHeader) )
#define DIBV5HEADERSIZE ( sizeof(DIBV5Header) )
@@ -1800,14 +1800,16 @@ bool ReadDIBBitmapEx(
}
case TransparentType::Color:
{
- Color maTransparentColor;
+ Color aTransparentColor;
+
+ tools::GenericTypeSerializer aSerializer(rIStm);
+ aSerializer.readColor(aTransparentColor);
- ReadColor( rIStm, maTransparentColor );
bRetval = !rIStm.GetError();
if(bRetval)
{
- rTarget = BitmapEx(aBmp, maTransparentColor);
+ rTarget = BitmapEx(aBmp, aTransparentColor);
}
break;
}
@@ -1885,7 +1887,8 @@ bool WriteDIBBitmapEx(
}
else if(TransparentType::Color == rSource.meTransparent)
{
- WriteColor( rOStm, rSource.maTransparentColor );
+ tools::GenericTypeSerializer aSerializer(rOStm);
+ aSerializer.writeColor(rSource.maTransparentColor);
return true;
}
}
diff --git a/vcl/source/gdi/gradient.cxx b/vcl/source/gdi/gradient.cxx
index e60009519a34..4c13bb423134 100644
--- a/vcl/source/gdi/gradient.cxx
+++ b/vcl/source/gdi/gradient.cxx
@@ -20,6 +20,7 @@
#include <tools/stream.hxx>
#include <tools/vcompat.hxx>
#include <tools/gen.hxx>
+#include <tools/GenericTypeSerializer.hxx>
#include <vcl/gradient.hxx>
Impl_Gradient::Impl_Gradient() :
@@ -225,8 +226,9 @@ SvStream& ReadGradient( SvStream& rIStm, Gradient& rGradient )
rIStm.ReadUInt16( nTmp16 ); rGradient.mpImplGradient->meStyle = static_cast<GradientStyle>(nTmp16);
- ReadColor( rIStm, rGradient.mpImplGradient->maStartColor );
- ReadColor( rIStm, rGradient.mpImplGradient->maEndColor );
+ tools::GenericTypeSerializer aSerializer(rIStm);
+ aSerializer.readColor(rGradient.mpImplGradient->maStartColor);
+ aSerializer.readColor(rGradient.mpImplGradient->maEndColor);
rIStm.ReadUInt16( rGradient.mpImplGradient->mnAngle )
.ReadUInt16( rGradient.mpImplGradient->mnBorder )
.ReadUInt16( rGradient.mpImplGradient->mnOfsX )
@@ -243,8 +245,9 @@ SvStream& WriteGradient( SvStream& rOStm, const Gradient& rGradient )
VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
rOStm.WriteUInt16( static_cast<sal_uInt16>(rGradient.mpImplGradient->meStyle) );
- WriteColor( rOStm, rGradient.mpImplGradient->maStartColor );
- WriteColor( rOStm, rGradient.mpImplGradient->maEndColor );
+ tools::GenericTypeSerializer aSerializer(rOStm);
+ aSerializer.writeColor(rGradient.mpImplGradient->maStartColor);
+ aSerializer.writeColor(rGradient.mpImplGradient->maEndColor);
rOStm.WriteUInt16( rGradient.mpImplGradient->mnAngle )
.WriteUInt16( rGradient.mpImplGradient->mnBorder )
.WriteUInt16( rGradient.mpImplGradient->mnOfsX )
diff --git a/vcl/source/gdi/graphictools.cxx b/vcl/source/gdi/graphictools.cxx
index 948580cf5123..4be1b43fadb7 100644
--- a/vcl/source/gdi/graphictools.cxx
+++ b/vcl/source/gdi/graphictools.cxx
@@ -19,6 +19,7 @@
#include <tools/stream.hxx>
#include <tools/vcompat.hxx>
+#include <tools/GenericTypeSerializer.hxx>
#include <vcl/graphictools.hxx>
@@ -236,7 +237,8 @@ SvStream& WriteSvtGraphicFill( SvStream& rOStm, const SvtGraphicFill& rClass )
VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
rClass.maPath.Write( rOStm );
- WriteColor( rOStm, rClass.maFillColor );
+ tools::GenericTypeSerializer aSerializer(rOStm);
+ aSerializer.writeColor(rClass.maFillColor);
rOStm.WriteDouble( rClass.mfTransparency );
sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillRule );
rOStm.WriteUInt16( nTmp );
@@ -249,11 +251,11 @@ SvStream& WriteSvtGraphicFill( SvStream& rOStm, const SvtGraphicFill& rClass )
rOStm.WriteUInt16( nTmp );
nTmp = sal::static_int_cast<sal_uInt16>( rClass.maHatchType );
rOStm.WriteUInt16( nTmp );
- WriteColor( rOStm, rClass.maHatchColor );
+ aSerializer.writeColor(rClass.maHatchColor);
nTmp = sal::static_int_cast<sal_uInt16>( rClass.maGradientType );
rOStm.WriteUInt16( nTmp );
- WriteColor( rOStm, rClass.maGradient1stColor );
- WriteColor( rOStm, rClass.maGradient2ndColor );
+ aSerializer.writeColor(rClass.maGradient1stColor);
+ aSerializer.writeColor(rClass.maGradient2ndColor);
rOStm.WriteInt32( rClass.maGradientStepCount );
WriteGraphic( rOStm, rClass.maFillGraphic );
@@ -265,7 +267,9 @@ SvStream& ReadSvtGraphicFill( SvStream& rIStm, SvtGraphicFill& rClass )
VersionCompat aCompat( rIStm, StreamMode::READ );
rClass.maPath.Read( rIStm );
- ReadColor( rIStm, rClass.maFillColor );
+
+ tools::GenericTypeSerializer aSerializer(rIStm);
+ aSerializer.readColor(rClass.maFillColor);
rIStm.ReadDouble( rClass.mfTransparency );
sal_uInt16 nTmp;
rIStm.ReadUInt16( nTmp );
@@ -278,11 +282,11 @@ SvStream& ReadSvtGraphicFill( SvStream& rIStm, SvtGraphicFill& rClass )
rClass.mbTiling = nTmp;
rIStm.ReadUInt16( nTmp );
rClass.maHatchType = SvtGraphicFill::HatchType( nTmp );
- ReadColor( rIStm, rClass.maHatchColor );
+ aSerializer.readColor(rClass.maHatchColor);
rIStm.ReadUInt16( nTmp );
rClass.maGradientType = SvtGraphicFill::GradientType( nTmp );
- ReadColor( rIStm, rClass.maGradient1stColor );
- ReadColor( rIStm, rClass.maGradient2ndColor );
+ aSerializer.readColor(rClass.maGradient1stColor);
+ aSerializer.readColor(rClass.maGradient2ndColor);
rIStm.ReadInt32( rClass.maGradientStepCount );
ReadGraphic( rIStm, rClass.maFillGraphic );
diff --git a/vcl/source/gdi/hatch.cxx b/vcl/source/gdi/hatch.cxx
index 1e4b4fa7bf92..06b15f1bbf6d 100644
--- a/vcl/source/gdi/hatch.cxx
+++ b/vcl/source/gdi/hatch.cxx
@@ -19,6 +19,7 @@
#include <tools/stream.hxx>
#include <tools/vcompat.hxx>
+#include <tools/GenericTypeSerializer.hxx>
#include <vcl/hatch.hxx>
ImplHatch::ImplHatch() :
@@ -77,13 +78,17 @@ void Hatch::SetAngle( sal_uInt16 nAngle10 )
SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch )
{
- VersionCompat aCompat( rIStm, StreamMode::READ );
- sal_uInt16 nTmp16;
- sal_Int32 nTmp32(0);
+ VersionCompat aCompat(rIStm, StreamMode::READ);
+ sal_uInt16 nTmp16;
+ sal_Int32 nTmp32(0);
- rIStm.ReadUInt16( nTmp16 ); rHatch.mpImplHatch->meStyle = static_cast<HatchStyle>(nTmp16);
- ReadColor( rIStm, rHatch.mpImplHatch->maColor ).ReadInt32( nTmp32 ).ReadUInt16(
- rHatch.mpImplHatch->mnAngle );
+ rIStm.ReadUInt16(nTmp16);
+ rHatch.mpImplHatch->meStyle = static_cast<HatchStyle>(nTmp16);
+
+ tools::GenericTypeSerializer aSerializer(rIStm);
+ aSerializer.readColor(rHatch.mpImplHatch->maColor);
+ rIStm.ReadInt32(nTmp32);
+ rIStm.ReadUInt16(rHatch.mpImplHatch->mnAngle);
rHatch.mpImplHatch->mnDistance = nTmp32;
return rIStm;
@@ -94,7 +99,9 @@ SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
rOStm.WriteUInt16( static_cast<sal_uInt16>(rHatch.mpImplHatch->meStyle) );
- WriteColor( rOStm, rHatch.mpImplHatch->maColor );
+
+ tools::GenericTypeSerializer aSerializer(rOStm);
+ aSerializer.writeColor(rHatch.mpImplHatch->maColor);
rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteUInt16( rHatch.mpImplHatch->mnAngle );
return rOStm;
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index 91abacfde3be..7813d1671846 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -310,14 +310,14 @@ void MetaPixelAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
WritePair( rOStm, maPt );
- maColor.Write( rOStm );
+ rOStm.WriteUInt32(maColor.mValue);
}
void MetaPixelAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompat aCompat(rIStm, StreamMode::READ);
ReadPair( rIStm, maPt );
- maColor.Read( rIStm);
+ rIStm.ReadUInt32(maColor.mValue);
}
MetaPointAction::MetaPointAction() :
@@ -1932,7 +1932,7 @@ void MetaMaskScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
WriteDIB(maBmp, rOStm, false, true);
- maColor.Write( rOStm );
+ rOStm.WriteUInt32(maColor.mValue);
WritePair( rOStm, maDstPt );
WritePair( rOStm, maDstSz );
WritePair( rOStm, maSrcPt );
@@ -1944,7 +1944,7 @@ void MetaMaskScalePartAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompat aCompat(rIStm, StreamMode::READ);
ReadDIB(maBmp, rIStm, true);
- maColor.Read( rIStm );
+ rIStm.ReadUInt32(maColor.mValue);
ReadPair( rIStm, maDstPt );
ReadPair( rIStm, maDstSz );
ReadPair( rIStm, maSrcPt );
@@ -2380,14 +2380,14 @@ void MetaLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
- maColor.Write( rOStm );
+ rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet );
}
void MetaLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompat aCompat(rIStm, StreamMode::READ);
- maColor.Read( rIStm );
+ rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet );
}
@@ -2422,14 +2422,14 @@ void MetaFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
- maColor.Write( rOStm );
+ rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet );
}
void MetaFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompat aCompat(rIStm, StreamMode::READ);
- maColor.Read( rIStm );
+ rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet );
}
@@ -2459,13 +2459,13 @@ void MetaTextColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
- maColor.Write( rOStm );
+ rOStm.WriteUInt32(maColor.mValue);
}
void MetaTextColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompat aCompat(rIStm, StreamMode::READ);
- maColor.Read( rIStm );
+ rIStm.ReadUInt32(maColor.mValue);
}
MetaTextFillColorAction::MetaTextFillColorAction() :
@@ -2499,14 +2499,14 @@ void MetaTextFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
- maColor.Write( rOStm );
+ rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet );
}
void MetaTextFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompat aCompat(rIStm, StreamMode::READ);
- maColor.Read( rIStm );
+ rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet );
}
@@ -2541,14 +2541,14 @@ void MetaTextLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
- maColor.Write( rOStm );
+ rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet );
}
void MetaTextLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompat aCompat(rIStm, StreamMode::READ);
- maColor.Read( rIStm );
+ rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet );
}
@@ -2583,14 +2583,14 @@ void MetaOverlineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
- maColor.Write( rOStm );
+ rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet );
}
void MetaOverlineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompat aCompat(rIStm, StreamMode::READ);
- maColor.Read( rIStm );
+ rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet );
}
diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx
index defa1b650888..71c7c5c7b26f 100644
--- a/vcl/source/gdi/svmconverter.cxx
+++ b/vcl/source/gdi/svmconverter.cxx
@@ -24,6 +24,7 @@
#include <tools/fract.hxx>
#include <tools/stream.hxx>
#include <tools/helpers.hxx>
+#include <tools/GenericTypeSerializer.hxx>
#include <vcl/dibtools.hxx>
#include <vcl/virdev.hxx>
#include <vcl/graph.hxx>
@@ -33,7 +34,6 @@
#include <osl/diagnose.h>
#include <svmconverter.hxx>
-
#include <memory>
// Inlines
@@ -1134,7 +1134,8 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
bool bSet;
sal_Int32 nFollowingActionCount(0);
- ReadColor( rIStm, aColor );
+ tools::GenericTypeSerializer aSerializer(rIStm);
+ aSerializer.readColor(aColor);
rIStm.ReadCharAsBool( bSet ).ReadInt32( nFollowingActionCount );
ImplSkipActions( rIStm, nFollowingActionCount );
rMtf.AddAction( new MetaTextLineColorAction( aColor, bSet ) );
diff --git a/vcl/source/gdi/wall.cxx b/vcl/source/gdi/wall.cxx
index 6c127b910944..fb0efd16ffa3 100644
--- a/vcl/source/gdi/wall.cxx
+++ b/vcl/source/gdi/wall.cxx
@@ -19,6 +19,7 @@
#include <tools/stream.hxx>
#include <tools/vcompat.hxx>
+#include <tools/GenericTypeSerializer.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/gradient.hxx>
#include <vcl/wall.hxx>
@@ -61,7 +62,8 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
rImplWallpaper.mpBitmap.reset();
// version 1
- ReadColor( rIStm, rImplWallpaper.maColor );
+ tools::GenericTypeSerializer aSerializer(rIStm);
+ aSerializer.readColor(rImplWallpaper.maColor);
sal_uInt16 nTmp16(0);
rIStm.ReadUInt16(nTmp16);
rImplWallpaper.meStyle = static_cast<WallpaperStyle>(nTmp16);
@@ -94,7 +96,7 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
// version 3 (new color format)
if( aCompat.GetVersion() >= 3 )
{
- rImplWallpaper.maColor.Read( rIStm );
+ rIStm.ReadUInt32(rImplWallpaper.maColor.mValue);
}
}
@@ -110,7 +112,9 @@ SvStream& WriteImplWallpaper( SvStream& rOStm, const ImplWallpaper& rImplWallpap
bool bDummy = false;
// version 1
- WriteColor( rOStm, rImplWallpaper.maColor );
+ tools::GenericTypeSerializer aSerializer(rOStm);
+ aSerializer.writeColor(rImplWallpaper.maColor);
+
rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplWallpaper.meStyle) );
// version 2
@@ -126,7 +130,7 @@ SvStream& WriteImplWallpaper( SvStream& rOStm, const ImplWallpaper& rImplWallpap
WriteDIBBitmapEx(*rImplWallpaper.mpBitmap, rOStm);
// version 3 (new color format)
- rImplWallpaper.maColor.Write( rOStm );
+ rOStm.WriteUInt32(rImplWallpaper.maColor.mValue);
return rOStm;
}