diff options
author | Tibor Nagy <tibor.nagy.extern@allotropia.de> | 2024-01-22 11:24:51 +0100 |
---|---|---|
committer | Nagy Tibor <tibor.nagy.extern@allotropia.de> | 2024-01-22 13:34:32 +0100 |
commit | 27a1eccae1763b8efa17c909820f57f84361d308 (patch) | |
tree | e3ae31663be705fd21aab4c0f3951d9bf1682318 | |
parent | 0ad94d52c022a0acb20be21b5a1dfcf445e12f0c (diff) |
tdf#156718 PPTX import: fix the different formatting in table style
when the PPTX file only has table style id, but no table style content.
Change-Id: Ia3416478716a50beb6837988e98697fd88e916d9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162368
Tested-by: Jenkins
Reviewed-by: Nagy Tibor <tibor.nagy.extern@allotropia.de>
-rw-r--r-- | oox/source/drawingml/table/predefined-table-styles.cxx | 20 | ||||
-rw-r--r-- | oox/source/drawingml/table/tablecell.cxx | 12 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf156718.pptx | bin | 0 -> 14422 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 70 |
4 files changed, 98 insertions, 4 deletions
diff --git a/oox/source/drawingml/table/predefined-table-styles.cxx b/oox/source/drawingml/table/predefined-table-styles.cxx index 7df96036137d..3e821456e3b3 100644 --- a/oox/source/drawingml/table/predefined-table-styles.cxx +++ b/oox/source/drawingml/table/predefined-table-styles.cxx @@ -231,6 +231,12 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) std::unique_ptr<TableStyle> pTableStyle; pTableStyle.reset(new TableStyle()); + // Text Style definitions for table parts + + bool bFirstRowTextBoldStyle = false; + bool bFirstColTextBoldStyle = false; + bool bLastColTextBoldStyle = false; + // Text Color definitions for table parts ::oox::drawingml::Color wholeTblTextColor; @@ -406,6 +412,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) pWholeTblBottomBorder->moLineWidth = 12700; pWholeTblInsideHBorder->moLineWidth = 12700; pWholeTblInsideVBorder->moLineWidth = 12700; + pFirstRowBottomBorder->moLineWidth = 12700; pWholeTblLeftBorder->moPresetDash = XML_solid; pWholeTblRightBorder->moPresetDash = XML_solid; @@ -413,6 +420,7 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) pWholeTblBottomBorder->moPresetDash = XML_solid; pWholeTblInsideHBorder->moPresetDash = XML_solid; pWholeTblInsideVBorder->moPresetDash = XML_solid; + pFirstRowBottomBorder->moPresetDash = XML_solid; // Start to handle all style groups. @@ -553,7 +561,13 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) setBorderLineType(pFirstRowBottomBorder, XML_solidFill); setBorderLineType(pLastRowTopBorder, XML_solidFill); + bFirstRowTextBoldStyle = true; + bFirstColTextBoldStyle = true; + bLastColTextBoldStyle = true; + wholeTblTextColor.setSchemeClr(XML_tx1); + firstRowTextColor.setSchemeClr(XML_tx1); + lastColTextColor.setSchemeClr(XML_tx1); sal_Int32 accent_val; @@ -567,8 +581,6 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) pFirstRowBottomBorder->maLineFill.maFillColor.setSchemeClr(accent_val); pLastRowTopBorder->maLineFill.maFillColor.setSchemeClr(accent_val); - firstRowTextColor.setSchemeClr(accent_val); - pBand1HFillProperties->maFillColor.setSchemeClr(accent_val); pBand1VFillProperties->maFillColor.setSchemeClr(accent_val); @@ -891,6 +903,10 @@ std::unique_ptr<TableStyle> CreateTableStyle(const OUString& styleId) pTableStyle->getStyleId() = styleId; pTableStyle->getStyleName() = style_name; + pTableStyle->getFirstRow().getTextBoldStyle() = bFirstRowTextBoldStyle; + pTableStyle->getFirstCol().getTextBoldStyle() = bFirstColTextBoldStyle; + pTableStyle->getLastCol().getTextBoldStyle() = bLastColTextBoldStyle; + pTableStyle->getWholeTbl().getTextColor() = wholeTblTextColor; pTableStyle->getFirstRow().getTextColor() = firstRowTextColor; pTableStyle->getFirstCol().getTextColor() = firstColTextColor; diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index 687c987fe242..78ec4f61feeb 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -358,10 +358,18 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, cons } if ( rProperties.isBandRow() ) { + bool bHasFirstColFillColor + = (rProperties.isFirstCol() && rTable.getFirstCol().getFillProperties() + && rTable.getFirstCol().getFillProperties()->maFillColor.isUsed()); + + bool bHasLastColFillColor + = (rProperties.isLastCol() && rTable.getLastCol().getFillProperties() + && rTable.getLastCol().getFillProperties()->maFillColor.isUsed()); + if ( ( !rProperties.isFirstRow() || ( nRow != 0 ) ) && ( !rProperties.isLastRow() || ( nRow != nMaxRow ) ) && - ( !rProperties.isFirstCol() || ( nColumn != 0 ) ) && - ( !rProperties.isLastCol() || ( nColumn != nMaxColumn ) ) ) + ( !rProperties.isFirstCol() || ( nColumn != 0 ) || !bHasFirstColFillColor ) && + ( !rProperties.isLastCol() || ( nColumn != nMaxColumn ) || !bHasLastColFillColor ) ) { sal_Int32 nBand = nRow; if ( rProperties.isFirstRow() ) diff --git a/sd/qa/unit/data/pptx/tdf156718.pptx b/sd/qa/unit/data/pptx/tdf156718.pptx Binary files differnew file mode 100644 index 000000000000..8aeafa155762 --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf156718.pptx diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index c08e44ea2653..d6beee87693b 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -34,6 +34,7 @@ #include <sax/tools/converter.hxx> #include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/presentation/ClickAction.hpp> @@ -203,6 +204,75 @@ CPPUNIT_TEST_FIXTURE(SdImportTest, testDocumentLayout) } } +CPPUNIT_TEST_FIXTURE(SdImportTest, testTableStyle) +{ + createSdImpressDoc("pptx/tdf156718.pptx"); + const SdrPage* pPage = GetPage(1); + + sdr::table::SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0)); + CPPUNIT_ASSERT(pTableObj); + + uno::Reference<table::XCellRange> xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xCellPropSet; + uno::Reference<beans::XPropertySet> xRunPropSet; + uno::Reference<text::XTextRange> xParagraph; + uno::Reference<text::XTextRange> xRun; + table::BorderLine2 aBorderLine; + Color nFillColor, nCharColor; + float nFontWeight; + + xCellPropSet.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW); + xParagraph.set(getParagraphFromShape(0, xCellPropSet)); + xRun.set(getRunFromParagraph(0, xParagraph)); + xRunPropSet.set(xRun, uno::UNO_QUERY_THROW); + xRunPropSet->getPropertyValue("CharColor") >>= nCharColor; + xRunPropSet->getPropertyValue("CharWeight") >>= nFontWeight; + xCellPropSet->getPropertyValue("BottomBorder") >>= aBorderLine; + CPPUNIT_ASSERT_EQUAL(Color(0x000000), nCharColor); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, nFontWeight); + CPPUNIT_ASSERT_EQUAL_MESSAGE("The bottom border is missing!", true, aBorderLine.LineWidth > 0); + + xCellPropSet.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW); + xParagraph.set(getParagraphFromShape(0, xCellPropSet)); + xRun.set(getRunFromParagraph(0, xParagraph)); + xRunPropSet.set(xRun, uno::UNO_QUERY_THROW); + xRunPropSet->getPropertyValue("CharColor") >>= nCharColor; + xRunPropSet->getPropertyValue("CharWeight") >>= nFontWeight; + CPPUNIT_ASSERT_EQUAL(Color(0x000000), nCharColor); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, nFontWeight); + + xCellPropSet.set(xTable->getCellByPosition(2, 0), uno::UNO_QUERY_THROW); + xParagraph.set(getParagraphFromShape(0, xCellPropSet)); + xRun.set(getRunFromParagraph(0, xParagraph)); + xRunPropSet.set(xRun, uno::UNO_QUERY_THROW); + xRunPropSet->getPropertyValue("CharColor") >>= nCharColor; + xRunPropSet->getPropertyValue("CharWeight") >>= nFontWeight; + CPPUNIT_ASSERT_EQUAL(Color(0x000000), nCharColor); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, nFontWeight); + + xCellPropSet.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW); + xParagraph.set(getParagraphFromShape(0, xCellPropSet)); + xRun.set(getRunFromParagraph(0, xParagraph)); + xRunPropSet.set(xRun, uno::UNO_QUERY_THROW); + xRunPropSet->getPropertyValue("CharColor") >>= nCharColor; + xRunPropSet->getPropertyValue("CharWeight") >>= nFontWeight; + xCellPropSet->getPropertyValue("FillColor") >>= nFillColor; + CPPUNIT_ASSERT_EQUAL(Color(0x000000), nCharColor); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, nFontWeight); + CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nFillColor); + + xCellPropSet.set(xTable->getCellByPosition(2, 1), uno::UNO_QUERY_THROW); + xParagraph.set(getParagraphFromShape(0, xCellPropSet)); + xRun.set(getRunFromParagraph(0, xParagraph)); + xRunPropSet.set(xRun, uno::UNO_QUERY_THROW); + xRunPropSet->getPropertyValue("CharColor") >>= nCharColor; + xRunPropSet->getPropertyValue("CharWeight") >>= nFontWeight; + xCellPropSet->getPropertyValue("FillColor") >>= nFillColor; + CPPUNIT_ASSERT_EQUAL(Color(0x000000), nCharColor); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, nFontWeight); + CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nFillColor); +} + CPPUNIT_TEST_FIXTURE(SdImportTest, testFreeformShapeGluePoints) { createSdImpressDoc("pptx/tdf156829.pptx"); |