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>
This commit is contained in:
Tomaž Vajngerl
2019-04-27 11:18:42 +09:00
committed by Tomaž Vajngerl
parent 55e28737e9
commit cae53cf14d
16 changed files with 275 additions and 194 deletions

View File

@@ -44,6 +44,8 @@
#include <editeng/formatbreakitem.hxx> #include <editeng/formatbreakitem.hxx>
#include <editeng/keepitem.hxx> #include <editeng/keepitem.hxx>
#include <editeng/shaditem.hxx> #include <editeng/shaditem.hxx>
#include <tools/GenericTypeSerializer.hxx>
void Create_legacy_direct_set(SvxFontHeightItem& rItem, sal_uInt32 nH, sal_uInt16 nP, MapUnit eP) 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) void Create(SvxColorItem& rItem, SvStream& rStrm, sal_uInt16)
{ {
Color aColor(COL_AUTO); Color aColor(COL_AUTO);
ReadColor(rStrm, aColor); tools::GenericTypeSerializer aSerializer(rStrm);
aSerializer.readColor(aColor);
rItem.SetValue(aColor); rItem.SetValue(aColor);
} }
SvStream& Store(const SvxColorItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion) SvStream& Store(const SvxColorItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
{ {
tools::GenericTypeSerializer aSerializer(rStrm);
if( VERSION_USEAUTOCOLOR == nItemVersion && COL_AUTO == rItem.GetValue() ) if( VERSION_USEAUTOCOLOR == nItemVersion && COL_AUTO == rItem.GetValue() )
WriteColor( rStrm, COL_BLACK ); aSerializer.writeColor(COL_BLACK);
else else
WriteColor( rStrm, rItem.GetValue() ); aSerializer.writeColor(rItem.GetValue());
return rStrm; return rStrm;
} }
} }
@@ -310,7 +314,9 @@ namespace legacy
sal_uInt16 nOutline, nInline, nDistance; sal_uInt16 nOutline, nInline, nDistance;
sal_uInt16 nStyle = css::table::BorderLineStyle::NONE; sal_uInt16 nStyle = css::table::BorderLineStyle::NONE;
Color aColor; 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) if (version >= BORDER_LINE_WITH_STYLE_VERSION)
stream.ReadUInt16( nStyle ); stream.ReadUInt16( nStyle );
@@ -363,7 +369,9 @@ namespace legacy
/// Store a border line to a stream. /// Store a border line to a stream.
static SvStream& StoreBorderLine(SvStream &stream, const ::editeng::SvxBorderLine &l, sal_uInt16 version) 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() ) stream.WriteUInt16( l.GetOutWidth() )
.WriteUInt16( l.GetInWidth() ) .WriteUInt16( l.GetInWidth() )
.WriteUInt16( l.GetDistance() ); .WriteUInt16( l.GetDistance() );
@@ -432,7 +440,9 @@ namespace legacy
short nOutline, nInline, nDistance; short nOutline, nInline, nDistance;
Color aColor; 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 ) if( nOutline )
{ {
::editeng::SvxBorderLine aLine( &aColor ); ::editeng::SvxBorderLine aLine( &aColor );
@@ -447,14 +457,16 @@ namespace legacy
if(nullptr != pLine) if(nullptr != pLine)
{ {
WriteColor( rStrm, pLine->GetColor() ); tools::GenericTypeSerializer aSerializer(rStrm);
aSerializer.writeColor(pLine->GetColor());
rStrm.WriteInt16( pLine->GetOutWidth() ) rStrm.WriteInt16( pLine->GetOutWidth() )
.WriteInt16( pLine->GetInWidth() ) .WriteInt16( pLine->GetInWidth() )
.WriteInt16( pLine->GetDistance() ); .WriteInt16( pLine->GetDistance() );
} }
else else
{ {
WriteColor( rStrm, Color() ); tools::GenericTypeSerializer aSerializer(rStrm);
aSerializer.writeColor(Color());
rStrm.WriteInt16( 0 ).WriteInt16( 0 ).WriteInt16( 0 ); rStrm.WriteInt16( 0 ).WriteInt16( 0 ).WriteInt16( 0 );
} }
@@ -481,8 +493,9 @@ namespace legacy
sal_Int8 nStyle; sal_Int8 nStyle;
rStrm.ReadCharAsBool( bTrans ); rStrm.ReadCharAsBool( bTrans );
ReadColor( rStrm, aTempColor ); tools::GenericTypeSerializer aSerializer(rStrm);
ReadColor( rStrm, aTempFillColor ); aSerializer.readColor(aTempColor);
aSerializer.readColor(aTempFillColor);
rStrm.ReadSChar( nStyle ); rStrm.ReadSChar( nStyle );
switch ( nStyle ) switch ( nStyle )
@@ -579,8 +592,9 @@ namespace legacy
SvStream& Store(const SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16) SvStream& Store(const SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16)
{ {
rStrm.WriteBool( false ); rStrm.WriteBool( false );
WriteColor( rStrm, rItem.GetColor() ); tools::GenericTypeSerializer aSerializer(rStrm);
WriteColor( rStrm, rItem.GetColor() ); aSerializer.writeColor(rItem.GetColor());
aSerializer.writeColor(rItem.GetColor());
rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID
sal_uInt16 nDoLoad = 0; sal_uInt16 nDoLoad = 0;
@@ -782,8 +796,10 @@ namespace legacy
Color aFillColor; Color aFillColor;
sal_Int8 nStyle; sal_Int8 nStyle;
rStrm.ReadSChar( cLoc ).ReadUInt16( _nWidth ).ReadCharAsBool( bTrans ); rStrm.ReadSChar( cLoc ).ReadUInt16( _nWidth ).ReadCharAsBool( bTrans );
ReadColor( rStrm, aColor ); tools::GenericTypeSerializer aSerializer(rStrm);
ReadColor( rStrm, aFillColor ).ReadSChar( nStyle ); aSerializer.readColor(aColor);
aSerializer.readColor(aFillColor);
rStrm.ReadSChar(nStyle);
aColor.SetTransparency(bTrans ? 0xff : 0); aColor.SetTransparency(bTrans ? 0xff : 0);
rItem.SetLocation(static_cast<SvxShadowLocation>(cLoc)); rItem.SetLocation(static_cast<SvxShadowLocation>(cLoc));
@@ -796,8 +812,9 @@ namespace legacy
rStrm.WriteSChar( static_cast<sal_uInt8>(rItem.GetLocation()) ) rStrm.WriteSChar( static_cast<sal_uInt8>(rItem.GetLocation()) )
.WriteUInt16( rItem.GetWidth() ) .WriteUInt16( rItem.GetWidth() )
.WriteBool( rItem.GetColor().GetTransparency() > 0 ); .WriteBool( rItem.GetColor().GetTransparency() > 0 );
WriteColor( rStrm, rItem.GetColor() ); tools::GenericTypeSerializer aSerializer(rStrm);
WriteColor( rStrm, rItem.GetColor() ); aSerializer.writeColor(rItem.GetColor());
aSerializer.writeColor(rItem.GetColor());
rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID
return rStrm; return rStrm;
} }

View File

@@ -48,6 +48,7 @@
#include <tools/mapunit.hxx> #include <tools/mapunit.hxx>
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <tools/GenericTypeSerializer.hxx>
#include <unotools/configmgr.hxx> #include <unotools/configmgr.hxx>
#include <libxml/xmlwriter.h> #include <libxml/xmlwriter.h>
#include <editeng/unonrule.hxx> #include <editeng/unonrule.hxx>
@@ -234,7 +235,9 @@ SvxNumberFormat::SvxNumberFormat( SvStream &rStream )
else pBulletFont = nullptr; else pBulletFont = nullptr;
ReadPair( rStream, aGraphicSize ); ReadPair( rStream, aGraphicSize );
ReadColor( rStream, nBulletColor ); tools::GenericTypeSerializer aSerializer(rStream);
aSerializer.readColor(nBulletColor);
rStream.ReadUInt16( nBulletRelSize ); rStream.ReadUInt16( nBulletRelSize );
rStream.ReadUInt16( nTmp16 ); SetShowSymbol( nTmp16 != 0 ); rStream.ReadUInt16( nTmp16 ); SetShowSymbol( nTmp16 != 0 );
@@ -309,7 +312,9 @@ void SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverte
Color nTempColor = nBulletColor; Color nTempColor = nBulletColor;
if(COL_AUTO == nBulletColor) if(COL_AUTO == nBulletColor)
nTempColor = COL_BLACK; nTempColor = COL_BLACK;
WriteColor( rStream, nTempColor );
tools::GenericTypeSerializer aSerializer(rStream);
aSerializer.writeColor(nTempColor);
rStream.WriteUInt16( nBulletRelSize ); rStream.WriteUInt16( nBulletRelSize );
rStream.WriteUInt16( sal_uInt16(IsShowSymbol()) ); rStream.WriteUInt16( sal_uInt16(IsShowSymbol()) );

View File

@@ -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: */

View File

@@ -171,12 +171,6 @@ public:
return !(Color::operator==(rColor)); 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 // Return color as RGB hex string
// for example "00ff00" for green color // for example "00ff00" for green color
OUString AsRGBHexString() const; OUString AsRGBHexString() const;

View File

@@ -30,6 +30,7 @@
#include <svtools/colrdlg.hxx> #include <svtools/colrdlg.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
#include <tools/GenericTypeSerializer.hxx>
#include <sdiocmpt.hxx> #include <sdiocmpt.hxx>
#include <sfx2/docfile.hxx> #include <sfx2/docfile.hxx>
#include <pres.hxx> #include <pres.hxx>
@@ -233,6 +234,7 @@ SvStream& operator >> (SvStream& rIn, SdPublishingDesign& rDesign)
SdIOCompat aIO(rIn, StreamMode::READ); SdIOCompat aIO(rIn, StreamMode::READ);
sal_uInt16 nTemp16; sal_uInt16 nTemp16;
tools::GenericTypeSerializer aSerializer(rIn);
rDesign.m_aDesignName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rIn, rDesign.m_aDesignName = read_uInt16_lenPrefixed_uInt8s_ToOUString(rIn,
RTL_TEXTENCODING_UTF8); RTL_TEXTENCODING_UTF8);
@@ -257,11 +259,11 @@ SvStream& operator >> (SvStream& rIn, SdPublishingDesign& rDesign)
rIn.ReadCharAsBool( rDesign.m_bCreated ); // not used rIn.ReadCharAsBool( rDesign.m_bCreated ); // not used
rIn.ReadInt16( rDesign.m_nButtonThema ); rIn.ReadInt16( rDesign.m_nButtonThema );
rIn.ReadCharAsBool( rDesign.m_bUserAttr ); rIn.ReadCharAsBool( rDesign.m_bUserAttr );
ReadColor( rIn, rDesign.m_aBackColor ); aSerializer.readColor(rDesign.m_aBackColor);
ReadColor( rIn, rDesign.m_aTextColor ); aSerializer.readColor(rDesign.m_aTextColor);
ReadColor( rIn, rDesign.m_aLinkColor ); aSerializer.readColor(rDesign.m_aLinkColor);
ReadColor( rIn, rDesign.m_aVLinkColor ); aSerializer.readColor(rDesign.m_aVLinkColor);
ReadColor( rIn, rDesign.m_aALinkColor ); aSerializer.readColor(rDesign.m_aALinkColor);
rIn.ReadCharAsBool( rDesign.m_bUseAttribs ); rIn.ReadCharAsBool( rDesign.m_bUseAttribs );
rIn.ReadCharAsBool( rDesign.m_bUseColor ); 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 // The last parameter is the versionnumber of the code
SdIOCompat aIO(rOut, StreamMode::WRITE, 0); SdIOCompat aIO(rOut, StreamMode::WRITE, 0);
tools::GenericTypeSerializer aSerializer(rOut);
// Name // Name
write_uInt16_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aDesignName, write_uInt16_lenPrefixed_uInt8s_FromOUString(rOut, rDesign.m_aDesignName,
RTL_TEXTENCODING_UTF8); RTL_TEXTENCODING_UTF8);
@@ -310,11 +314,11 @@ SvStream& WriteSdPublishingDesign(SvStream& rOut, const SdPublishingDesign& rDes
rOut.WriteBool( rDesign.m_bCreated ); // not used rOut.WriteBool( rDesign.m_bCreated ); // not used
rOut.WriteInt16( rDesign.m_nButtonThema ); rOut.WriteInt16( rDesign.m_nButtonThema );
rOut.WriteBool( rDesign.m_bUserAttr ); rOut.WriteBool( rDesign.m_bUserAttr );
WriteColor( rOut, rDesign.m_aBackColor ); aSerializer.writeColor(rDesign.m_aBackColor);
WriteColor( rOut, rDesign.m_aTextColor ); aSerializer.writeColor(rDesign.m_aTextColor);
WriteColor( rOut, rDesign.m_aLinkColor ); aSerializer.writeColor(rDesign.m_aLinkColor);
WriteColor( rOut, rDesign.m_aVLinkColor ); aSerializer.writeColor(rDesign.m_aVLinkColor);
WriteColor( rOut, rDesign.m_aALinkColor ); aSerializer.writeColor(rDesign.m_aALinkColor);
rOut.WriteBool( rDesign.m_bUseAttribs ); rOut.WriteBool( rDesign.m_bUseAttribs );
rOut.WriteBool( rDesign.m_bUseColor ); rOut.WriteBool( rDesign.m_bUseColor );

View File

@@ -73,6 +73,7 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
tools/source/ref/ref \ tools/source/ref/ref \
tools/source/stream/stream \ tools/source/stream/stream \
tools/source/stream/vcompat \ tools/source/stream/vcompat \
tools/source/stream/GenericTypeSerializer \
tools/source/string/tenccvt \ tools/source/string/tenccvt \
tools/source/zcodec/zcodec \ tools/source/zcodec/zcodec \
tools/source/xml/XmlWriter \ tools/source/xml/XmlWriter \

View File

@@ -23,7 +23,6 @@ class Test: public CppUnit::TestFixture
public: public:
void testVariables(); void testVariables();
void test_asRGBColor(); void test_asRGBColor();
void test_readAndWriteStream();
void test_ApplyTintOrShade(); void test_ApplyTintOrShade();
void testGetColorError(); void testGetColorError();
void testInvert(); void testInvert();
@@ -32,7 +31,6 @@ public:
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testVariables); CPPUNIT_TEST(testVariables);
CPPUNIT_TEST(test_asRGBColor); CPPUNIT_TEST(test_asRGBColor);
CPPUNIT_TEST(test_readAndWriteStream);
CPPUNIT_TEST(test_ApplyTintOrShade); CPPUNIT_TEST(test_ApplyTintOrShade);
CPPUNIT_TEST(testGetColorError); CPPUNIT_TEST(testGetColorError);
CPPUNIT_TEST(testInvert); CPPUNIT_TEST(testInvert);
@@ -107,22 +105,6 @@ void Test::test_asRGBColor()
CPPUNIT_ASSERT_EQUAL(OUString("ffffff"), aColor.AsRGBHexString()); 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) OUString createTintShade(sal_uInt8 nR, sal_uInt8 nG, sal_uInt8 nB, OUString const & sReference, sal_Int16 nTintShade)
{ {
Color aColor(nR, nG, nB); Color aColor(nR, nG, nB);

View File

@@ -25,7 +25,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <tools/color.hxx> #include <tools/color.hxx>
#include <tools/stream.hxx>
#include <tools/helpers.hxx> #include <tools/helpers.hxx>
#include <basegfx/color/bcolortools.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 ); 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 OUString Color::AsRGBHexString() const
{ {
std::stringstream ss; std::stringstream ss;
@@ -203,72 +190,6 @@ OUString Color::AsRGBHexString() const
return OUString::createFromAscii(ss.str().c_str()); 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) void Color::ApplyTintOrShade(sal_Int16 n100thPercent)
{ {
if (n100thPercent == 0) if (n100thPercent == 0)
@@ -295,21 +216,4 @@ void Color::ApplyTintOrShade(sal_Int16 n100thPercent)
B = sal_uInt8(std::lround(aBColor.getBlue() * 255.0)); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -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: */

View File

@@ -28,6 +28,7 @@
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/fract.hxx> #include <tools/fract.hxx>
#include <tools/helpers.hxx> #include <tools/helpers.hxx>
#include <tools/GenericTypeSerializer.hxx>
#include <unotools/configmgr.hxx> #include <unotools/configmgr.hxx>
#include <vcl/bitmapex.hxx> #include <vcl/bitmapex.hxx>
#include <vcl/bitmapaccess.hxx> #include <vcl/bitmapaccess.hxx>
@@ -35,7 +36,6 @@
#include <bitmapwriteaccess.hxx> #include <bitmapwriteaccess.hxx>
#include <memory> #include <memory>
#define DIBCOREHEADERSIZE ( 12UL ) #define DIBCOREHEADERSIZE ( 12UL )
#define DIBINFOHEADERSIZE ( sizeof(DIBInfoHeader) ) #define DIBINFOHEADERSIZE ( sizeof(DIBInfoHeader) )
#define DIBV5HEADERSIZE ( sizeof(DIBV5Header) ) #define DIBV5HEADERSIZE ( sizeof(DIBV5Header) )
@@ -1800,14 +1800,16 @@ bool ReadDIBBitmapEx(
} }
case TransparentType::Color: case TransparentType::Color:
{ {
Color maTransparentColor; Color aTransparentColor;
tools::GenericTypeSerializer aSerializer(rIStm);
aSerializer.readColor(aTransparentColor);
ReadColor( rIStm, maTransparentColor );
bRetval = !rIStm.GetError(); bRetval = !rIStm.GetError();
if(bRetval) if(bRetval)
{ {
rTarget = BitmapEx(aBmp, maTransparentColor); rTarget = BitmapEx(aBmp, aTransparentColor);
} }
break; break;
} }
@@ -1885,7 +1887,8 @@ bool WriteDIBBitmapEx(
} }
else if(TransparentType::Color == rSource.meTransparent) else if(TransparentType::Color == rSource.meTransparent)
{ {
WriteColor( rOStm, rSource.maTransparentColor ); tools::GenericTypeSerializer aSerializer(rOStm);
aSerializer.writeColor(rSource.maTransparentColor);
return true; return true;
} }
} }

View File

@@ -20,6 +20,7 @@
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/vcompat.hxx> #include <tools/vcompat.hxx>
#include <tools/gen.hxx> #include <tools/gen.hxx>
#include <tools/GenericTypeSerializer.hxx>
#include <vcl/gradient.hxx> #include <vcl/gradient.hxx>
Impl_Gradient::Impl_Gradient() : Impl_Gradient::Impl_Gradient() :
@@ -225,8 +226,9 @@ SvStream& ReadGradient( SvStream& rIStm, Gradient& rGradient )
rIStm.ReadUInt16( nTmp16 ); rGradient.mpImplGradient->meStyle = static_cast<GradientStyle>(nTmp16); rIStm.ReadUInt16( nTmp16 ); rGradient.mpImplGradient->meStyle = static_cast<GradientStyle>(nTmp16);
ReadColor( rIStm, rGradient.mpImplGradient->maStartColor ); tools::GenericTypeSerializer aSerializer(rIStm);
ReadColor( rIStm, rGradient.mpImplGradient->maEndColor ); aSerializer.readColor(rGradient.mpImplGradient->maStartColor);
aSerializer.readColor(rGradient.mpImplGradient->maEndColor);
rIStm.ReadUInt16( rGradient.mpImplGradient->mnAngle ) rIStm.ReadUInt16( rGradient.mpImplGradient->mnAngle )
.ReadUInt16( rGradient.mpImplGradient->mnBorder ) .ReadUInt16( rGradient.mpImplGradient->mnBorder )
.ReadUInt16( rGradient.mpImplGradient->mnOfsX ) .ReadUInt16( rGradient.mpImplGradient->mnOfsX )
@@ -243,8 +245,9 @@ SvStream& WriteGradient( SvStream& rOStm, const Gradient& rGradient )
VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 ); VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
rOStm.WriteUInt16( static_cast<sal_uInt16>(rGradient.mpImplGradient->meStyle) ); rOStm.WriteUInt16( static_cast<sal_uInt16>(rGradient.mpImplGradient->meStyle) );
WriteColor( rOStm, rGradient.mpImplGradient->maStartColor ); tools::GenericTypeSerializer aSerializer(rOStm);
WriteColor( rOStm, rGradient.mpImplGradient->maEndColor ); aSerializer.writeColor(rGradient.mpImplGradient->maStartColor);
aSerializer.writeColor(rGradient.mpImplGradient->maEndColor);
rOStm.WriteUInt16( rGradient.mpImplGradient->mnAngle ) rOStm.WriteUInt16( rGradient.mpImplGradient->mnAngle )
.WriteUInt16( rGradient.mpImplGradient->mnBorder ) .WriteUInt16( rGradient.mpImplGradient->mnBorder )
.WriteUInt16( rGradient.mpImplGradient->mnOfsX ) .WriteUInt16( rGradient.mpImplGradient->mnOfsX )

