[Libreoffice-commits] core.git: editeng/source include/tools sd/source tools/Library_tl.mk tools/qa tools/source vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Sat Apr 27 04:49:42 UTC 2019


 editeng/source/items/legacyitem.cxx           |   49 ++++++++----
 editeng/source/items/numitem.cxx              |    9 +-
 include/tools/GenericTypeSerializer.hxx       |   47 +++++++++++
 include/tools/color.hxx                       |    6 -
 sd/source/filter/html/pubdlg.cxx              |   24 +++--
 tools/Library_tl.mk                           |    1 
 tools/qa/cppunit/test_color.cxx               |   18 ----
 tools/source/generic/color.cxx                |   96 -----------------------
 tools/source/stream/GenericTypeSerializer.cxx |  105 ++++++++++++++++++++++++++
 vcl/source/gdi/dibtools.cxx                   |   13 +--
 vcl/source/gdi/gradient.cxx                   |   11 +-
 vcl/source/gdi/graphictools.cxx               |   20 ++--
 vcl/source/gdi/hatch.cxx                      |   21 +++--
 vcl/source/gdi/metaact.cxx                    |   32 +++----
 vcl/source/gdi/svmconverter.cxx               |    5 -
 vcl/source/gdi/wall.cxx                       |   12 +-
 16 files changed, 275 insertions(+), 194 deletions(-)

New commits:
commit cae53cf14d59bc2fa6317c9493197804928d6e5e
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Apr 27 11:18:42 2019 +0900
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Sat Apr 27 06:48:18 2019 +0200

    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 at gmail.com>

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()) );
 
diff --git a/include/tools/GenericTypeSerializer.hxx b/include/tools/GenericTypeSerializer.hxx
new file mode 100644
index 000000000000..90b5d002c8f1
--- /dev/null
+++ b/include/tools/GenericTypeSerializer.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef INCLUDED_TOOLS_GENERICTYPESERIALIZER_HXX
+#define INCLUDED_TOOLS_GENERICTYPESERIALIZER_HXX
+
+#include <sal/types.h>
+#include <tools/toolsdllapi.h>
+#include <tools/color.hxx>
+#include <tools/stream.hxx>
+
+namespace tools
+{
+class TOOLS_DLLPUBLIC GenericTypeSerializer
+{
+public:
+    SvStream& mrStream;
+
+    GenericTypeSerializer(SvStream& rStream)
+        : mrStream(rStream)
+    {
+    }
+
+    void readColor(Color& rColor);
+    void writeColor(const Color& rColor);
+};
+
+} // end namespace tools
+
+#endif // INCLUDED_TOOLS_GENERICTYPESERIALIZER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index 956b500ab752..4aea9a2d670e 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -171,12 +171,6 @@ public:
         return !(Color::operator==(rColor));
     }
 
-    SvStream& Read(SvStream& rIStream);
-    SvStream& Write(SvStream& rOStream) const;
-
-    TOOLS_DLLPUBLIC friend SvStream& ReadColor(SvStream& rIStream, Color& rColor);
-    TOOLS_DLLPUBLIC friend SvStream& WriteColor(SvStream& rOStream, const Color& rColor);
-
     // Return color as RGB hex string
     // for example "00ff00" for green color
     OUString AsRGBHexString() const;
diff --git a/sd/source/filter/html/pubdlg.cxx b/sd/source/filter/html/pubdlg.cxx
index 3cbc42135894..cdf1d10f00bd 100644
--- a/sd/source/filter/html/pubdlg.cxx
+++ b/sd/source/filter/html/pubdlg.cxx
@@ -30,6 +30,7 @@
 #include <svtools/colrdlg.hxx>
 #include <tools/debug.hxx>
 #include <tools/urlobj.hxx>
+#include <tools/GenericTypeSerializer.hxx>
 #include <sdiocmpt.hxx>
 #include <sfx2/docfile.hxx>
 #include <pres.hxx>
@@ -233,6 +234,7 @@ SvStream& operator >> (SvStream& rIn, SdPublishingDesign& rDesign)
     SdIOCompat aIO(rIn, StreamMode::READ);
 
     sal_uInt16 nTemp16;
+    tools::GenericTypeSerializer aSerializer(rIn);
 
     rDesign.m_aDesignName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rIn,
         RTL_TEXTENCODING_UTF8);
@@ -257,11 +259,11 @@ SvStream& operator >> (SvStream& rIn, SdPublishingDesign& rDesign)
     rIn.ReadCharAsBool( rDesign.m_bCreated );      // not used
     rIn.ReadInt16( rDesign.m_nButtonThema );
     rIn.ReadCharAsBool( rDesign.m_bUserAttr );
