summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTibor Nagy <tibor.nagy.extern@allotropia.de>2024-01-22 11:24:51 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2024-01-29 10:11:45 +0100
commit00dd94eda1e4b46c7f9a53750aa829c31c6830d3 (patch)
tree778d400a5833709ef0e250f24e6d9cb134c4df36
parent13c748e7998b6df02e23815f337e9ab4d04172f3 (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> (cherry picked from commit 27a1eccae1763b8efa17c909820f57f84361d308) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162378 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit 67ae17ad8a74620eb744976d56f8d763893e847c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162386
-rw-r--r--oox/source/drawingml/table/predefined-table-styles.cxx20
-rw-r--r--oox/source/drawingml/table/tablecell.cxx12
-rw-r--r--sd/qa/unit/data/pptx/tdf156718.pptxbin0 -> 14422 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx70
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 513637e3c7ee..919b453368b3 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;
@@ -410,6 +416,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;
@@ -417,6 +424,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.
@@ -557,7 +565,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;
@@ -571,8 +585,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);
@@ -895,6 +907,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 9d16bce09d17..b480a0479ddf 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
new file mode 100644
index 000000000000..8aeafa155762
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf156718.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index adc7c12e4632..85d25f831e83 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");