View File

@@ -19,6 +19,7 @@
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/vcompat.hxx> #include <tools/vcompat.hxx>
#include <tools/GenericTypeSerializer.hxx>
#include <vcl/graphictools.hxx> #include <vcl/graphictools.hxx>
@@ -236,7 +237,8 @@ SvStream& WriteSvtGraphicFill( SvStream& rOStm, const SvtGraphicFill& rClass )
VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 ); VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
rClass.maPath.Write( rOStm ); rClass.maPath.Write( rOStm );
WriteColor( rOStm, rClass.maFillColor ); tools::GenericTypeSerializer aSerializer(rOStm);
aSerializer.writeColor(rClass.maFillColor);
rOStm.WriteDouble( rClass.mfTransparency ); rOStm.WriteDouble( rClass.mfTransparency );
sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillRule ); sal_uInt16 nTmp = sal::static_int_cast<sal_uInt16>( rClass.maFillRule );
rOStm.WriteUInt16( nTmp ); rOStm.WriteUInt16( nTmp );
@@ -249,11 +251,11 @@ SvStream& WriteSvtGraphicFill( SvStream& rOStm, const SvtGraphicFill& rClass )
rOStm.WriteUInt16( nTmp ); rOStm.WriteUInt16( nTmp );
nTmp = sal::static_int_cast<sal_uInt16>( rClass.maHatchType ); nTmp = sal::static_int_cast<sal_uInt16>( rClass.maHatchType );
rOStm.WriteUInt16( nTmp ); rOStm.WriteUInt16( nTmp );
WriteColor( rOStm, rClass.maHatchColor ); aSerializer.writeColor(rClass.maHatchColor);
nTmp = sal::static_int_cast<sal_uInt16>( rClass.maGradientType ); nTmp = sal::static_int_cast<sal_uInt16>( rClass.maGradientType );
rOStm.WriteUInt16( nTmp ); rOStm.WriteUInt16( nTmp );
WriteColor( rOStm, rClass.maGradient1stColor ); aSerializer.writeColor(rClass.maGradient1stColor);
WriteColor( rOStm, rClass.maGradient2ndColor ); aSerializer.writeColor(rClass.maGradient2ndColor);
rOStm.WriteInt32( rClass.maGradientStepCount ); rOStm.WriteInt32( rClass.maGradientStepCount );
WriteGraphic( rOStm, rClass.maFillGraphic ); WriteGraphic( rOStm, rClass.maFillGraphic );
@@ -265,7 +267,9 @@ SvStream& ReadSvtGraphicFill( SvStream& rIStm, SvtGraphicFill& rClass )
VersionCompat aCompat( rIStm, StreamMode::READ ); VersionCompat aCompat( rIStm, StreamMode::READ );
rClass.maPath.Read( rIStm ); rClass.maPath.Read( rIStm );
ReadColor( rIStm, rClass.maFillColor );
tools::GenericTypeSerializer aSerializer(rIStm);
aSerializer.readColor(rClass.maFillColor);
rIStm.ReadDouble( rClass.mfTransparency ); rIStm.ReadDouble( rClass.mfTransparency );
sal_uInt16 nTmp; sal_uInt16 nTmp;
rIStm.ReadUInt16( nTmp ); rIStm.ReadUInt16( nTmp );
@@ -278,11 +282,11 @@ SvStream& ReadSvtGraphicFill( SvStream& rIStm, SvtGraphicFill& rClass )
rClass.mbTiling = nTmp; rClass.mbTiling = nTmp;
rIStm.ReadUInt16( nTmp ); rIStm.ReadUInt16( nTmp );
rClass.maHatchType = SvtGraphicFill::HatchType( nTmp ); rClass.maHatchType = SvtGraphicFill::HatchType( nTmp );
ReadColor( rIStm, rClass.maHatchColor ); aSerializer.readColor(rClass.maHatchColor);
rIStm.ReadUInt16( nTmp ); rIStm.ReadUInt16( nTmp );
rClass.maGradientType = SvtGraphicFill::GradientType( nTmp ); rClass.maGradientType = SvtGraphicFill::GradientType( nTmp );
ReadColor( rIStm, rClass.maGradient1stColor ); aSerializer.readColor(rClass.maGradient1stColor);
ReadColor( rIStm, rClass.maGradient2ndColor ); aSerializer.readColor(rClass.maGradient2ndColor);
rIStm.ReadInt32( rClass.maGradientStepCount ); rIStm.ReadInt32( rClass.maGradientStepCount );
ReadGraphic( rIStm, rClass.maFillGraphic ); ReadGraphic( rIStm, rClass.maFillGraphic );

