Tests with color stops to assert Color and not BColor values

For testing color stops of a gradient we don't need to assert super
precise values (doubls to the n-th decimal point) as long the end
results in the same (8-bit) Color value. So change the tests to
convert the BColor that is in gradient color stops to Color and
assert the Color value.

Change-Id: Ibd7661e2f72955a0778e822df1fae568973be357
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155360
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Tomaž Vajngerl 2023-08-01 22:06:31 +02:00 committed by Tomaž Vajngerl
parent e60ef8651c
commit 73ec9c7168
14 changed files with 115 additions and 131 deletions

View file

@ -632,11 +632,11 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testBnc889755)
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.25, 0.25, 0.25));
CPPUNIT_ASSERT_EQUAL(Color(0x404040), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.070000000000000007));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.25, 0.25, 0.25));
CPPUNIT_ASSERT_EQUAL(Color(0x404040), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 0.080000000000000002));
CPPUNIT_ASSERT_EQUAL(aColorStops[2].getStopColor(), basegfx::BColor(1.0, 1.0, 1.0));
CPPUNIT_ASSERT_EQUAL(Color(0xffffff), Color(aColorStops[2].getStopColor()));
}
CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testBnc882383)
@ -676,9 +676,9 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testTransparencyGradientValue)
// MCGR: Use the whole completely imported transparency gradient to check for correctness
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.3, 0.3, 0.3));
CPPUNIT_ASSERT_EQUAL(Color(0x4d4d4d), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.2, 0.2, 0.2));
CPPUNIT_ASSERT_EQUAL(Color(0x333333), Color(aColorStops[1].getStopColor()));
}
CPPUNIT_TEST_FIXTURE(Chart2ImportTest, testSimpleStrictXLSX)

View file

@ -194,8 +194,16 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testGradientMultiStepTransparency)
const basegfx::BColorStops aColorStops(aTransparence.ColorStops);
CPPUNIT_ASSERT_EQUAL(size_t(5), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[4].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[4].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00, aColorStops[0].getStopOffset(), 1E-3);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.19, aColorStops[1].getStopOffset(), 1E-3);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.35, aColorStops[2].getStopOffset(), 1E-3);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.58, aColorStops[3].getStopOffset(), 1E-3);
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.00, aColorStops[4].getStopOffset(), 1E-3);
CPPUNIT_ASSERT_EQUAL(Color(0xffffff), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT_EQUAL(Color(0x9e9e9e), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(Color(0x363636), Color(aColorStops[2].getStopColor()));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[3].getStopColor()));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[4].getStopColor()));
}
CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testShapeTextAlignment)

View file

@ -475,11 +475,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3)
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
CPPUNIT_ASSERT_EQUAL(Color(0x0000ff), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(
aColorStops[1].getStopColor(),
basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865));
CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient.Angle);
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aGradient.XOffset);
@ -500,11 +498,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3)
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.40000000000000002));
CPPUNIT_ASSERT_EQUAL(
aColorStops[0].getStopColor(),
basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865));
CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
CPPUNIT_ASSERT_EQUAL(Color(0x0000ff), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient.Angle);
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset);
@ -525,11 +521,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testWriterFontwork3)
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(
aColorStops[0].getStopColor(),
basegfx::BColor(0.96862745098039216, 0.58823529411764708, 0.27450980392156865));
CPPUNIT_ASSERT_EQUAL(Color(0xf79646), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
CPPUNIT_ASSERT_EQUAL(Color(0x0000ff), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(sal_Int16(900), aGradient.Angle);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.XOffset);
@ -642,11 +636,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(),
basegfx::BColor(1.0, 0.75294117647058822, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0xffc000), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(),
basegfx::BColor(0.75294117647058822, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0xc00000), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
CPPUNIT_ASSERT_EQUAL(sal_Int16(690), aGradient.Angle);
@ -675,11 +667,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(),
basegfx::BColor(0.0, 0.51372549019607838, 0.8784313725490196));
CPPUNIT_ASSERT_EQUAL(Color(0x0083e0), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(),
basegfx::BColor(0.90196078431372551, 0.90196078431372551, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0xe6e600), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style);
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset);
@ -692,13 +682,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
// Transparency is encoded in gray color.
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(
aColorStops[0].getStopColor(),
basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002));
CPPUNIT_ASSERT_EQUAL(Color(0x666666), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(
aColorStops[1].getStopColor(),
basegfx::BColor(0.29999999999999999, 0.29999999999999999, 0.29999999999999999));
CPPUNIT_ASSERT_EQUAL(Color(0x4d4d4d), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style);
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), aGradient.XOffset);
@ -732,13 +718,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(
aColorStops[0].getStopColor(),
basegfx::BColor(0.26666666666666666, 0.44705882352941179, 0.7686274509803922));
CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(
aColorStops[1].getStopColor(),
basegfx::BColor(0.26666666666666666, 0.44705882352941179, 0.7686274509803922));
CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT, aGradient.Style);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.XOffset);
@ -751,9 +733,9 @@ CPPUNIT_TEST_FIXTURE(OoxShapeTest, testImportWordArtGradient)
// Transparency is encoded in gray color.
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(1.0, 1.0, 1.0));
CPPUNIT_ASSERT_EQUAL(Color(0xFFFFFF), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RECT, aGradient.Style);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aGradient.XOffset);