-    ReadColor( rIn, rDesign.m_aBackColor );
-    ReadColor( rIn, rDesign.m_aTextColor );
-    ReadColor( rIn, rDesign.m_aLinkColor );
-    ReadColor( rIn, rDesign.m_aVLinkColor );
-    ReadColor( rIn, rDesign.m_aALinkColor );
+    aSerializer.readColor(rDesign.m_aBackColor);
+    aSerializer.readColor(rDesign.m_aTextColor);
+    aSerializer.readColor(rDesign.m_aLinkColor);
+    aSerializer.readColor(rDesign.m_aVLinkColor);
+    aSerializer.readColor(rDesign.m_aALinkColor);
     rIn.ReadCharAsBool( rDesign.m_bUseAttribs );
     rIn.ReadCharAsBool( rDesign.m_bUseColor );
 
@@ -287,6 +289,8 @@ SvStream& WriteSdPublishingDesign(SvStream& rOut, const SdPublishingDesign& rDes
     // The last parameter is the versionnumber of the code
     SdIOCompat aIO(rOut, StreamMode::WRITE, 0);
 
+    tools::GenericTypeSerializer aSerializer(rOut);
+
     // Name
     write_uInt16_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aDesignName,
         RTL_TEXTENCODING_UTF8);
@@ -310,11 +314,11 @@ SvStream& WriteSdPublishingDesign(SvStream& rOut, const SdPublishingDesign& rDes
     rOut.WriteBool( rDesign.m_bCreated );     // not used
     rOut.WriteInt16( rDesign.m_nButtonThema );
     rOut.WriteBool( rDesign.m_bUserAttr );
-    WriteColor( rOut, rDesign.m_aBackColor );
-    WriteColor( rOut, rDesign.m_aTextColor );
-    WriteColor( rOut, rDesign.m_aLinkColor );
-    WriteColor( rOut, rDesign.m_aVLinkColor );
-    WriteColor( rOut, rDesign.m_aALinkColor );
+    aSerializer.writeColor(rDesign.m_aBackColor);
+    aSerializer.writeColor(rDesign.m_aTextColor);
+    aSerializer.writeColor(rDesign.m_aLinkColor);
+    aSerializer.writeColor(rDesign.m_aVLinkColor);
+    aSerializer.writeColor(rDesign.m_aALinkColor);
     rOut.WriteBool( rDesign.m_bUseAttribs );
     rOut.WriteBool( rDesign.m_bUseColor );
 
diff --git a/tools/Library_tl.mk b/tools/Library_tl.mk
index d6705d0b5925..9f3df2dc825f 100644
--- a/tools/Library_tl.mk
+++ b/tools/Library_tl.mk
@@ -73,6 +73,7 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
     tools/source/ref/ref \
     tools/source/stream/stream \
     tools/source/stream/vcompat \
+    tools/source/stream/GenericTypeSerializer \
     tools/source/string/tenccvt \
     tools/source/zcodec/zcodec \
     tools/source/xml/XmlWriter \
diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx
index 8ecf03572295..011fbcbdfa65 100644
--- a/tools/qa/cppunit/test_color.cxx
+++ b/tools/qa/cppunit/test_color.cxx
@@ -23,7 +23,6 @@ class Test: public CppUnit::TestFixture
 public:
     void testVariables();
     void test_asRGBColor();
-    void test_readAndWriteStream();
     void test_ApplyTintOrShade();
     void testGetColorError();
     void testInvert();
@@ -32,7 +31,6 @@ public:
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testVariables);
     CPPUNIT_TEST(test_asRGBColor);
-    CPPUNIT_TEST(test_readAndWriteStream);
     CPPUNIT_TEST(test_ApplyTintOrShade);
     CPPUNIT_TEST(testGetColorError);
     CPPUNIT_TEST(testInvert);
@@ -107,22 +105,6 @@ void Test::test_asRGBColor()
     CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aColor.AsRGBHexString());
 }
 