View File

@@ -19,6 +19,7 @@
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/vcompat.hxx> #include <tools/vcompat.hxx>
#include <tools/GenericTypeSerializer.hxx>
#include <vcl/hatch.hxx> #include <vcl/hatch.hxx>
ImplHatch::ImplHatch() : ImplHatch::ImplHatch() :
@@ -77,13 +78,17 @@ void Hatch::SetAngle( sal_uInt16 nAngle10 )
SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch ) SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch )
{ {
VersionCompat aCompat( rIStm, StreamMode::READ ); VersionCompat aCompat(rIStm, StreamMode::READ);
sal_uInt16 nTmp16; sal_uInt16 nTmp16;
sal_Int32 nTmp32(0); sal_Int32 nTmp32(0);
rIStm.ReadUInt16( nTmp16 ); rHatch.mpImplHatch->meStyle = static_cast<HatchStyle>(nTmp16); rIStm.ReadUInt16(nTmp16);
ReadColor( rIStm, rHatch.mpImplHatch->maColor ).ReadInt32( nTmp32 ).ReadUInt16( rHatch.mpImplHatch->meStyle = static_cast<HatchStyle>(nTmp16);
rHatch.mpImplHatch->mnAngle );
tools::GenericTypeSerializer aSerializer(rIStm);
aSerializer.readColor(rHatch.mpImplHatch->maColor);
rIStm.ReadInt32(nTmp32);
rIStm.ReadUInt16(rHatch.mpImplHatch->mnAngle);
rHatch.mpImplHatch->mnDistance = nTmp32; rHatch.mpImplHatch->mnDistance = nTmp32;
return rIStm; return rIStm;
@@ -94,7 +99,9 @@ SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch )
VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 ); VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
rOStm.WriteUInt16( static_cast<sal_uInt16>(rHatch.mpImplHatch->meStyle) ); 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 ); rOStm.WriteInt32( rHatch.mpImplHatch->mnDistance ).WriteUInt16( rHatch.mpImplHatch->mnAngle );
return rOStm; return rOStm;