View file

@ -1653,12 +1653,9 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf129789)
CPPUNIT_ASSERT_EQUAL(size_t(2), rColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(
rColorStops[0].getStopColor(),
basegfx::BColor(0.8666666666666667, 0.90980392156862744, 0.79607843137254897));
CPPUNIT_ASSERT_EQUAL(Color(0xdde8cb), Color(rColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(rColorStops[1].getStopColor(),
basegfx::BColor(1.0, 0.84313725490196079, 0.84313725490196079));
CPPUNIT_ASSERT_EQUAL(Color(0xffd7d7), Color(rColorStops[1].getStopColor()));
SdrCaptionObj* const pCaptionH9 = checkCaption(*pDoc, ScAddress(7, 8, 0), false);
@ -1670,12 +1667,9 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf129789)
CPPUNIT_ASSERT_EQUAL(size_t(2), rColorStops2.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops2[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(
rColorStops2[0].getStopColor(),
basegfx::BColor(0.8666666666666667, 0.90980392156862744, 0.79607843137254897));
CPPUNIT_ASSERT_EQUAL(Color(0xdde8cb), Color(rColorStops2[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops2[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(rColorStops2[1].getStopColor(),
basegfx::BColor(1.0, 0.84313725490196079, 0.84313725490196079));
CPPUNIT_ASSERT_EQUAL(Color(0xffd7d7), Color(rColorStops2[1].getStopColor()));
}
{

View file

@ -1233,13 +1233,11 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf94238)
// was incorrect.
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.39000000000000001));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(
aColorStops[2].getStopColor(),
basegfx::BColor(0.54509803921568623, 0.54509803921568623, 0.54509803921568623));
CPPUNIT_ASSERT_EQUAL(Color(0x8b8b8b), Color(aColorStops[2].getStopColor()));
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testPictureTransparency)
@ -1491,11 +1489,11 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest1, testTdf128345GradientAxial)
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(1.0, 1.0, 1.0));
CPPUNIT_ASSERT_EQUAL(Color(0xffffff), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.5));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[2].getStopColor(), basegfx::BColor(1.0, 1.0, 1.0));
CPPUNIT_ASSERT_EQUAL(Color(0xffffff), Color(aColorStops[2].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aTransparenceGradient.Style);
}

View file

@ -1015,10 +1015,9 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest2, testTdf105739)
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(1.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0xff0000), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(),
basegfx::BColor(0.0, 0.69019607843137254, 0.31372549019607843));
CPPUNIT_ASSERT_EQUAL(Color(0x00b050), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(int(awt::GradientStyle_LINEAR), static_cast<int>(aFillGradient.Style));
}
}

View file

@ -1253,9 +1253,9 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf127372)
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[1].getStopColor()));
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf127379)
@ -1285,11 +1285,9 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf127379)
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(1.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0xff0000), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(
aColorStops[1].getStopColor(),
basegfx::BColor(0.16470588235294117, 0.37647058823529411, 0.59999999999999998));
CPPUNIT_ASSERT_EQUAL(Color(0x2a6099), Color(aColorStops[1].getStopColor()));
}
CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf98603)

View file

@ -290,9 +290,9 @@ void SdMiscTest::testFillGradient()
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(1.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0xff0000), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 1.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0x00ff00), Color(aColorStops[1].getStopColor()));
}
void SdMiscTest::testTdf44774()

View file

