diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2022-10-28 12:20:49 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2022-10-31 11:49:11 +0100 |
commit | 6f32f1a12be06c4da92b807d8a35cb079984e26a (patch) | |
tree | 30ce1f7048b6460b205e56c93e3a64a748c6cffe /sd/qa | |
parent | 1dc8b2b9ce4c5cee03c5fec49658fa363a00341b (diff) |
tdf#72238 xmloff,sd: Import of <style:table-cell-properties>
Handles fo:border*, fo:padding*, fo:background-color and
style:vertical-align attributes.
Export is unchanged for now, as older versions still
can't read this, and on the other hand we probably want
to keep the import of the wrong attributes for the long
term, to not break existing documents. Also, we can't
fully export fill properties anyway because of tdf#103602.
Change-Id: I8687507b98602ffcd05adb2087c894bb45aa3c6c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142058
Tested-by: Jenkins
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'sd/qa')
-rw-r--r-- | sd/qa/unit/data/odg/tablestyles.fodg | 34 | ||||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 35 |
2 files changed, 69 insertions, 0 deletions
diff --git a/sd/qa/unit/data/odg/tablestyles.fodg b/sd/qa/unit/data/odg/tablestyles.fodg new file mode 100644 index 000000000000..7b54e73955f9 --- /dev/null +++ b/sd/qa/unit/data/odg/tablestyles.fodg @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.graphics"> + <office:scripts/> + <office:font-face-decls/> + <office:automatic-styles> + <style:page-layout style:name="PM0"> + <style:page-layout-properties fo:margin-top="1cm" fo:margin-bottom="1cm" fo:margin-left="1cm" fo:margin-right="1cm" fo:page-width="21.59cm" fo:page-height="27.94cm" style:print-orientation="portrait"/> + </style:page-layout> + <style:style style:name="dp1" style:family="drawing-page"> + <style:drawing-page-properties draw:background-size="border" draw:fill="none"/> + </style:style> + <style:style style:name="dp2" style:family="drawing-page"/> + <style:style style:name="ce1" style:family="table-cell"> + <style:table-cell-properties fo:background-color="#ffcc99" fo:border="4.51pt solid #99ccff" fo:padding="0.3cm" style:vertical-align="middle"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Default" style:page-layout-name="PM0" draw:style-name="dp1"/> + </office:master-styles> + <office:body> + <office:drawing> + <draw:page draw:name="page1" draw:style-name="dp2" draw:master-page-name="Default"> + <draw:frame svg:width="14.098cm" svg:height="1.998cm" svg:x="3.448cm" svg:y="13.89cm"> + <table:table> + <table:table-column/> + <table:table-row> + <table:table-cell table:style-name="ce1"/> + </table:table-row> + </table:table> + </draw:frame> + </draw:page> + </office:drawing> + </office:body> +</office:document> diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 1a4060731387..f219e936ca9f 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/drawing/BitmapMode.hpp> #include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XMasterPagesSupplier.hpp> @@ -95,6 +96,7 @@ public: void testMasterPageBackgroundFullSize(); void testColumnsODG(); void testTdf112126(); + void testCellProperties(); CPPUNIT_TEST_SUITE(SdExportTest); @@ -143,6 +145,7 @@ public: CPPUNIT_TEST(testMasterPageBackgroundFullSize); CPPUNIT_TEST(testColumnsODG); CPPUNIT_TEST(testTdf112126); + CPPUNIT_TEST(testCellProperties); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -1994,6 +1997,38 @@ void SdExportTest::testTdf112126() xDocShRef->DoClose(); } +void SdExportTest::testCellProperties() +{ + auto xDocShRef + = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odg/tablestyles.fodg"), FODG); + utl::TempFileNamed tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), ODG, &tempFile); + + const SdrPage* pPage = GetPage(1, xDocShRef); + auto pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0)); + CPPUNIT_ASSERT(pTableObj != nullptr); + uno::Reference<beans::XPropertySet> xCell(pTableObj->getTable()->getCellByPosition(0, 0), + uno::UNO_QUERY_THROW); + + Color nColor; + table::BorderLine2 aBorderLine; + drawing::TextVerticalAdjust aTextAdjust; + sal_Int32 nPadding; + + xCell->getPropertyValue("FillColor") >>= nColor; + CPPUNIT_ASSERT_EQUAL(Color(0xffcc99), nColor); + xCell->getPropertyValue("RightBorder") >>= aBorderLine; + CPPUNIT_ASSERT_EQUAL(Color(0x99ccff), Color(ColorTransparency, aBorderLine.Color)); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aBorderLine.LineWidth); + xCell->getPropertyValue("TextRightDistance") >>= nPadding; + CPPUNIT_ASSERT_EQUAL(sal_Int32(300), nPadding); + xCell->getPropertyValue("TextVerticalAdjust") >>= aTextAdjust; + CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust::TextVerticalAdjust_CENTER, aTextAdjust); + + xDocShRef->DoClose(); + tempFile.EnableKillingFile(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); |