View File

@@ -310,14 +310,14 @@ void MetaPixelAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
MetaAction::Write(rOStm, pData); MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
WritePair( rOStm, maPt ); WritePair( rOStm, maPt );
maColor.Write( rOStm ); rOStm.WriteUInt32(maColor.mValue);
} }
void MetaPixelAction::Read( SvStream& rIStm, ImplMetaReadData* ) void MetaPixelAction::Read( SvStream& rIStm, ImplMetaReadData* )
{ {
VersionCompat aCompat(rIStm, StreamMode::READ); VersionCompat aCompat(rIStm, StreamMode::READ);
ReadPair( rIStm, maPt ); ReadPair( rIStm, maPt );
maColor.Read( rIStm); rIStm.ReadUInt32(maColor.mValue);
} }
MetaPointAction::MetaPointAction() : MetaPointAction::MetaPointAction() :
@@ -1932,7 +1932,7 @@ void MetaMaskScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
MetaAction::Write(rOStm, pData); MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
WriteDIB(maBmp, rOStm, false, true); WriteDIB(maBmp, rOStm, false, true);
maColor.Write( rOStm ); rOStm.WriteUInt32(maColor.mValue);
WritePair( rOStm, maDstPt ); WritePair( rOStm, maDstPt );
WritePair( rOStm, maDstSz ); WritePair( rOStm, maDstSz );
WritePair( rOStm, maSrcPt ); WritePair( rOStm, maSrcPt );
@@ -1944,7 +1944,7 @@ void MetaMaskScalePartAction::Read( SvStream& rIStm, ImplMetaReadData* )
{ {
VersionCompat aCompat(rIStm, StreamMode::READ); VersionCompat aCompat(rIStm, StreamMode::READ);
ReadDIB(maBmp, rIStm, true); ReadDIB(maBmp, rIStm, true);
maColor.Read( rIStm ); rIStm.ReadUInt32(maColor.mValue);
ReadPair( rIStm, maDstPt ); ReadPair( rIStm, maDstPt );
ReadPair( rIStm, maDstSz ); ReadPair( rIStm, maDstSz );
ReadPair( rIStm, maSrcPt ); ReadPair( rIStm, maSrcPt );
@@ -2380,14 +2380,14 @@ void MetaLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{ {
MetaAction::Write(rOStm, pData); MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
maColor.Write( rOStm ); rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet ); rOStm.WriteBool( mbSet );
} }
void MetaLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* ) void MetaLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{ {
VersionCompat aCompat(rIStm, StreamMode::READ); VersionCompat aCompat(rIStm, StreamMode::READ);
maColor.Read( rIStm ); rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet ); rIStm.ReadCharAsBool( mbSet );
} }
@@ -2422,14 +2422,14 @@ void MetaFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{ {
MetaAction::Write(rOStm, pData); MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
maColor.Write( rOStm ); rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet ); rOStm.WriteBool( mbSet );
} }
void MetaFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* ) void MetaFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{ {
VersionCompat aCompat(rIStm, StreamMode::READ); VersionCompat aCompat(rIStm, StreamMode::READ);
maColor.Read( rIStm ); rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet ); rIStm.ReadCharAsBool( mbSet );
} }
@@ -2459,13 +2459,13 @@ void MetaTextColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{ {
MetaAction::Write(rOStm, pData); MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
maColor.Write( rOStm ); rOStm.WriteUInt32(maColor.mValue);
} }
void MetaTextColorAction::Read( SvStream& rIStm, ImplMetaReadData* ) void MetaTextColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{ {
VersionCompat aCompat(rIStm, StreamMode::READ); VersionCompat aCompat(rIStm, StreamMode::READ);
maColor.Read( rIStm ); rIStm.ReadUInt32(maColor.mValue);
} }
MetaTextFillColorAction::MetaTextFillColorAction() : MetaTextFillColorAction::MetaTextFillColorAction() :
@@ -2499,14 +2499,14 @@ void MetaTextFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{ {
MetaAction::Write(rOStm, pData); MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
maColor.Write( rOStm ); rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet ); rOStm.WriteBool( mbSet );
} }
void MetaTextFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* ) void MetaTextFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{ {
VersionCompat aCompat(rIStm, StreamMode::READ); VersionCompat aCompat(rIStm, StreamMode::READ);
maColor.Read( rIStm ); rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet ); rIStm.ReadCharAsBool( mbSet );
} }
@@ -2541,14 +2541,14 @@ void MetaTextLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{ {
MetaAction::Write(rOStm, pData); MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
maColor.Write( rOStm ); rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet ); rOStm.WriteBool( mbSet );
} }
void MetaTextLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* ) void MetaTextLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{ {
VersionCompat aCompat(rIStm, StreamMode::READ); VersionCompat aCompat(rIStm, StreamMode::READ);
maColor.Read( rIStm ); rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet ); rIStm.ReadCharAsBool( mbSet );
} }
@@ -2583,14 +2583,14 @@ void MetaOverlineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{ {
MetaAction::Write(rOStm, pData); MetaAction::Write(rOStm, pData);
VersionCompat aCompat(rOStm, StreamMode::WRITE, 1); VersionCompat aCompat(rOStm, StreamMode::WRITE, 1);
maColor.Write( rOStm ); rOStm.WriteUInt32(maColor.mValue);
rOStm.WriteBool( mbSet ); rOStm.WriteBool( mbSet );
} }
void MetaOverlineColorAction::Read( SvStream& rIStm, ImplMetaReadData* ) void MetaOverlineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{ {
VersionCompat aCompat(rIStm, StreamMode::READ); VersionCompat aCompat(rIStm, StreamMode::READ);
maColor.Read( rIStm ); rIStm.ReadUInt32(maColor.mValue);
rIStm.ReadCharAsBool( mbSet ); rIStm.ReadCharAsBool( mbSet );
} }

