diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-04-27 11:18:42 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-04-27 06:48:18 +0200 |
commit | cae53cf14d59bc2fa6317c9493197804928d6e5e (patch) | |
tree | 4420d17bf2c9f1aa001c98c5c140ebd7ed04c30e /editeng/source | |
parent | 55e28737e973b40f72d398c9bb7a4a41307eb562 (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 'editeng/source')
-rw-r--r-- | editeng/source/items/legacyitem.cxx | 49 | ||||
-rw-r--r-- | editeng/source/items/numitem.cxx | 9 |
2 files changed, 40 insertions, 18 deletions
diff --git a/editeng/source/items/legacyitem.cxx b/editeng/source/items/legacyitem.cxx index 9a4acfafcead..f2997f715cc3 100644 --- a/editeng/source/items/legacyitem.cxx +++ b/editeng/source/items/legacyitem.cxx @@ -44,6 +44,8 @@ #include <editeng/formatbreakitem.hxx> #include <editeng/keepitem.hxx> #include <editeng/shaditem.hxx> +#include <tools/GenericTypeSerializer.hxx> + void Create_legacy_direct_set(SvxFontHeightItem& rItem, sal_uInt32 nH, sal_uInt16 nP, MapUnit eP) { @@ -273,16 +275,18 @@ namespace legacy void Create(SvxColorItem& rItem, SvStream& rStrm, sal_uInt16) { Color aColor(COL_AUTO); - ReadColor(rStrm, aColor); + tools::GenericTypeSerializer aSerializer(rStrm); + aSerializer.readColor(aColor); rItem.SetValue(aColor); } SvStream& Store(const SvxColorItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion) { + tools::GenericTypeSerializer aSerializer(rStrm); if( VERSION_USEAUTOCOLOR == nItemVersion && COL_AUTO == rItem.GetValue() ) - WriteColor( rStrm, COL_BLACK ); + aSerializer.writeColor(COL_BLACK); else - WriteColor( rStrm, rItem.GetValue() ); + aSerializer.writeColor(rItem.GetValue()); return rStrm; } } @@ -310,7 +314,9 @@ namespace legacy sal_uInt16 nOutline, nInline, nDistance; sal_uInt16 nStyle = css::table::BorderLineStyle::NONE; Color aColor; - ReadColor( stream, aColor ).ReadUInt16( nOutline ).ReadUInt16( nInline ).ReadUInt16( nDistance ); + tools::GenericTypeSerializer aSerializer(stream); + aSerializer.readColor(aColor); + stream.ReadUInt16( nOutline ).ReadUInt16( nInline ).ReadUInt16( nDistance ); if (version >= BORDER_LINE_WITH_STYLE_VERSION) stream.ReadUInt16( nStyle ); @@ -363,7 +369,9 @@ namespace legacy /// Store a border line to a stream. static SvStream& StoreBorderLine(SvStream &stream, const ::editeng::SvxBorderLine &l, sal_uInt16 version) { - WriteColor( stream, l.GetColor() ); + tools::GenericTypeSerializer aSerializer(stream); + aSerializer.writeColor(l.GetColor()); + stream.WriteUInt16( l.GetOutWidth() ) .WriteUInt16( l.GetInWidth() ) .WriteUInt16( l.GetDistance() ); @@ -432,7 +440,9 @@ namespace legacy short nOutline, nInline, nDistance; Color aColor; - ReadColor( rStrm, aColor ).ReadInt16( nOutline ).ReadInt16( nInline ).ReadInt16( nDistance ); + tools::GenericTypeSerializer aSerializer(rStrm); + aSerializer.readColor(aColor); + rStrm.ReadInt16( nOutline ).ReadInt16( nInline ).ReadInt16( nDistance ); if( nOutline ) { ::editeng::SvxBorderLine aLine( &aColor ); @@ -447,14 +457,16 @@ namespace legacy if(nullptr != pLine) { - WriteColor( rStrm, pLine->GetColor() ); + tools::GenericTypeSerializer aSerializer(rStrm); + aSerializer.writeColor(pLine->GetColor()); rStrm.WriteInt16( pLine->GetOutWidth() ) .WriteInt16( pLine->GetInWidth() ) .WriteInt16( pLine->GetDistance() ); } else { - WriteColor( rStrm, Color() ); + tools::GenericTypeSerializer aSerializer(rStrm); + aSerializer.writeColor(Color()); rStrm.WriteInt16( 0 ).WriteInt16( 0 ).WriteInt16( 0 ); } @@ -481,8 +493,9 @@ namespace legacy sal_Int8 nStyle; rStrm.ReadCharAsBool( bTrans ); - ReadColor( rStrm, aTempColor ); - ReadColor( rStrm, aTempFillColor ); + tools::GenericTypeSerializer aSerializer(rStrm); + aSerializer.readColor(aTempColor); + aSerializer.readColor(aTempFillColor); rStrm.ReadSChar( nStyle ); switch ( nStyle ) @@ -579,8 +592,9 @@ namespace legacy SvStream& Store(const SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16) { rStrm.WriteBool( false ); - WriteColor( rStrm, rItem.GetColor() ); - WriteColor( rStrm, rItem.GetColor() ); + tools::GenericTypeSerializer aSerializer(rStrm); + aSerializer.writeColor(rItem.GetColor()); + aSerializer.writeColor(rItem.GetColor()); rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID sal_uInt16 nDoLoad = 0; @@ -782,8 +796,10 @@ namespace legacy Color aFillColor; sal_Int8 nStyle; rStrm.ReadSChar( cLoc ).ReadUInt16( _nWidth ).ReadCharAsBool( bTrans ); - ReadColor( rStrm, aColor ); - ReadColor( rStrm, aFillColor ).ReadSChar( nStyle ); + tools::GenericTypeSerializer aSerializer(rStrm); + aSerializer.readColor(aColor); + aSerializer.readColor(aFillColor); + rStrm.ReadSChar(nStyle); aColor.SetTransparency(bTrans ? 0xff : 0); rItem.SetLocation(static_cast<SvxShadowLocation>(cLoc)); @@ -796,8 +812,9 @@ namespace legacy rStrm.WriteSChar( static_cast<sal_uInt8>(rItem.GetLocation()) ) .WriteUInt16( rItem.GetWidth() ) .WriteBool( rItem.GetColor().GetTransparency() > 0 ); - WriteColor( rStrm, rItem.GetColor() ); - WriteColor( rStrm, rItem.GetColor() ); + tools::GenericTypeSerializer aSerializer(rStrm); + aSerializer.writeColor(rItem.GetColor()); + aSerializer.writeColor(rItem.GetColor()); rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID return rStrm; } diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index 5a748f5a4414..b9d90c64f764 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -48,6 +48,7 @@ #include <tools/mapunit.hxx> #include <tools/stream.hxx> #include <tools/debug.hxx> +#include <tools/GenericTypeSerializer.hxx> #include <unotools/configmgr.hxx> #include <libxml/xmlwriter.h> #include <editeng/unonrule.hxx> @@ -234,7 +235,9 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream ) else pBulletFont = nullptr; ReadPair( rStream, aGraphicSize ); - ReadColor( rStream, nBulletColor ); + tools::GenericTypeSerializer aSerializer(rStream); + aSerializer.readColor(nBulletColor); + rStream.ReadUInt16( nBulletRelSize ); rStream.ReadUInt16( nTmp16 ); SetShowSymbol( nTmp16 != 0 ); @@ -309,7 +312,9 @@ void SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverte Color nTempColor = nBulletColor; if(COL_AUTO == nBulletColor) nTempColor = COL_BLACK; - WriteColor( rStream, nTempColor ); + + tools::GenericTypeSerializer aSerializer(rStream); + aSerializer.writeColor(nTempColor); rStream.WriteUInt16( nBulletRelSize ); rStream.WriteUInt16( sal_uInt16(IsShowSymbol()) ); |