diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-06-19 11:02:07 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2018-06-20 04:57:10 +0200 |
commit | 3ef18b28ade43a38bb46a2400e4e81a9ae8796bc (patch) | |
tree | b38c548693b5652d33c00b302ad03018c23ffb0c | |
parent | 423f87128e08035a11b84138c1dc9ca63f4d33b2 (diff) |
NFC oox export shape: move replicated code into function
Change-Id: I1d306769bee8390626b513c63c5b889ba3d3d3d6
Reviewed-on: https://gerrit.libreoffice.org/56083
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Justin Luth <justin_luth@sil.org>
-rw-r--r-- | include/oox/export/shapes.hxx | 2 | ||||
-rw-r--r-- | oox/source/export/shapes.cxx | 68 |
2 files changed, 22 insertions, 48 deletions
diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx index 6e5839d93bdc..aa0ca2cd1a62 100644 --- a/include/oox/export/shapes.hxx +++ b/include/oox/export/shapes.hxx @@ -25,6 +25,7 @@ #include <unordered_map> #include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/uno/Reference.hxx> #include <oox/dllapi.h> #include <oox/export/drawingml.hxx> @@ -215,6 +216,7 @@ public: void WriteTableCellProperties(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet); + void WriteBorderLine(const sal_Int32 XML_line, const css::table::BorderLine2& rBorderLine); void WriteTableCellBorders(const css::uno::Reference< css::beans::XPropertySet >& rXPropSet); sal_Int32 GetNewShapeID( const css::uno::Reference< css::drawing::XShape >& rShape ); diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 2c8564b0d335..7b51e62b0059 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -76,7 +76,6 @@ #include <com/sun/star/table/XMergeableCell.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/table/BorderLine2.hpp> #include <tools/stream.hxx> #include <tools/globname.hxx> #include <comphelper/classids.hxx> @@ -1746,68 +1745,41 @@ void ShapeExport::WriteTableCellProperties(const Reference< XPropertySet>& xCell mpFS->endElementNS( XML_a, XML_tcPr ); } -void ShapeExport::WriteTableCellBorders(const Reference< XPropertySet>& xCellPropSet) +void ShapeExport::WriteBorderLine(const sal_Int32 XML_line, const BorderLine2& rBorderLine) { - BorderLine2 aBorderLine; - -// lnL - Left Border Line Properties of table cell - xCellPropSet->getPropertyValue("LeftBorder") >>= aBorderLine; - sal_Int32 nLeftBorder = aBorderLine.LineWidth; - util::Color aLeftBorderColor = aBorderLine.Color; - // While importing the table cell border line width, it converts EMU->Hmm then divided result by 2. // To get original value of LineWidth need to multiple by 2. - nLeftBorder = nLeftBorder*2; - nLeftBorder = oox::drawingml::convertHmmToEmu( nLeftBorder ); + sal_Int32 nBorderWidth = rBorderLine.LineWidth; + nBorderWidth *= 2; + nBorderWidth = oox::drawingml::convertHmmToEmu( nBorderWidth ); - if(nLeftBorder > 0) + if ( nBorderWidth > 0 ) { - mpFS->startElementNS( XML_a, XML_lnL, XML_w, I32S(nLeftBorder), FSEND ); - DrawingML::WriteSolidFill(::Color(aLeftBorderColor)); - mpFS->endElementNS( XML_a, XML_lnL ); + mpFS->startElementNS( XML_a, XML_line, XML_w, I32S(nBorderWidth), FSEND ); + DrawingML::WriteSolidFill( ::Color(rBorderLine.Color) ); + mpFS->endElementNS( XML_a, XML_line ); } +} + +void ShapeExport::WriteTableCellBorders(const Reference< XPropertySet>& xCellPropSet) +{ + BorderLine2 aBorderLine; + +// lnL - Left Border Line Properties of table cell + xCellPropSet->getPropertyValue("LeftBorder") >>= aBorderLine; + WriteBorderLine( XML_lnL, aBorderLine ); // lnR - Right Border Line Properties of table cell xCellPropSet->getPropertyValue("RightBorder") >>= aBorderLine; - sal_Int32 nRightBorder = aBorderLine.LineWidth; - util::Color aRightBorderColor = aBorderLine.Color; - nRightBorder = nRightBorder * 2 ; - nRightBorder = oox::drawingml::convertHmmToEmu( nRightBorder ); - - if(nRightBorder > 0) - { - mpFS->startElementNS( XML_a, XML_lnR, XML_w, I32S(nRightBorder), FSEND); - DrawingML::WriteSolidFill(::Color(aRightBorderColor)); - mpFS->endElementNS( XML_a, XML_lnR); - } + WriteBorderLine( XML_lnR, aBorderLine ); // lnT - Top Border Line Properties of table cell xCellPropSet->getPropertyValue("TopBorder") >>= aBorderLine; - sal_Int32 nTopBorder = aBorderLine.LineWidth; - util::Color aTopBorderColor = aBorderLine.Color; - nTopBorder = nTopBorder * 2; - nTopBorder = oox::drawingml::convertHmmToEmu( nTopBorder ); - - if(nTopBorder > 0) - { - mpFS->startElementNS( XML_a, XML_lnT, XML_w, I32S(nTopBorder), FSEND); - DrawingML::WriteSolidFill(::Color(aTopBorderColor)); - mpFS->endElementNS( XML_a, XML_lnT); - } + WriteBorderLine( XML_lnT, aBorderLine ); // lnB - Bottom Border Line Properties of table cell xCellPropSet->getPropertyValue("BottomBorder") >>= aBorderLine; - sal_Int32 nBottomBorder = aBorderLine.LineWidth; - util::Color aBottomBorderColor = aBorderLine.Color; - nBottomBorder = nBottomBorder * 2; - nBottomBorder = oox::drawingml::convertHmmToEmu( nBottomBorder ); - - if(nBottomBorder > 0) - { - mpFS->startElementNS( XML_a, XML_lnB, XML_w, I32S(nBottomBorder), FSEND); - DrawingML::WriteSolidFill(::Color(aBottomBorderColor)); - mpFS->endElementNS( XML_a, XML_lnB); - } + WriteBorderLine( XML_lnB, aBorderLine ); } ShapeExport& ShapeExport::WriteTableShape( const Reference< XShape >& xShape ) |