View File

@@ -24,6 +24,7 @@
#include <tools/fract.hxx> #include <tools/fract.hxx>
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/helpers.hxx> #include <tools/helpers.hxx>
#include <tools/GenericTypeSerializer.hxx>
#include <vcl/dibtools.hxx> #include <vcl/dibtools.hxx>
#include <vcl/virdev.hxx> #include <vcl/virdev.hxx>
#include <vcl/graph.hxx> #include <vcl/graph.hxx>
@@ -33,7 +34,6 @@
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <svmconverter.hxx> #include <svmconverter.hxx>
#include <memory> #include <memory>
// Inlines // Inlines
@@ -1134,7 +1134,8 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
bool bSet; bool bSet;
sal_Int32 nFollowingActionCount(0); sal_Int32 nFollowingActionCount(0);
ReadColor( rIStm, aColor ); tools::GenericTypeSerializer aSerializer(rIStm);
aSerializer.readColor(aColor);
rIStm.ReadCharAsBool( bSet ).ReadInt32( nFollowingActionCount ); rIStm.ReadCharAsBool( bSet ).ReadInt32( nFollowingActionCount );
ImplSkipActions( rIStm, nFollowingActionCount ); ImplSkipActions( rIStm, nFollowingActionCount );
rMtf.AddAction( new MetaTextLineColorAction( aColor, bSet ) ); rMtf.AddAction( new MetaTextLineColorAction( aColor, bSet ) );

