summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-02-02 14:10:02 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-05 15:33:09 +0000
commite2383402d4cab93f4003e03912700a00525b7d4c (patch)
tree5e6b1862c05bbd67409e73241bcb27f2da22e0c2 /sw
parent9f9d679e72ca473c39ae31a284f85dd7a17e1ca3 (diff)
xmloff: tdf#96147: ODF export: fix duplicate fo:background-color
... attributes that happen if both CharHighlight and CharBackColor properties are used, because the CharBackTransparent property wasn't taken into account, and combining the CharBackColor and CharBackTransparent properties happens *after* XMLTextExportPropertySetMapper::ContextFilter() runs. Also, it looks like a transparent highlight wouldn't export properly but apparently DomainMapper::getColorFromId() won't create such. (regression from f880962f5bf26bfaef06bd3f9e67e2d901a2e74c) Change-Id: Ib628ef8bb377482f74fadb97c81afb95fbbf7184 (cherry picked from commit 8dadefc35f8b33648fb6adbdaca75ea52b2705db) Reviewed-on: https://gerrit.libreoffice.org/22042 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx80
1 files changed, 80 insertions, 0 deletions
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 1871c61ba052..751f2a5518d7 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -30,6 +30,7 @@ public:
void testImageWithSpecialID();
void testGraphicShape();
void testCharHighlight();
+ void testCharHighlightODF();
void testCharHighlightBody();
void testMSCharBackgroundEditing();
void testCharBackgroundToHighlighting();
@@ -43,6 +44,7 @@ public:
CPPUNIT_TEST(testImageWithSpecialID);
CPPUNIT_TEST(testGraphicShape);
CPPUNIT_TEST(testCharHighlight);
+ CPPUNIT_TEST(testCharHighlightODF);
CPPUNIT_TEST(testMSCharBackgroundEditing);
CPPUNIT_TEST(testCharBackgroundToHighlighting);
#if !defined(WNT)
@@ -473,6 +475,84 @@ void Test::testCharHighlight()
testCharHighlightBody();
}
+void Test::testCharHighlightODF()
+{
+ mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/globalfilter/data/char_background_editing.docx"),
+ "com.sun.star.text.TextDocument");
+
+ // don't check import, testMSCharBackgroundEditing already does that
+
+ uno::Reference<text::XTextRange> xPara = getParagraph(1);
+ for (int i = 1; i <= 4; ++i)
+ {
+ uno::Reference<beans::XPropertySet> xRun(getRun(xPara,i), uno::UNO_QUERY);
+ switch (i)
+ {
+ case 1: // non-transparent highlight
+ xRun->setPropertyValue("CharBackColor", uno::makeAny(static_cast<sal_Int32>(128)));
+ xRun->setPropertyValue("CharBackTransparent", uno::makeAny(true));
+ xRun->setPropertyValue("CharHighlight", uno::makeAny(static_cast<sal_Int32>(64)));
+ break;
+
+ case 2: // transparent backcolor
+ xRun->setPropertyValue("CharBackColor", uno::makeAny(static_cast<sal_Int32>(128)));
+ xRun->setPropertyValue("CharBackTransparent", uno::makeAny(true));
+ xRun->setPropertyValue("CharHighlight", uno::makeAny(static_cast<sal_Int32>(COL_TRANSPARENT)));
+ break;
+
+ case 3: // non-transparent backcolor
+ xRun->setPropertyValue("CharBackColor", uno::makeAny(static_cast<sal_Int32>(128)));
+ xRun->setPropertyValue("CharBackTransparent", uno::makeAny(false));
+ xRun->setPropertyValue("CharHighlight", uno::makeAny(static_cast<sal_Int32>(COL_TRANSPARENT)));
+ break;
+
+ case 4: // non-transparent highlight again
+ xRun->setPropertyValue("CharBackColor", uno::makeAny(static_cast<sal_Int32>(128)));
+ xRun->setPropertyValue("CharBackTransparent", uno::makeAny(false));
+ xRun->setPropertyValue("CharHighlight", uno::makeAny(static_cast<sal_Int32>(64)));
+ break;
+ }
+ }
+
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString::createFromAscii("writer8");
+
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+
+ uno::Reference< lang::XComponent > xComponent(xStorable, uno::UNO_QUERY);
+ xComponent->dispose();
+ mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument");
+
+ xPara.set(getParagraph(1));
+ for (int i = 1; i <= 4; ++i)
+ {
+ uno::Reference<beans::XPropertySet> xRun(getRun(xPara,i), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun, "CharHighlight"));
+ switch (i)
+ {
+ case 1: // non-transparent highlight
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(64), getProperty<sal_Int32>(xRun, "CharBackColor"));
+ CPPUNIT_ASSERT_EQUAL(sal_False, getProperty<sal_Bool>(xRun, "CharBackTransparent"));
+ break;
+ case 2: // transparent backcolor
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(COL_TRANSPARENT), getProperty<sal_Int32>(xRun, "CharBackColor"));
+ CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xRun, "CharBackTransparent"));
+ break;
+ case 3: // non-transparent backcolor
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(128), getProperty<sal_Int32>(xRun, "CharBackColor"));
+ CPPUNIT_ASSERT_EQUAL(sal_False, getProperty<sal_Bool>(xRun, "CharBackTransparent"));
+ break;
+ case 4: // non-transparent highlight again
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(64), getProperty<sal_Int32>(xRun, "CharBackColor"));
+ CPPUNIT_ASSERT_EQUAL(sal_False, getProperty<sal_Bool>(xRun, "CharBackTransparent"));
+ break;
+ }
+ }
+}
+
void Test::testMSCharBackgroundEditing()
{
// Simulate the editing process of imported MSO character background attributes