@ -819,9 +819,9 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillGradient)
CPPUNIT_ASSERT_EQUAL(size_t(2), rColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(rColorStops[0].getStopColor(), basegfx::BColor(1.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0xff0000), Color(rColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(rColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(rColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 1.0));
CPPUNIT_ASSERT_EQUAL(Color(0x0000ff), Color(rColorStops[1].getStopColor()));
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf134053)

View file

@ -794,9 +794,9 @@ DECLARE_ODFEXPORT_TEST(testTextframeGradient, "textframe-gradient.odt")
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.75294117647058822, 0.31372549019607843, 0.30196078431372547));
CPPUNIT_ASSERT_EQUAL(Color(0xc0504d), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.85098039215686272, 0.58431372549019611, 0.58039215686274515));
CPPUNIT_ASSERT_EQUAL(Color(0xd99594), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
@ -808,9 +808,9 @@ DECLARE_ODFEXPORT_TEST(testTextframeGradient, "textframe-gradient.odt")
CPPUNIT_ASSERT_EQUAL(size_t(2), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002));
CPPUNIT_ASSERT_EQUAL(Color(0x666666), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
}

View file

@ -575,11 +575,11 @@ DECLARE_OOXMLEXPORT_TEST(testTextframeGradient, "textframe-gradient.docx")
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.85098039215686272, 0.58431372549019611, 0.58039215686274515));
CPPUNIT_ASSERT_EQUAL(Color(0xd99594), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.5));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.75294117647058822, 0.31372549019607843, 0.30196078431372547));
CPPUNIT_ASSERT_EQUAL(Color(0xc0504d), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[2].getStopColor(), basegfx::BColor(0.85098039215686272, 0.58431372549019611, 0.58039215686274515));
CPPUNIT_ASSERT_EQUAL(Color(0xd99594), Color(aColorStops[2].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
xFrame.set(getShape(2), uno::UNO_QUERY);
@ -591,11 +591,11 @@ DECLARE_OOXMLEXPORT_TEST(testTextframeGradient, "textframe-gradient.docx")
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002));
CPPUNIT_ASSERT_EQUAL(Color(0x666666), Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.5));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), basegfx::BColor(0.0, 0.0, 0.0));
CPPUNIT_ASSERT_EQUAL(Color(0x000000), Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[2].getStopColor(), basegfx::BColor(0.40000000000000002, 0.40000000000000002, 0.40000000000000002));
CPPUNIT_ASSERT_EQUAL(Color(0x666666), Color(aColorStops[2].getStopColor()));
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
// Left / right margin was incorrect: the attribute was missing and we

View file

@ -616,10 +616,10 @@ DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf")
awt::Gradient2 aGradient = getProperty<awt::Gradient2>(xFrame, "FillGradient");
// prepare compare colors
const basegfx::BColor aColA(0.85098039215686272, 0.58431372549019611, 0.58039215686274515);
const basegfx::BColor aColB(0.75294117647058822, 0.31372549019607843, 0.30196078431372547);
const basegfx::BColor aColC(0.40000000000000002, 0.40000000000000002, 0.40000000000000002);
const basegfx::BColor aColD(0.0, 0.0, 0.0);
const Color aColA(0xd99594);
const Color aColB(0xc0504d);
const Color aColC(0x666666);
const Color aColD(0x000000);
// MCGR: Use the completely imported transparency gradient to check for correctness
basegfx::BColorStops aColorStops(aGradient.ColorStops);
@ -627,11 +627,11 @@ DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf")
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), aColA);
CPPUNIT_ASSERT_EQUAL(aColA, Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.5));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), aColB);
CPPUNIT_ASSERT_EQUAL(aColB, Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[2].getStopColor(), aColA);
CPPUNIT_ASSERT_EQUAL(aColA, Color(aColorStops[2].getStopColor()));
xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT,
@ -644,11 +644,11 @@ DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf")
CPPUNIT_ASSERT_EQUAL(size_t(3), aColorStops.size());
CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_LINEAR, aGradient.Style);
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[0].getStopOffset(), 0.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[0].getStopColor(), aColC);
CPPUNIT_ASSERT_EQUAL(aColC, Color(aColorStops[0].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[1].getStopOffset(), 0.5));
CPPUNIT_ASSERT_EQUAL(aColorStops[1].getStopColor(), aColD);
CPPUNIT_ASSERT_EQUAL(aColD, Color(aColorStops[1].getStopColor()));
CPPUNIT_ASSERT(basegfx::fTools::equal(aColorStops[2].getStopOffset(), 1.0));
CPPUNIT_ASSERT_EQUAL(aColorStops[2].getStopColor(), aColC);
CPPUNIT_ASSERT_EQUAL(aColC, Color(aColorStops[2].getStopColor()));
}
DECLARE_RTFEXPORT_TEST(testRecordChanges, "record-changes.rtf")

