summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-03-16 18:05:01 +0100
committerLászló Németh <nemeth@numbertext.org>2019-03-18 16:38:55 +0100
commit0dac43445b35da7e554dd4d7574c59611a0d0be1 (patch)
tree25cac121065fa662701be54cfa4971d4f5e88714
parentcf89d6dbfd72e60e459b2ffef313a6d8b477857b (diff)
tdf#81437 XLSX import: fix missing chart border
of MSO 2007/2010 documents with "automatic" chart area formatting, setting also the default 0.75 pt border width and light gray border color. Note: MSO 2007/2010 and MSO 2013/2016 have different "automatic" border colors. This fix uses the last, light gray version instead of the dark one. Change-Id: I579f3745d5fcb2a36e1b4d519320631d20e60fd4 Reviewed-on: https://gerrit.libreoffice.org/69341 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--chart2/qa/extras/chart2import.cxx23
-rwxr-xr-xchart2/qa/extras/data/xlsx/chart-area-style-border.xlsxbin0 -> 12006 bytes
-rw-r--r--include/oox/helper/graphichelper.hxx6
-rw-r--r--oox/source/drawingml/chart/objectformatter.cxx17
-rw-r--r--oox/source/helper/graphichelper.cxx11
5 files changed, 53 insertions, 4 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 0d8eda002a3b..2172493e654e 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -19,6 +19,7 @@
#include <com/sun/star/chart2/XInternalDataProvider.hpp>
#include <com/sun/star/chart/XChartDataArray.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/chart/XAxisXSupplier.hpp>
#include <com/sun/star/chart/MissingValueTreatment.hpp>
#include <com/sun/star/chart2/TickmarkStyle.hpp>
@@ -70,6 +71,7 @@ public:
void testTdf106217();
void testTdf108021();
void testAutoBackgroundXLSX();
+ void testAutoChartAreaBorderPropXLSX();
void testChartAreaStyleBackgroundXLSX();
void testChartHatchFillXLSX();
void testAxisTextRotationXLSX();
@@ -155,6 +157,7 @@ public:
CPPUNIT_TEST(testTdf106217);
CPPUNIT_TEST(testTdf108021);
CPPUNIT_TEST(testAutoBackgroundXLSX);
+ CPPUNIT_TEST(testAutoChartAreaBorderPropXLSX);
CPPUNIT_TEST(testChartAreaStyleBackgroundXLSX);
CPPUNIT_TEST(testChartHatchFillXLSX);
CPPUNIT_TEST(testAxisTextRotationXLSX);
@@ -920,6 +923,26 @@ void Chart2ImportTest::testAutoBackgroundXLSX()
sal_Int32(0x00FFFFFF), sal_Int32(nColor & 0x00FFFFFF)); // highest 2 bytes are transparency which we ignore here.
}
+void Chart2ImportTest::testAutoChartAreaBorderPropXLSX()
+{
+ load("/chart2/qa/extras/data/xlsx/", "chart-area-style-border.xlsx");
+ uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+ CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc.is());
+
+ // Test "Automatic" chartarea border style/color/width.
+ Reference<beans::XPropertySet> xPropSet = xChartDoc->getPageBackground();
+ CPPUNIT_ASSERT(xPropSet.is());
+ drawing::LineStyle eStyle = xPropSet->getPropertyValue("LineStyle").get<drawing::LineStyle>();
+ sal_Int32 nColor = xPropSet->getPropertyValue("LineColor").get<sal_Int32>();
+ sal_Int32 nWidth = xPropSet->getPropertyValue("LineWidth").get<sal_Int32>();
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border should be loaded as solid style.",
+ drawing::LineStyle_SOLID, eStyle);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border color should be loaded as light gray.",
+ sal_Int32(0xD9D9D9), nColor);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("'Automatic' chartarea border width should be loaded as 0.75 pt (~0.026 cm)",
+ sal_Int32(26), nWidth);
+}
+
void Chart2ImportTest::testChartAreaStyleBackgroundXLSX()
{
load("/chart2/qa/extras/data/xlsx/", "chart-area-style-background.xlsx");
diff --git a/chart2/qa/extras/data/xlsx/chart-area-style-border.xlsx b/chart2/qa/extras/data/xlsx/chart-area-style-border.xlsx
new file mode 100755
index 000000000000..81a6a6e606bb
--- /dev/null
+++ b/chart2/qa/extras/data/xlsx/chart-area-style-border.xlsx
Binary files differ
diff --git a/include/oox/helper/graphichelper.hxx b/include/oox/helper/graphichelper.hxx
index 0f277ca98fd0..a3db628ee361 100644
--- a/include/oox/helper/graphichelper.hxx
+++ b/include/oox/helper/graphichelper.hxx
@@ -73,6 +73,12 @@ public:
virtual sal_Int32 getDefaultChartAreaFillStyle() const;
+ /** Returns chartspace automatic default border style */
+ virtual sal_Int32 getDefaultChartAreaLineStyle() const;
+
+ /** Returns chartspace automatic default border width in Emu */
+ virtual sal_Int16 getDefaultChartAreaLineWidth() const;
+
// Device info and device dependent unit conversion -----------------------
/** Returns information about the output device. */
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index 5b576d824ba3..f97bd780bf3e 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -600,7 +600,8 @@ class LineFormatter : public DetailFormatterBase
public:
explicit LineFormatter(
ObjectFormatterData& rData,
- const AutoFormatEntry* pAutoFormatEntry );
+ const AutoFormatEntry* pAutoFormatEntry,
+ const ObjectType eObjType );
/** Converts line formatting to the passed property set. */
void convertFormatting(
@@ -809,8 +810,8 @@ DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const Auto
return aColor.getColor( mrData.mrFilter.getGraphicHelper() );
}
-LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
- DetailFormatterBase( rData, pAutoFormatEntry )
+LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, const ObjectType eObjType ) :
+ DetailFormatterBase(rData, pAutoFormatEntry)
{
if( pAutoFormatEntry )
{
@@ -819,6 +820,14 @@ LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry*
if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
if( const LineProperties* pLineProps = pTheme->getLineStyle( pAutoFormatEntry->mnThemedIdx ) )
*mxAutoLine = *pLineProps;
+ // set automatic border property for chartarea, because of tdf#81437 and tdf#82217
+ if ( eObjType == OBJECTTYPE_CHARTSPACE )
+ {
+ mxAutoLine->maLineFill.moFillType = rData.mrFilter.getGraphicHelper().getDefaultChartAreaLineStyle();
+ mxAutoLine->moLineWidth = rData.mrFilter.getGraphicHelper().getDefaultChartAreaLineWidth();
+ // this value is what MSO 2016 use as a default color for chartspace border
+ mxAutoLine->maLineFill.maFillColor.setSrgbClr( 0xD9D9D9 );
+ }
// change line width according to chart auto style
if( mxAutoLine->moLineWidth.has() )
mxAutoLine->moLineWidth = mxAutoLine->moLineWidth.get() * pAutoFormatEntry->mnRelLineWidth / 100;
@@ -918,7 +927,7 @@ void TextFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Te
}
ObjectTypeFormatter::ObjectTypeFormatter( ObjectFormatterData& rData, const ObjectTypeFormatEntry& rEntry, const ChartSpaceModel& rChartSpace, const ObjectType eObjType ) :
- maLineFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoLines, rChartSpace.mnStyle ) ),
+ maLineFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoLines, rChartSpace.mnStyle ), eObjType ),
maFillFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoFills, rChartSpace.mnStyle ), eObjType ),
maTextFormatter( rData, lclGetAutoTextEntry( rEntry.mpAutoTexts, rChartSpace.mnStyle ), rChartSpace.mxTextProp ),
mrModelObjHelper( rData.maModelObjHelper ),
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index ee2b44b3b98f..b720aeab8746 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -165,6 +165,17 @@ sal_Int32 GraphicHelper::getDefaultChartAreaFillStyle() const
return XML_solidFill;
}
+sal_Int32 GraphicHelper::getDefaultChartAreaLineStyle() const
+{
+ return XML_solidFill;
+}
+
+sal_Int16 GraphicHelper::getDefaultChartAreaLineWidth() const
+{
+ // this value is what MSO 2016 writes fixing incomplete MSO 2010 documents (0.75 pt in emu)
+ return 9525;
+}
+
// Device info and device dependent unit conversion ---------------------------
sal_Int32 GraphicHelper::convertScreenPixelXToHmm( double fPixelX ) const