summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tools/color.hxx2
-rw-r--r--include/vcl/metaact.hxx5
-rw-r--r--starmath/inc/token.hxx13
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx8
-rw-r--r--tools/qa/cppunit/test_color.cxx44
-rw-r--r--vcl/source/gdi/metaact.cxx44
-rw-r--r--vcl/source/gdi/wall.cxx6
7 files changed, 70 insertions, 52 deletions
diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index 3226184ca117..209ed34169a8 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -48,8 +48,6 @@ enum ColorAlphaTag { ColorAlpha = 0 };
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Color
{
- // data intentionally public; read the commit log!
-public:
union
{
sal_uInt32 mValue;
diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx
index ef36989df80f..5ed09a9c5315 100644
--- a/include/vcl/metaact.hxx
+++ b/include/vcl/metaact.hxx
@@ -93,8 +93,11 @@ public:
*/
virtual bool IsTransparent() const { return false; }
-public:
static rtl::Reference<MetaAction> ReadMetaAction(SvStream& rIStm, ImplMetaReadData* pData);
+
+protected:
+ static void ReadColor(SvStream& rIStm, ::Color& rColor);
+ static void WriteColor(SvStream& rIStm, ::Color aColor);
};
class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaPixelAction final : public MetaAction
diff --git a/starmath/inc/token.hxx b/starmath/inc/token.hxx
index cb485a531ac8..374e23876a9f 100644
--- a/starmath/inc/token.hxx
+++ b/starmath/inc/token.hxx
@@ -209,7 +209,10 @@ struct SmColorTokenTableEntry
return colorname.compareToIgnoreAsciiCaseAscii(pIdent) == 0;
}
- bool operator==(sal_uInt32 colorcode) const { return colorcode == cColor.mValue; }
+ bool operator==(sal_uInt32 colorcode) const
+ {
+ return colorcode == static_cast<sal_uInt32>(cColor);
+ }
bool operator==(Color colorcode) const { return colorcode == cColor; }
@@ -218,7 +221,7 @@ struct SmColorTokenTableEntry
return colorname.compareToIgnoreAsciiCaseAscii(pIdent) == 0;
}
- bool equals(sal_uInt32 colorcode) const { return colorcode == cColor.mValue; }
+ bool equals(sal_uInt32 colorcode) const { return colorcode == static_cast<sal_uInt32>(cColor); }
bool equals(Color colorcode) const { return colorcode == cColor; }
};
@@ -283,7 +286,7 @@ struct SmToken
void operator=(const SmColorTokenTableEntry& aTokenTableEntry)
{
- aText = OUString::number(aTokenTableEntry.cColor.mValue, 16);
+ aText = OUString::number(static_cast<sal_uInt32>(aTokenTableEntry.cColor), 16);
eType = aTokenTableEntry.eType;
cMathChar = MS_NULLCHAR;
nGroup = TG::Color;
@@ -294,7 +297,7 @@ struct SmToken
void operator=(const SmColorTokenTableEntry* aTokenTableEntry)
{
- aText = OUString::number(aTokenTableEntry->cColor.mValue, 16);
+ aText = OUString::number(static_cast<sal_uInt32>(aTokenTableEntry->cColor), 16);
eType = aTokenTableEntry->eType;
cMathChar = MS_NULLCHAR;
nGroup = TG::Color;
@@ -305,7 +308,7 @@ struct SmToken
void operator=(const std::unique_ptr<SmColorTokenTableEntry>& aTokenTableEntry)
{
- aText = OUString::number(aTokenTableEntry->cColor.mValue, 16);
+ aText = OUString::number(static_cast<sal_uInt32>(aTokenTableEntry->cColor), 16);
eType = aTokenTableEntry->eType;
cMathChar = MS_NULLCHAR;
nGroup = TG::Color;
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 10d54fc91e2e..28edd8c5fb55 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -2419,9 +2419,9 @@ void SwTiledRenderingTest::testSemiTransparent()
// Without the accompanying fix in place, this test would have failed with 'Expected greater or
// equal than: 190; Actual: 159'. This means the semi-transparent gray rectangle was darker than
// expected, as it was painted twice.
- CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.R));
- CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.G));
- CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.B));
+ CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.GetRed()));
+ CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.GetGreen()));
+ CPPUNIT_ASSERT_GREATEREQUAL(190, static_cast<int>(aColor.GetBlue()));
}
void SwTiledRenderingTest::testHighlightNumbering()
@@ -2543,7 +2543,7 @@ void SwTiledRenderingTest::testClipText()
for (int i = 0; i < 150; i++)
{
Color aTopTextColor(pAccess->GetPixel(98, 98 + i));
- if (aTopTextColor.R < 255)
+ if (aTopTextColor.GetRed() < 255)
{
bClipTop = false;
break;
diff --git a/tools/qa/cppunit/test_color.cxx b/tools/qa/cppunit/test_color.cxx
index 28e2118dc99a..05616b8f64a2 100644
--- a/tools/qa/cppunit/test_color.cxx
+++ b/tools/qa/cppunit/test_color.cxx
@@ -39,41 +39,41 @@ public:
void Test::testVariables()
{
Color aColor(0x44, 0x88, 0xAA);
- CPPUNIT_ASSERT_EQUAL(int(0x00), int(aColor.A));
- CPPUNIT_ASSERT_EQUAL(int(0x44), int(aColor.R));
- CPPUNIT_ASSERT_EQUAL(int(0x88), int(aColor.G));
- CPPUNIT_ASSERT_EQUAL(int(0xAA), int(aColor.B));
- CPPUNIT_ASSERT_EQUAL(int(0x004488AA), int(aColor.mValue));
+ CPPUNIT_ASSERT_EQUAL(int(0x00), int(255 - aColor.GetAlpha()));
+ CPPUNIT_ASSERT_EQUAL(int(0x44), int(aColor.GetRed()));
+ CPPUNIT_ASSERT_EQUAL(int(0x88), int(aColor.GetGreen()));
+ CPPUNIT_ASSERT_EQUAL(int(0xAA), int(aColor.GetBlue()));
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x004488AA), sal_uInt32(aColor));
- aColor.mValue = 0xAABBCCDD;
- CPPUNIT_ASSERT_EQUAL(int(0xAA), int(aColor.A));
- CPPUNIT_ASSERT_EQUAL(int(0xBB), int(aColor.R));
- CPPUNIT_ASSERT_EQUAL(int(0xCC), int(aColor.G));
- CPPUNIT_ASSERT_EQUAL(int(0xDD), int(aColor.B));
+ aColor = Color(ColorTransparency, 0xAABBCCDD);
+ CPPUNIT_ASSERT_EQUAL(int(0xAA), int(255 - aColor.GetAlpha()));
+ CPPUNIT_ASSERT_EQUAL(int(0xBB), int(aColor.GetRed()));
+ CPPUNIT_ASSERT_EQUAL(int(0xCC), int(aColor.GetGreen()));
+ CPPUNIT_ASSERT_EQUAL(int(0xDD), int(aColor.GetBlue()));
- aColor.A = 0x11;
- CPPUNIT_ASSERT_EQUAL(int(0x11BBCCDD), int(aColor.mValue));
+ aColor.SetAlpha(255 - 0x11);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x11BBCCDD), sal_uInt32(aColor));
- aColor.R = 0x22;
- CPPUNIT_ASSERT_EQUAL(int(0x1122CCDD), int(aColor.mValue));
+ aColor.SetRed(0x22);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x1122CCDD), sal_uInt32(aColor));
- aColor.G = 0x33;
- CPPUNIT_ASSERT_EQUAL(int(0x112233DD), int(aColor.mValue));
+ aColor.SetGreen(0x33);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x112233DD), sal_uInt32(aColor));
- aColor.B = 0x44;
- CPPUNIT_ASSERT_EQUAL(int(0x11223344), int(aColor.mValue));
+ aColor.SetBlue(0x44);
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x11223344), sal_uInt32(aColor));
aColor.SetAlpha(255 - 0x77);
- CPPUNIT_ASSERT_EQUAL(int(0x77223344), int(aColor.mValue));
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x77223344), sal_uInt32(aColor));
aColor.SetRed(0x88);
- CPPUNIT_ASSERT_EQUAL(int(0x77883344), int(aColor.mValue));
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x77883344), sal_uInt32(aColor));
aColor.SetGreen(0x99);
- CPPUNIT_ASSERT_EQUAL(int(0x77889944), int(aColor.mValue));
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x77889944), sal_uInt32(aColor));
aColor.SetBlue(0xAA);
- CPPUNIT_ASSERT_EQUAL(int(0x778899AA), int(aColor.mValue));
+ CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x778899AA), sal_uInt32(aColor));
}
void Test::test_asRGBColor()
diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx
index 11100101f2eb..5ae914e44091 100644
--- a/vcl/source/gdi/metaact.cxx
+++ b/vcl/source/gdi/metaact.cxx
@@ -271,6 +271,18 @@ rtl::Reference<MetaAction> MetaAction::ReadMetaAction( SvStream& rIStm, ImplMeta
return pAction;
}
+void MetaAction::ReadColor(SvStream& rIStm, ::Color& rColor)
+{
+ sal_uInt32 nTmp;
+ rIStm.ReadUInt32(nTmp);
+ rColor = ::Color(ColorTransparency, nTmp);
+}
+
+void MetaAction::WriteColor(SvStream& rIStm, ::Color aColor)
+{
+ rIStm.WriteUInt32(static_cast<sal_uInt32>(aColor));
+}
+
MetaPixelAction::MetaPixelAction() :
MetaAction(MetaActionType::PIXEL)
{}
@@ -310,7 +322,7 @@ void MetaPixelAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
VersionCompatWrite aCompat(rOStm, 1);
TypeSerializer aSerializer(rOStm);
aSerializer.writePoint(maPt);
- rOStm.WriteUInt32(maColor.mValue);
+ WriteColor(rOStm, maColor);
}
void MetaPixelAction::Read( SvStream& rIStm, ImplMetaReadData* )
@@ -318,7 +330,7 @@ void MetaPixelAction::Read( SvStream& rIStm, ImplMetaReadData* )
VersionCompatRead aCompat(rIStm);
TypeSerializer aSerializer(rIStm);
aSerializer.readPoint(maPt);
- rIStm.ReadUInt32(maColor.mValue);
+ ReadColor(rIStm, maColor);
}
MetaPointAction::MetaPointAction() :
@@ -1981,7 +1993,7 @@ void MetaMaskScalePartAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
WriteDIB(maBmp, rOStm, false, true);
- rOStm.WriteUInt32(maColor.mValue);
+ WriteColor(rOStm, maColor);
TypeSerializer aSerializer(rOStm);
aSerializer.writePoint(maDstPt);
aSerializer.writeSize(maDstSz);
@@ -1994,7 +2006,7 @@ void MetaMaskScalePartAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompatRead aCompat(rIStm);
ReadDIB(maBmp, rIStm, true);
- rIStm.ReadUInt32(maColor.mValue);
+ ReadColor(rIStm, maColor);
TypeSerializer aSerializer(rIStm);
aSerializer.readPoint(maDstPt);
aSerializer.readSize(maDstSz);
@@ -2437,14 +2449,14 @@ void MetaLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
- rOStm.WriteUInt32(maColor.mValue);
+ WriteColor(rOStm, maColor);
rOStm.WriteBool( mbSet );
}
void MetaLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompatRead aCompat(rIStm);
- rIStm.ReadUInt32(maColor.mValue);
+ ReadColor(rIStm, maColor);
rIStm.ReadCharAsBool( mbSet );
}
@@ -2479,14 +2491,14 @@ void MetaFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
- rOStm.WriteUInt32(maColor.mValue);
+ WriteColor(rOStm, maColor);
rOStm.WriteBool( mbSet );
}
void MetaFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompatRead aCompat(rIStm);
- rIStm.ReadUInt32(maColor.mValue);
+ ReadColor(rIStm, maColor);
rIStm.ReadCharAsBool( mbSet );
}
@@ -2516,13 +2528,13 @@ void MetaTextColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
- rOStm.WriteUInt32(maColor.mValue);
+ WriteColor(rOStm, maColor);
}
void MetaTextColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompatRead aCompat(rIStm);
- rIStm.ReadUInt32(maColor.mValue);
+ ReadColor(rIStm, maColor);
}
MetaTextFillColorAction::MetaTextFillColorAction() :
@@ -2556,14 +2568,14 @@ void MetaTextFillColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
- rOStm.WriteUInt32(maColor.mValue);
+ WriteColor(rOStm, maColor);
rOStm.WriteBool( mbSet );
}
void MetaTextFillColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompatRead aCompat(rIStm);
- rIStm.ReadUInt32(maColor.mValue);
+ ReadColor(rIStm, maColor);
rIStm.ReadCharAsBool( mbSet );
}
@@ -2598,14 +2610,14 @@ void MetaTextLineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
- rOStm.WriteUInt32(maColor.mValue);
+ WriteColor(rOStm, maColor);
rOStm.WriteBool( mbSet );
}
void MetaTextLineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompatRead aCompat(rIStm);
- rIStm.ReadUInt32(maColor.mValue);
+ ReadColor(rIStm, maColor);
rIStm.ReadCharAsBool( mbSet );
}
@@ -2640,14 +2652,14 @@ void MetaOverlineColorAction::Write( SvStream& rOStm, ImplMetaWriteData* pData )
{
MetaAction::Write(rOStm, pData);
VersionCompatWrite aCompat(rOStm, 1);
- rOStm.WriteUInt32(maColor.mValue);
+ WriteColor(rOStm, maColor);
rOStm.WriteBool( mbSet );
}
void MetaOverlineColorAction::Read( SvStream& rIStm, ImplMetaReadData* )
{
VersionCompatRead aCompat(rIStm);
- rIStm.ReadUInt32(maColor.mValue);
+ ReadColor(rIStm, maColor);
rIStm.ReadCharAsBool( mbSet );
}
diff --git a/vcl/source/gdi/wall.cxx b/vcl/source/gdi/wall.cxx
index c6e07afa37ca..db2d0804d747 100644
--- a/vcl/source/gdi/wall.cxx
+++ b/vcl/source/gdi/wall.cxx
@@ -96,7 +96,9 @@ SvStream& ReadImplWallpaper( SvStream& rIStm, ImplWallpaper& rImplWallpaper )
// version 3 (new color format)
if( aCompat.GetVersion() >= 3 )
{
- rIStm.ReadUInt32(rImplWallpaper.maColor.mValue);
+ sal_uInt32 nTmp;
+ rIStm.ReadUInt32(nTmp);
+ rImplWallpaper.maColor = ::Color(ColorTransparency, nTmp);
}
}
@@ -134,7 +136,7 @@ SvStream& WriteImplWallpaper( SvStream& rOStm, const ImplWallpaper& rImplWallpap
WriteDIBBitmapEx(*rImplWallpaper.mpBitmap, rOStm);
// version 3 (new color format)
- rOStm.WriteUInt32(rImplWallpaper.maColor.mValue);
+ rOStm.WriteUInt32(static_cast<sal_uInt32>(rImplWallpaper.maColor));
return rOStm;
}