summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatus Uzak <matus.uzak@gmail.com>2016-04-13 02:00:03 +0200
committerKatarina Behrens <Katarina.Behrens@cib.de>2016-04-29 10:57:47 +0000
commitf9c8651506adddad4941fe08e9e76a78d14a9fe0 (patch)
tree0deda8792d2aee0a1f2602e6e2e62fc4de571bfd
parentd6ffb7405d3267f1e76aed7a5e3162b8700f6817 (diff)
tdf#90736: PPTX import: Improved table border line style support
Map preset line dash values from ooxml to the smaller set of LO's predefined table border line styles. Map custom dashing scheme to a simple dashed line style. Change-Id: Ia81d94cb7e20b05f1c2cc0c20c8ad398c5613d6c Reviewed-on: https://gerrit.libreoffice.org/24048 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r--oox/source/drawingml/table/tablecell.cxx42
-rw-r--r--sd/qa/unit/data/pptx/tableBorderLineStyle.pptxbin0 -> 51776 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx48
3 files changed, 89 insertions, 1 deletions
diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx
index 4df26bbc1e41..9a569505aeb1 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/table/XTable.hpp>
#include <com/sun/star/table/XMergeableCellRange.hpp>
+#include <com/sun/star/table/BorderLineStyle.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
@@ -72,7 +73,7 @@ void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase,
sal_Int32 nPropId )
{
BorderLine2 aBorderLine;
- if( rLineProperties.maLineFill.moFillType.differsFrom( XML_noFill ))
+ if ( rLineProperties.maLineFill.moFillType.differsFrom( XML_noFill ))
{
Color aColor = rLineProperties.maLineFill.getBestSolidColor();
aBorderLine.Color = aColor.getColor( rFilterBase.getGraphicHelper() );
@@ -91,6 +92,45 @@ void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase,
aBorderLine.LineDistance = 0;
}
+ if ( rLineProperties.moPresetDash.has() )
+ {
+ switch ( rLineProperties.moPresetDash.get() )
+ {
+ case XML_dot:
+ case XML_sysDot:
+ aBorderLine.LineStyle = ::table::BorderLineStyle::DOTTED;
+ break;
+ case XML_dash:
+ case XML_lgDash:
+ case XML_sysDash:
+ aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED;
+ break;
+ case XML_dashDot:
+ case XML_lgDashDot:
+ case XML_sysDashDot:
+ aBorderLine.LineStyle = ::table::BorderLineStyle::DASH_DOT;
+ break;
+ case XML_lgDashDotDot:
+ case XML_sysDashDotDot:
+ aBorderLine.LineStyle = ::table::BorderLineStyle::DASH_DOT_DOT;
+ break;
+ case XML_solid:
+ aBorderLine.LineStyle = ::table::BorderLineStyle::SOLID;
+ break;
+ default:
+ aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED;
+ break;
+ }
+ }
+ else if ( !rLineProperties.maCustomDash.empty() )
+ {
+ aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED;
+ }
+ else
+ {
+ aBorderLine.LineStyle = ::table::BorderLineStyle::NONE;
+ }
+
PropertySet aPropSet( rxPropSet );
aPropSet.setProperty( nPropId, aBorderLine );
}
diff --git a/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx b/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx
new file mode 100644
index 000000000000..c46b7bcee819
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index da4d4c49db67..a9b7f0df067c 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -56,6 +56,7 @@
#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
#include <com/sun/star/chart2/data/XDataSequence.hpp>
#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
+#include <com/sun/star/table/BorderLineStyle.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
@@ -97,6 +98,7 @@ public:
void testBnc584721_4();
void testBnc904423();
void testShapeLineStyle();
+ void testTableBorderLineStyle();
void testBnc862510_6();
void testBnc862510_7();
#if ENABLE_PDFIMPORT
@@ -143,6 +145,7 @@ public:
CPPUNIT_TEST(testBnc584721_4);
CPPUNIT_TEST(testBnc904423);
CPPUNIT_TEST(testShapeLineStyle);
+ CPPUNIT_TEST(testTableBorderLineStyle);
CPPUNIT_TEST(testBnc862510_6);
CPPUNIT_TEST(testBnc862510_7);
#if ENABLE_PDFIMPORT
@@ -1024,6 +1027,51 @@ void SdImportTest::testShapeLineStyle()
xDocShRef->DoClose();
}
+void SdImportTest::testTableBorderLineStyle()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx"), PPTX );
+
+ // TODO: If you are working on improvement of table border line style
+ // support, then expect this unit test to fail.
+
+ const sal_Int16 nObjBorderLineStyles[] =
+ {
+ ::table::BorderLineStyle::DASHED,
+ ::table::BorderLineStyle::DASH_DOT_DOT,
+ ::table::BorderLineStyle::DASH_DOT,
+ ::table::BorderLineStyle::DOTTED,
+ ::table::BorderLineStyle::DASHED,
+ ::table::BorderLineStyle::DOTTED,
+ ::table::BorderLineStyle::DASHED,
+ ::table::BorderLineStyle::DASH_DOT,
+ ::table::BorderLineStyle::DASH_DOT,
+ ::table::BorderLineStyle::SOLID,
+ ::table::BorderLineStyle::NONE
+ };
+
+ const SdrPage *pPage = GetPage( 1, xDocShRef );
+ CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(nObjBorderLineStyles), pPage->GetObjCount());
+
+ sdr::table::SdrTableObj *pTableObj;
+ uno::Reference< table::XCellRange > xTable;
+ uno::Reference< beans::XPropertySet > xCell;
+ table::BorderLine2 aBorderLine;
+
+ for (size_t i = 0; i < SAL_N_ELEMENTS(nObjBorderLineStyles); i++)
+ {
+ pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(i));
+ CPPUNIT_ASSERT( pTableObj );
+ xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
+ xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
+ xCell->getPropertyValue("TopBorder") >>= aBorderLine;
+ if (aBorderLine.LineWidth > 0) {
+ CPPUNIT_ASSERT_EQUAL(nObjBorderLineStyles[i], aBorderLine.LineStyle);
+ }
+ }
+
+ xDocShRef->DoClose();
+}
+
void SdImportTest::testBnc862510_6()
{
// Black text was imported instead of gray