diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2015-03-18 10:22:51 +0100 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2015-03-21 16:19:07 +0100 |
commit | caf653c03b9152a93c3e5959921fe98adfb7d639 (patch) | |
tree | 36adce1243ada028d7fbd667eed5f629349efdd2 /sw/qa/extras | |
parent | 8f01925d98dabdbf400c9263e08242267b2b9701 (diff) |
Char highlight: RTF filters
Handle \highlightN and \chcbpatN separately.
Change-Id: I20546bd4c26154e8b1168f87dcb4ab44a192ad83
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/globalfilter/data/char_highlight.docx (renamed from sw/qa/extras/ooxmlexport/data/char_highlight.docx) | bin | 4091 -> 4091 bytes | |||
-rw-r--r-- | sw/qa/extras/globalfilter/globalfilter.cxx | 80 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 49 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/data/fdo79599.rtf | 38 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 9 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo79599.rtf | 38 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 56 |
7 files changed, 81 insertions, 189 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/char_highlight.docx b/sw/qa/extras/globalfilter/data/char_highlight.docx Binary files differindex 841fc3e3a8e9..841fc3e3a8e9 100644 --- a/sw/qa/extras/ooxmlexport/data/char_highlight.docx +++ b/sw/qa/extras/globalfilter/data/char_highlight.docx diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index ae874729d505..e136665e0571 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -28,12 +28,14 @@ public: void testLinkedGraphicRT(); void testImageWithSpecialID(); void testGraphicShape(); + void testCharHighlight(); CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(testSwappedOutImageExport); CPPUNIT_TEST(testLinkedGraphicRT); CPPUNIT_TEST(testImageWithSpecialID); CPPUNIT_TEST(testGraphicShape); + CPPUNIT_TEST(testCharHighlight); CPPUNIT_TEST_SUITE_END(); }; @@ -350,6 +352,84 @@ void Test::testGraphicShape() } } +void Test::testCharHighlight() +{ + // MS Word has two kind of character backgrounds called character shading and highlighting + // Now we support these two background attributes colors both in import and export code + + const char* aFilterNames[] = { +// "writer8", + "Rich Text Format", +// "MS Word 97", + "Office Open XML Text", + }; + + for( size_t nFilter = 0; nFilter < SAL_N_ELEMENTS(aFilterNames); ++nFilter ) + { + if (mxComponent.is()) + mxComponent->dispose(); + mxComponent = loadFromDesktop(getURLFromSrc("/sw/qa/extras/globalfilter/data/char_highlight.docx"), + "com.sun.star.text.TextDocument"); + + // Export the document and import again for a check + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString::createFromAscii(aFilterNames[nFilter]); + + 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"); + + const uno::Reference< text::XTextRange > xPara = getParagraph(1); + // Both highlight and background + const sal_Int32 nBackColor(0x4F81BD); + for( int nRun = 1; nRun <= 16; ++nRun ) + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,nRun), uno::UNO_QUERY); + sal_Int32 nHighlightColor = 0; + switch( nRun ) + { + case 1: nHighlightColor = 0x000000; break; //black + case 2: nHighlightColor = 0x0000ff; break; //blue + case 3: nHighlightColor = 0x00ffff; break; //cyan + case 4: nHighlightColor = 0x00ff00; break; //green + case 5: nHighlightColor = 0xff00ff; break; //magenta + case 6: nHighlightColor = 0xff0000; break; //red + case 7: nHighlightColor = 0xffff00; break; //yellow + case 8: nHighlightColor = 0xffffff; break; //white + case 9: nHighlightColor = 0x000080; break;//dark blue + case 10: nHighlightColor = 0x008080; break; //dark cyan + case 11: nHighlightColor = 0x008000; break; //dark green + case 12: nHighlightColor = 0x800080; break; //dark magenta + case 13: nHighlightColor = 0x800000; break; //dark red + case 14: nHighlightColor = 0x808000; break; //dark yellow + case 15: nHighlightColor = 0x808080; break; //dark gray + case 16: nHighlightColor = 0xC0C0C0; break; //light gray + } + CPPUNIT_ASSERT_EQUAL(nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); + } + + // Only highlight + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + } + + // Only background + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); + } + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx index 0036db92f1ff..19c079ede5ef 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -469,55 +469,6 @@ DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx") CPPUNIT_ASSERT_EQUAL(OUString("RenderedShapes"), nValue); // Rendered bitmap has the proper name } - -DECLARE_OOXMLEXPORT_TEST(testCharHighlight, "char_highlight.docx") -{ - const uno::Reference< text::XTextRange > xPara = getParagraph(1); - // Both highlight and background - const sal_Int32 nBackColor(0x4F81BD); - for( int nRun = 1; nRun <= 16; ++nRun ) - { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,nRun), uno::UNO_QUERY); - sal_Int32 nHighlightColor = 0; - switch( nRun ) - { - case 1: nHighlightColor = 0x000000; break; //black - case 2: nHighlightColor = 0x0000ff; break; //blue - case 3: nHighlightColor = 0x00ffff; break; //cyan - case 4: nHighlightColor = 0x00ff00; break; //green - case 5: nHighlightColor = 0xff00ff; break; //magenta - case 6: nHighlightColor = 0xff0000; break; //red - case 7: nHighlightColor = 0xffff00; break; //yellow - case 8: nHighlightColor = 0xffffff; break; //white - case 9: nHighlightColor = 0x000080; break;//dark blue - case 10: nHighlightColor = 0x008080; break; //dark cyan - case 11: nHighlightColor = 0x008000; break; //dark green - case 12: nHighlightColor = 0x800080; break; //dark magenta - case 13: nHighlightColor = 0x800000; break; //dark red - case 14: nHighlightColor = 0x808000; break; //dark yellow - case 15: nHighlightColor = 0x808080; break; //dark gray - case 16: nHighlightColor = 0xC0C0C0; break; //light gray - } - CPPUNIT_ASSERT_EQUAL(nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); - } - - // Only highlight - { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); - } - - // Only background - { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); - } -} - - DECLARE_OOXMLEXPORT_TEST(testFontNameIsEmpty, "font-name-is-empty.docx") { // Check no empty font name is exported diff --git a/sw/qa/extras/rtfexport/data/fdo79599.rtf b/sw/qa/extras/rtfexport/data/fdo79599.rtf deleted file mode 100644 index f9087091e1b3..000000000000 --- a/sw/qa/extras/rtfexport/data/fdo79599.rtf +++ /dev/null @@ -1,38 +0,0 @@ -{\rtf1\deff0 -{\fonttbl -{\f000 Courier New;} -} -{\colortbl; -\red0\green0\blue0; -\red255\green255\blue0; -\red0\green255\blue0; -\red0\green255\blue255; -\red255\green0\blue255; -\red0\green0\blue255; -\red255\green0\blue0; -\red0\green0\blue128; -\red0\green128\blue128; -\red0\green128\blue0; -\red128\green0\blue128; -\red128\green0\blue0; -\red128\green128\blue0; -\red128\green128\blue128; -\red192\green192\blue192; -} -\highlight0 Should be ignored\par -\highlight2 #FFFF00 = Yellow\par -\highlight3 #00FF00 = Green\par -\highlight4 #00FFFF = Cyan\par -\highlight5 #FF00FF = Magenta\par -\highlight6 #0000FF = Blue\par -\highlight7 #FF0000 = Red\par -\highlight8 #000080 = Dark blue\par -\highlight9 #008080 = Dark cyan\par -\highlight10 #008000 = Dark green\par -\highlight11 #800080 = Dark magenta\par -\highlight12 #800000 = Dark red\par -\highlight13 #808000 = Dark yellow\par -\highlight14 #808080 = Dark gray\par -\highlight15 #C0C0C0 = Light gray\par -\highlight1 #000000 = Black\par -} diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index de571a2eda7e..3ef2f13bfc07 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -670,15 +670,6 @@ DECLARE_RTFEXPORT_TEST(testFdo77600, "fdo77600.rtf") CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(getRun(getParagraph(1), 3), "CharFontName")); } -DECLARE_RTFEXPORT_TEST(testFdo79599, "fdo79599.rtf") -{ - // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007) - - // test \highlight11 = dark magenta - uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(11),1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(xRun, "CharBackColor")); -} - DECLARE_RTFEXPORT_TEST(testFdo80167, "fdo80167.rtf") { // Problem was that after export, the page break was missing, so this was 1. diff --git a/sw/qa/extras/rtfimport/data/fdo79599.rtf b/sw/qa/extras/rtfimport/data/fdo79599.rtf deleted file mode 100644 index f9087091e1b3..000000000000 --- a/sw/qa/extras/rtfimport/data/fdo79599.rtf +++ /dev/null @@ -1,38 +0,0 @@ -{\rtf1\deff0 -{\fonttbl -{\f000 Courier New;} -} -{\colortbl; -\red0\green0\blue0; -\red255\green255\blue0; -\red0\green255\blue0; -\red0\green255\blue255; -\red255\green0\blue255; -\red0\green0\blue255; -\red255\green0\blue0; -\red0\green0\blue128; -\red0\green128\blue128; -\red0\green128\blue0; -\red128\green0\blue128; -\red128\green0\blue0; -\red128\green128\blue0; -\red128\green128\blue128; -\red192\green192\blue192; -} -\highlight0 Should be ignored\par -\highlight2 #FFFF00 = Yellow\par -\highlight3 #00FF00 = Green\par -\highlight4 #00FFFF = Cyan\par -\highlight5 #FF00FF = Magenta\par -\highlight6 #0000FF = Blue\par -\highlight7 #FF0000 = Red\par -\highlight8 #000080 = Dark blue\par -\highlight9 #008080 = Dark cyan\par -\highlight10 #008000 = Dark green\par -\highlight11 #800080 = Dark magenta\par -\highlight12 #800000 = Dark red\par -\highlight13 #808000 = Dark yellow\par -\highlight14 #808080 = Dark gray\par -\highlight15 #C0C0C0 = Light gray\par -\highlight1 #000000 = Black\par -} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 766ade91daa6..5cffa27215bb 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -604,59 +604,6 @@ DECLARE_RTFIMPORT_TEST(testFdo50539, "fdo50539.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor")); } -DECLARE_RTFIMPORT_TEST(testFdo79599, "fdo79599.rtf") -{ - // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007) - - // ignore \highlight0 - CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor")); - - // test \highlight2 = yellow - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFF00), getProperty<sal_uInt32>(getRun(getParagraph(2), 1), "CharBackColor")); - - // test \highlight3 = green - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), getProperty<sal_uInt32>(getRun(getParagraph(3), 1), "CharBackColor")); - - // test \highlight4 = cyan - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FFFF), getProperty<sal_uInt32>(getRun(getParagraph(4), 1), "CharBackColor")); - - // test \highlight5 = magenta - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF00FF), getProperty<sal_uInt32>(getRun(getParagraph(5), 1), "CharBackColor")); - - // test \highlight6 = blue - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0000FF), getProperty<sal_uInt32>(getRun(getParagraph(6), 1), "CharBackColor")); - - // test \highlight7 = red - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), getProperty<sal_uInt32>(getRun(getParagraph(7), 1), "CharBackColor")); - - // test \highlight8 = dark blue - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000080), getProperty<sal_uInt32>(getRun(getParagraph(8), 1), "CharBackColor")); - - // test \highlight9 = dark cyan - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008080), getProperty<sal_uInt32>(getRun(getParagraph(9), 1), "CharBackColor")); - - // test \highlight10 = dark green - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008000), getProperty<sal_uInt32>(getRun(getParagraph(10), 1), "CharBackColor")); - - // test \highlight11 = dark magenta - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(getRun(getParagraph(11), 1), "CharBackColor")); - - // test \highlight12 = dark red - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800000), getProperty<sal_uInt32>(getRun(getParagraph(12), 1), "CharBackColor")); - - // test \highlight13 = dark yellow - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808000), getProperty<sal_uInt32>(getRun(getParagraph(13), 1), "CharBackColor")); - - // test \highlight14 = dark gray - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808080), getProperty<sal_uInt32>(getRun(getParagraph(14), 1), "CharBackColor")); - - // test \highlight15 = light gray - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xC0C0C0), getProperty<sal_uInt32>(getRun(getParagraph(15), 1), "CharBackColor")); - - // test \highlight1 = black - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000000), getProperty<sal_uInt32>(getRun(getParagraph(16), 1), "CharBackColor")); -} - DECLARE_RTFIMPORT_TEST(testFdo50665, "fdo50665.rtf") { // Access the second run, which is a textfield @@ -1211,8 +1158,7 @@ DECLARE_RTFIMPORT_TEST(testFdo61909, "fdo61909.rtf") uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1); // Was the Writer default font. CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty<OUString>(xTextRange, "CharFontName")); - // It is white (0xFFFFFF) in document - CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFFFF), getProperty<sal_uInt32>(xTextRange, "CharBackColor")); + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(xTextRange, "CharBackColor")); } DECLARE_RTFIMPORT_TEST(testFdo62288, "fdo62288.rtf") |