-void Test::test_readAndWriteStream()
-{
-    SvMemoryStream aStream;
-    Color aReadColor;
-
-    WriteColor(aStream, Color(0x12, 0x34, 0x56));
-
-    aStream.Seek(STREAM_SEEK_TO_BEGIN);
-
-    ReadColor(aStream, aReadColor);
-
-    CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x12), aReadColor.GetRed());
-    CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x34), aReadColor.GetGreen());
-    CPPUNIT_ASSERT_EQUAL(sal_uInt8(0x56), aReadColor.GetBlue());
-}
-
 OUString createTintShade(sal_uInt8 nR, sal_uInt8 nG, sal_uInt8 nB, OUString const & sReference, sal_Int16 nTintShade)
 {
     Color aColor(nR, nG, nB);
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index f79342d37862..a06c6e84a964 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -25,7 +25,6 @@
 #include <stdlib.h>
 
 #include <tools/color.hxx>
-#include <tools/stream.hxx>
 #include <tools/helpers.hxx>
 #include <basegfx/color/bcolortools.hxx>
 
@@ -184,18 +183,6 @@ Color Color::HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, sal_uInt16 nBri )
     return Color( cR, cG, cB );
 }
 
-SvStream& Color::Read( SvStream& rIStm )
-{
-    rIStm.ReadUInt32(mValue);
-    return rIStm;
-}
-
-SvStream& Color::Write( SvStream& rOStm ) const
-{
-    rOStm.WriteUInt32(mValue);
-    return rOStm;
-}
-
 OUString Color::AsRGBHexString() const
 {
     std::stringstream ss;
@@ -203,72 +190,6 @@ OUString Color::AsRGBHexString() const
     return OUString::createFromAscii(ss.str().c_str());
 }
 
-#define COL_NAME_USER       (sal_uInt16(0x8000))
-
-SvStream& ReadColor( SvStream& rIStream, Color& rColor )
-{
-    sal_uInt16 nColorName(0);
-
-    rIStream.ReadUInt16( nColorName );
-
-    if ( nColorName & COL_NAME_USER )
-    {
-        sal_uInt16 nRed;
-        sal_uInt16 nGreen;
-        sal_uInt16 nBlue;
-
-        rIStream.ReadUInt16( nRed );
-        rIStream.ReadUInt16( nGreen );
-        rIStream.ReadUInt16( nBlue );
-
-        rColor = Color( nRed>>8, nGreen>>8, nBlue>>8 );
-    }
-    else
-    {
-        static const Color aColAry[] =
-        {
-            COL_BLACK,                          // COL_BLACK
-            COL_BLUE,                           // COL_BLUE
-            COL_GREEN,                          // COL_GREEN
-            COL_CYAN,                           // COL_CYAN
-            COL_RED,                            // COL_RED
-            COL_MAGENTA,                        // COL_MAGENTA
-            COL_BROWN,                          // COL_BROWN
-            COL_GRAY,                           // COL_GRAY
-            COL_LIGHTGRAY,                      // COL_LIGHTGRAY
-            COL_LIGHTBLUE,                      // COL_LIGHTBLUE
-            COL_LIGHTGREEN,                     // COL_LIGHTGREEN
-            COL_LIGHTCYAN,                      // COL_LIGHTCYAN
-            COL_LIGHTRED,                       // COL_LIGHTRED
-            COL_LIGHTMAGENTA,                   // COL_LIGHTMAGENTA
-            COL_YELLOW,                         // COL_YELLOW
-            COL_WHITE,                          // COL_WHITE
-            COL_WHITE,                          // COL_MENUBAR
-            COL_BLACK,                          // COL_MENUBARTEXT
-            COL_WHITE,                          // COL_POPUPMENU
-            COL_BLACK,                          // COL_POPUPMENUTEXT
-            COL_BLACK,                          // COL_WINDOWTEXT
-            COL_WHITE,                          // COL_WINDOWWORKSPACE
-            COL_BLACK,                          // COL_HIGHLIGHT
-            COL_WHITE,                          // COL_HIGHLIGHTTEXT
-            COL_BLACK,                          // COL_3DTEXT
-            COL_LIGHTGRAY,                      // COL_3DFACE
-            COL_WHITE,                          // COL_3DLIGHT
-            COL_GRAY,                           // COL_3DSHADOW
-            COL_LIGHTGRAY,                      // COL_SCROLLBAR
-            COL_WHITE,                          // COL_FIELD
-            COL_BLACK                           // COL_FIELDTEXT
-        };
-
-        if ( nColorName < SAL_N_ELEMENTS( aColAry ) )
-            rColor = aColAry[nColorName];
-        else
-            rColor = COL_BLACK;
-    }
-
-    return rIStream;
-}
-
 void Color::ApplyTintOrShade(sal_Int16 n100thPercent)
 {
     if (n100thPercent == 0)
@@ -295,21 +216,4 @@ void Color::ApplyTintOrShade(sal_Int16 n100thPercent)
     B = sal_uInt8(std::lround(aBColor.getBlue()  * 255.0));
 }
 