View file

@ -21,9 +21,11 @@ $(eval $(call gb_CppunitTest_add_exception_objects,xmloff_style, \
))
$(eval $(call gb_CppunitTest_use_libraries,xmloff_style, \
basegfx \
comphelper \
cppu \
cppuhelper \
docmodel \
subsequenttest \
embobj \
sal \

View file

@ -17,9 +17,9 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/rendering/RGBColor.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <docmodel/uno/UnoComplexColor.hxx>
#include <officecfg/Office/Common.hxx>
#include <rtl/character.hxx>
#include <unotools/saveopt.hxx>
@ -80,6 +80,12 @@ struct XmlFont
return aFontFamilyGeneric.compareTo(rOther.aFontFamilyGeneric) < 0;
}
};
Color asColor(com::sun::star::rendering::RGBColor const& rRGBColor)
{
basegfx::BColor aBColor(rRGBColor.Red, rRGBColor.Green, rRGBColor.Blue);
return Color(aBColor);
}
}
CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFontSorting)
@ -369,16 +375,16 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew)
// Test new properties
auto aColorStopSeq = aGradient.ColorStops;
awt::ColorStop aColorStop = aColorStopSeq[0];
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Red);
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Green);
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue);
aColorStop = aColorStopSeq[1];
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Red);
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Green);
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue);
{
awt::ColorStop aColorStop = aColorStopSeq[0];
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(Color(0xff0000), asColor(aColorStop.StopColor));
}
{
awt::ColorStop aColorStop = aColorStopSeq[1];
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(Color(0xffff00), asColor(aColorStop.StopColor));
}
}
CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew_opacity)
@ -429,18 +435,16 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_OldToNew_opacity)
// Test new properties
auto aColorStopSeq = aGradient.ColorStops;
awt::ColorStop aColorStop = aColorStopSeq[0];
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopOffset);
// Rounding error because of converting through color: 90% => 0.9 * 255 => 229
// 299.0 / 255.0 = 0.898039215686275
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.9, aColorStop.StopColor.Red, 0.002);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.9, aColorStop.StopColor.Green, 0.002);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.9, aColorStop.StopColor.Blue, 0.002);
aColorStop = aColorStopSeq[1];
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Red);
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Green);
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue);
{
awt::ColorStop aColorStop = aColorStopSeq[0];
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(Color(0xe5e5e5), asColor(aColorStop.StopColor));
}
{
awt::ColorStop aColorStop = aColorStopSeq[1];
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(Color(0x000000), asColor(aColorStop.StopColor));
}
}
CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_threeStops)
@ -497,22 +501,21 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testMCGR_threeStops)
// Test new properties
auto aColorStopSeq = aGradient.ColorStops;
awt::ColorStop aColorStop = aColorStopSeq[0];
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Red);
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Green);
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue);
aColorStop = aColorStopSeq[1];
CPPUNIT_ASSERT_EQUAL(0.3, aColorStop.StopOffset);
// 0x99 = 153 => 153/255 = 0.6, 0xbb = 187 => 187/255 = 0.733...
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Red);
CPPUNIT_ASSERT_EQUAL(0.6, aColorStop.StopColor.Green);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.733333333333333, aColorStop.StopColor.Blue, 0.0000001);
aColorStop = aColorStopSeq[2];
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Red);
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopColor.Green);
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopColor.Blue);
{
awt::ColorStop aColorStop = aColorStopSeq[0];
CPPUNIT_ASSERT_EQUAL(0.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(Color(0xff0000), asColor(aColorStop.StopColor));
}
{
awt::ColorStop aColorStop = aColorStopSeq[1];
CPPUNIT_ASSERT_EQUAL(0.3, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(Color(0x0099bb), asColor(aColorStop.StopColor));
}
{
awt::ColorStop aColorStop = aColorStopSeq[2];
CPPUNIT_ASSERT_EQUAL(1.0, aColorStop.StopOffset);
CPPUNIT_ASSERT_EQUAL(Color(0xffff00), asColor(aColorStop.StopColor));
}
}
CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBorderRestoration)