summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-09-22 11:59:14 +0200
committerMatúš Kukan <matus.kukan@collabora.com>2014-09-26 08:23:33 +0200
commit18898e13fda25fe6dc85318dd0711355c7b2cc26 (patch)
tree8e33714a6a6eb33ace06d9e8f586f28dd0968289
parentdf73f4115cfe4d07e4159adf087571687eb173ec (diff)
bnc#897769: OOXML import: Import border lines using reference too.
Do not ignore 'lnRef' element. Also fix typo to apply 'seCell' properties to the right cell (southeast). Change-Id: Ia45f7016f358b70e6db06a232c569335ce9d7051
-rw-r--r--oox/source/drawingml/table/tablecell.cxx55
-rw-r--r--sd/qa/unit/import-tests.cxx12
2 files changed, 45 insertions, 22 deletions
diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx
index 96cb28c47e93..45486fd16377 100644
--- a/oox/source/drawingml/table/tablecell.cxx
+++ b/oox/source/drawingml/table/tablecell.cxx
@@ -84,15 +84,26 @@ void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase,
aPropSet.setProperty( nPropId, aBorderLine );
}
-void applyBorder( TableStylePart& rTableStylePart, sal_Int32 nLineType, oox::drawingml::LineProperties& rLineProperties )
+void applyBorder( const ::oox::core::XmlFilterBase& rFilterBase, TableStylePart& rTableStylePart, sal_Int32 nLineType, oox::drawingml::LineProperties& rLineProperties )
{
std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >& rPartLineBorders( rTableStylePart.getLineBorders() );
+ ::oox::drawingml::ShapeStyleRef& rLineStyleRef = rTableStylePart.getStyleRefs()[ nLineType ];
std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >::const_iterator aIter( rPartLineBorders.find( nLineType ) );
if ( ( aIter != rPartLineBorders.end() ) && aIter->second.get() )
rLineProperties.assignUsed( *aIter->second );
+ else if (rLineStyleRef.mnThemedIdx != 0)
+ {
+ if (const Theme* pTheme = rFilterBase.getCurrentTheme())
+ {
+ rLineProperties.assignUsed( *pTheme->getLineStyle(rLineStyleRef.mnThemedIdx) );
+ sal_Int32 nPhClr = rLineStyleRef.maPhClr.getColor( rFilterBase.getGraphicHelper() );
+ rLineProperties.maLineFill.maFillColor.setSrgbClr( nPhClr );
+ }
+ }
}
-void applyTableStylePart( oox::drawingml::FillProperties& rFillProperties,
+void applyTableStylePart( const ::oox::core::XmlFilterBase& rFilterBase,
+ oox::drawingml::FillProperties& rFillProperties,
TextCharacterProperties& aTextCharProps,
oox::drawingml::LineProperties& rLeftBorder,
oox::drawingml::LineProperties& rRightBorder,
@@ -106,12 +117,12 @@ void applyTableStylePart( oox::drawingml::FillProperties& rFillProperties,
if ( rPartFillPropertiesPtr.get() )
rFillProperties.assignUsed( *rPartFillPropertiesPtr );
- applyBorder( rTableStylePart, XML_left, rLeftBorder );
- applyBorder( rTableStylePart, XML_right, rRightBorder );
- applyBorder( rTableStylePart, XML_top, rTopBorder );
- applyBorder( rTableStylePart, XML_bottom, rBottomBorder );
- applyBorder( rTableStylePart, XML_tl2br, rTopLeftToBottomRightBorder );
- applyBorder( rTableStylePart, XML_tr2bl, rBottomLeftToTopRightBorder );
+ applyBorder( rFilterBase, rTableStylePart, XML_left, rLeftBorder );
+ applyBorder( rFilterBase, rTableStylePart, XML_right, rRightBorder );
+ applyBorder( rFilterBase, rTableStylePart, XML_top, rTopBorder );
+ applyBorder( rFilterBase, rTableStylePart, XML_bottom, rBottomBorder );
+ applyBorder( rFilterBase, rTableStylePart, XML_tl2br, rTopLeftToBottomRightBorder );
+ applyBorder( rFilterBase, rTableStylePart, XML_tr2bl, rBottomLeftToTopRightBorder );
aTextCharProps.maLatinFont = rTableStylePart.getLatinFont();
aTextCharProps.maAsianFont = rTableStylePart.getAsianFont();
@@ -171,7 +182,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
oox::drawingml::LineProperties aLinePropertiesTopLeftToBottomRight;
oox::drawingml::LineProperties aLinePropertiesBottomLeftToTopRight;
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -182,7 +193,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
if ( rProperties.isFirstRow() && ( nRow == 0 ) )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -193,7 +204,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
}
if ( rProperties.isLastRow() && ( nRow == nMaxRow ) )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -204,7 +215,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
}
if ( rProperties.isFirstCol() && ( nColumn == 0 ) )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -215,7 +226,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
}
if ( rProperties.isLastCol() && ( nColumn == nMaxColumn ) )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -236,7 +247,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
nBand++;
if ( nBand & 1 )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -247,7 +258,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
}
else
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -260,7 +271,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
}
if ( ( nRow == 0 ) && ( nColumn == 0 ) )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -271,7 +282,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
}
if ( ( nRow == nMaxRow ) && ( nColumn == 0 ) )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -282,7 +293,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
}
if ( ( nRow == 0 ) && ( nColumn == nMaxColumn ) )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -291,9 +302,9 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
aLinePropertiesBottomLeftToTopRight,
rTable.getNeCell() );
}
- if ( ( nRow == nMaxColumn ) && ( nColumn == nMaxColumn ) )
+ if ( ( nRow == nMaxRow ) && ( nColumn == nMaxColumn ) )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -314,7 +325,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
nBand++;
if ( nBand & 1 )
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
@@ -325,7 +336,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo
}
else
{
- applyTableStylePart( aFillProperties, aTextStyleProps,
+ applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
aLinePropertiesLeft,
aLinePropertiesRight,
aLinePropertiesTop,
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 6bc206a5b304..c654acbf28ac 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -49,6 +49,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/BorderLine2.hpp>
#include <stlpool.hxx>
@@ -689,6 +690,7 @@ void SdFiltersTest::testBnc480256()
uno::Reference< table::XCellRange > xTable;
uno::Reference< beans::XPropertySet > xCell;
sal_Int32 nColor;
+ table::BorderLine2 aBorderLine;
pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
CPPUNIT_ASSERT( pTableObj );
@@ -697,10 +699,14 @@ void SdFiltersTest::testBnc480256()
xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("FillColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(10208238), nColor);
+ xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
+ CPPUNIT_ASSERT_EQUAL(util::Color(5609427), aBorderLine.Color);
xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("FillColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(13032959), nColor);
+ xCell->getPropertyValue("TopBorder") >>= aBorderLine;
+ CPPUNIT_ASSERT_EQUAL(util::Color(5609427), aBorderLine.Color);
pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(1));
CPPUNIT_ASSERT( pTableObj );
@@ -709,11 +715,17 @@ void SdFiltersTest::testBnc480256()
xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("FillColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(7056614), nColor);
+ xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
+ CPPUNIT_ASSERT_EQUAL(util::Color(12505062), aBorderLine.Color);
xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
xCell->getPropertyValue("FillColor") >>= nColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(4626400), nColor);
+ xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
+ xCell->getPropertyValue("BottomBorder") >>= aBorderLine;
+ CPPUNIT_ASSERT_EQUAL(util::Color(0), aBorderLine.Color);
+
xDocShRef->DoClose();
}