-SvStream& WriteColor( SvStream& rOStream, const Color& rColor )
-{
-    sal_uInt16 nRed         = rColor.GetRed();
-    sal_uInt16 nGreen       = rColor.GetGreen();
-    sal_uInt16 nBlue        = rColor.GetBlue();
-    nRed    = (nRed<<8) + nRed;
-    nGreen  = (nGreen<<8) + nGreen;
-    nBlue   = (nBlue<<8) + nBlue;
-
-    rOStream.WriteUInt16( COL_NAME_USER );
-    rOStream.WriteUInt16( nRed );
-    rOStream.WriteUInt16( nGreen );
-    rOStream.WriteUInt16( nBlue );
-
-    return rOStream;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/tools/source/stream/GenericTypeSerializer.cxx b/tools/source/stream/GenericTypeSerializer.cxx
new file mode 100644
index 000000000000..7e261350ad50
--- /dev/null
+++ b/tools/source/stream/GenericTypeSerializer.cxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/config.h>
+
+#include <tools/GenericTypeSerializer.hxx>
+#include <vector>
+
+namespace tools
+{
+constexpr sal_uInt16 COL_NAME_USER = 0x8000;
+
+void GenericTypeSerializer::readColor(Color& rColor)
+{
+    sal_uInt16 nColorNameID(0);
+
+    mrStream.ReadUInt16(nColorNameID);
+
+    if (nColorNameID & COL_NAME_USER)
+    {
+        sal_uInt16 nRed;
+        sal_uInt16 nGreen;
+        sal_uInt16 nBlue;
+
+        mrStream.ReadUInt16(nRed);
+        mrStream.ReadUInt16(nGreen);
+        mrStream.ReadUInt16(nBlue);
+
+        rColor = Color(nRed >> 8, nGreen >> 8, nBlue >> 8);
+    }
+    else
+    {
+        static const std::vector<Color> staticColorArray = {
+            COL_BLACK, // COL_BLACK
+            COL_BLUE, // COL_BLUE
+            COL_GREEN, // COL_GREEN
+            COL_CYAN, // COL_CYAN
+            COL_RED, // COL_RED
+            COL_MAGENTA, // COL_MAGENTA
+            COL_BROWN, // COL_BROWN
+            COL_GRAY, // COL_GRAY
+            COL_LIGHTGRAY, // COL_LIGHTGRAY
+            COL_LIGHTBLUE, // COL_LIGHTBLUE
+            COL_LIGHTGREEN, // COL_LIGHTGREEN
+            COL_LIGHTCYAN, // COL_LIGHTCYAN
+            COL_LIGHTRED, // COL_LIGHTRED
+            COL_LIGHTMAGENTA, // COL_LIGHTMAGENTA
+            COL_YELLOW, // COL_YELLOW
+            COL_WHITE, // COL_WHITE
+            COL_WHITE, // COL_MENUBAR
+            COL_BLACK, // COL_MENUBARTEXT
+            COL_WHITE, // COL_POPUPMENU
+            COL_BLACK, // COL_POPUPMENUTEXT
+            COL_BLACK, // COL_WINDOWTEXT
+            COL_WHITE, // COL_WINDOWWORKSPACE
+            COL_BLACK, // COL_HIGHLIGHT
+            COL_WHITE, // COL_HIGHLIGHTTEXT
+            COL_BLACK, // COL_3DTEXT
+            COL_LIGHTGRAY, // COL_3DFACE
+            COL_WHITE, // COL_3DLIGHT
+            COL_GRAY, // COL_3DSHADOW
+            COL_LIGHTGRAY, // COL_SCROLLBAR
+            COL_WHITE, // COL_FIELD
+            COL_BLACK // COL_FIELDTEXT
+        };
+
+        if (nColorNameID < staticColorArray.size())
+            rColor = staticColorArray[nColorNameID];
+        else
+            rColor = COL_BLACK;
+    }
+}
+
+void GenericTypeSerializer::writeColor(const Color& rColor)
+{
+    mrStream.WriteUInt16(COL_NAME_USER);
+
+    sal_uInt16 nR = rColor.GetRed();
+    sal_uInt16 nG = rColor.GetGreen();
+    sal_uInt16 nB = rColor.GetBlue();
+
+    mrStream.WriteUInt16((nR << 8) + nR);
+    mrStream.WriteUInt16((nG << 8) + nG);
+    mrStream.WriteUInt16((nB << 8) + nB);
+}
+
+} // end namespace tools
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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;
 }


More information about the Libreoffice-commits mailing list