diff options
author | Oliver Specht <oliver.specht@cib.de> | 2023-12-05 13:28:36 +0100 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2023-12-19 20:53:12 +0100 |
commit | 9e127010a86b3521c803ac86c0b5f58dc8e2966b (patch) | |
tree | 621845ea090c334081ae635d29dde0d59dd5c922 /sw/qa/extras/ooxmlimport | |
parent | dc8632a8b5c5dc4f58a4677d90f2f05133aa713d (diff) |
tdf#158044 writerfilter: handle toggle properties in import/export
DOCX has some odd properties (bold, italic, shadowed, hidden ...),
which switch on/off if they are applied multiple times, e.g. with
paragraph and character styles. To fix that, a hard attribute has to
switch off the attribute in that occasion on import and on export a
hard attribute switches it on in Word.
Includes partial fix for tdf#154370.
Change-Id: Ie4c317cf9b7d02efd89b9d6a9996143585d7e937
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160343
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sw/qa/extras/ooxmlimport')
-rwxr-xr-x | sw/qa/extras/ooxmlimport/data/tdf154370.docx | bin | 0 -> 6333 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 77 |
2 files changed, 77 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf154370.docx b/sw/qa/extras/ooxmlimport/data/tdf154370.docx Binary files differnew file mode 100755 index 000000000000..ba72724593b2 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf154370.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 553fbebbc6e3..0c29484d765e 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -1188,6 +1188,83 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf141969) CPPUNIT_ASSERT_EQUAL(8.0f, getProperty<float>(xRun, "CharHeight")); } +CPPUNIT_TEST_FIXTURE(Test, testTdf154370) +{ + // Import a file with pargraph and character styles containing toggle properties applied to the end of + // the paragraphs. Should result in hard attributes resetting the properties + createSwDoc("tdf154370.docx"); + { + auto xPara(getParagraph(2)); + auto xRun = getRun(xPara, 2); + + OUString rangeText = xRun->getString(); + CPPUNIT_ASSERT_EQUAL(OUString("CharStyle BoldItalicCapsEmbossedStrike"), rangeText); + + const uno::Reference<beans::XPropertyState> xRangePropState(xRun, uno::UNO_QUERY_THROW); + beans::PropertyState ePropertyState = xRangePropState->getPropertyState("CharWeight"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + + ePropertyState = xRangePropState->getPropertyState("CharWeightComplex"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + + ePropertyState = xRangePropState->getPropertyState("CharWeightAsian"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + + ePropertyState = xRangePropState->getPropertyState("CharPosture"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + + ePropertyState = xRangePropState->getPropertyState("CharPostureAsian"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + + ePropertyState = xRangePropState->getPropertyState("CharCaseMap"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + + ePropertyState = xRangePropState->getPropertyState("CharRelief"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + + ePropertyState = xRangePropState->getPropertyState("CharStrikeout"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + } + { + auto xPara(getParagraph(3)); + auto xRun = getRun(xPara, 2); + + OUString rangeText = xRun->getString(); + CPPUNIT_ASSERT_EQUAL(OUString("CharStyle SmallcapsImprint"), rangeText); + + const uno::Reference<beans::XPropertyState> xRangePropState(xRun, uno::UNO_QUERY_THROW); + beans::PropertyState ePropertyState = xRangePropState->getPropertyState("CharCaseMap"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + + ePropertyState = xRangePropState->getPropertyState("CharRelief"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + } + { + auto xPara(getParagraph(5)); + auto xRun = getRun(xPara, 2); + + OUString rangeText = xRun->getString(); + CPPUNIT_ASSERT_EQUAL(OUString("CharStyle Hidden"), rangeText); + + const uno::Reference<beans::XPropertyState> xRangePropState(xRun, uno::UNO_QUERY_THROW); + beans::PropertyState ePropertyState = xRangePropState->getPropertyState("CharHidden"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + } + { + auto xPara(getParagraph(7)); + auto xRun = getRun(xPara, 2); + + OUString rangeText = xRun->getString(); + CPPUNIT_ASSERT_EQUAL(OUString("OutlineShadow"), rangeText); + + const uno::Reference<beans::XPropertyState> xRangePropState(xRun, uno::UNO_QUERY_THROW); + beans::PropertyState ePropertyState = xRangePropState->getPropertyState("CharContoured"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + + ePropertyState = xRangePropState->getPropertyState("CharShadowed"); + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState); + } +} // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT CPPUNIT_PLUGIN_IMPLEMENT(); |