diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-09-29 10:24:53 +0200 |
---|---|---|
committer | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2013-09-29 11:27:34 +0200 |
commit | 8b949134441056a1455d67ddfdd7e0bc5f2ee682 (patch) | |
tree | ba258b0f7df5b3ae7b5fbc4cf484cebcf51f389a /sw/qa | |
parent | 1b0f6be2d06154f6ecab2f6ee930fa3c5a62f01d (diff) |
fdo#65403, fdo#65404 DOCX export/import of character highlight
Steps
-Add a new character attribute (RES_CHRATR_HIGHLIGHT)
-Get this character attribute via SwFont class just like
background
-If has highlight, then paint that, otherwise paint background
-Extend UNO API
-Implement DOCX export and import filter
Note: By now character highlight can't be set via UI.
It's a next step to add a highlight option.
Change-Id: I7f81e173744bf256891487f898d06dbf372a2f88
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/char_highlight.docx | bin | 0 -> 4091 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 49 |
2 files changed, 49 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/char_highlight.docx b/sw/qa/extras/ooxmlexport/data/char_highlight.docx Binary files differnew file mode 100644 index 000000000000..841fc3e3a8e9 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/char_highlight.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index cc4131e0fbc9..45e50b1ce44a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -121,6 +121,7 @@ public: void testStyleInheritance(); void testSmartart(); void testFdo69636(); + void testCharHighLight(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -239,6 +240,7 @@ void Test::run() {"style-inheritance.docx", &Test::testStyleInheritance}, {"smartart.docx", &Test::testSmartart}, {"fdo69636.docx", &Test::testFdo69636}, + {"char_highlight.docx", &Test::testCharHighLight}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -1492,6 +1494,53 @@ void Test::testFdo69636() CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:pict/v:rect/v:textbox", "style").match("mso-layout-flow-alt:bottom-to-top")); } +void Test::testCharHighLight() +{ + 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(); |