View File

@@ -19,6 +19,7 @@
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/vcompat.hxx> #include <tools/vcompat.hxx>
#include <tools/GenericTypeSerializer.hxx>
#include <vcl/bitmapex.hxx> #include <vcl/bitmapex.hxx>
#include <vcl/gradient.hxx> #include <vcl/gradient.hxx>
#include <vcl/wall.hxx> #include <vcl/wall.hxx>
@@ -61,7 +62,8 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
rImplWallpaper.mpBitmap.reset(); rImplWallpaper.mpBitmap.reset();
// version 1 // version 1
ReadColor( rIStm, rImplWallpaper.maColor ); tools::GenericTypeSerializer aSerializer(rIStm);
aSerializer.readColor(rImplWallpaper.maColor);
sal_uInt16 nTmp16(0); sal_uInt16 nTmp16(0);
rIStm.ReadUInt16(nTmp16); rIStm.ReadUInt16(nTmp16);
rImplWallpaper.meStyle = static_cast<WallpaperStyle>(nTmp16); rImplWallpaper.meStyle = static_cast<WallpaperStyle>(nTmp16);
@@ -94,7 +96,7 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
// version 3 (new color format) // version 3 (new color format)
if( aCompat.GetVersion() >= 3 ) 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; bool bDummy = false;
// version 1 // version 1
WriteColor( rOStm, rImplWallpaper.maColor ); tools::GenericTypeSerializer aSerializer(rOStm);
aSerializer.writeColor(rImplWallpaper.maColor);
rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplWallpaper.meStyle) ); rOStm.WriteUInt16( static_cast<sal_uInt16>(rImplWallpaper.meStyle) );
// version 2 // version 2
@@ -126,7 +130,7 @@ SvStream& WriteImplWallpaper( SvStream& rOStm, const ImplWallpaper& rImplWallpap
WriteDIBBitmapEx(*rImplWallpaper.mpBitmap, rOStm); WriteDIBBitmapEx(*rImplWallpaper.mpBitmap, rOStm);
// version 3 (new color format) // version 3 (new color format)
rImplWallpaper.maColor.Write( rOStm ); rOStm.WriteUInt32(rImplWallpaper.maColor.mValue);
return rOStm; return rOStm;
} }