include/oox/export/shapes.hxx |    2 +
 oox/source/export/shapes.cxx  |   68 ++++++++++++------------------------------
 2 files changed, 22 insertions(+), 48 deletions(-)

New commits:
commit 23d6c908e6af6d02101edbf0246099e89f95cc7e
Author: Justin Luth <justin.l...@collabora.com>
Date:   Tue Jun 19 11:02:07 2018 +0300

    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.gran...@collabora.co.uk>
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    (cherry picked from commit 3ef18b28ade43a38bb46a2400e4e81a9ae8796bc)
    Reviewed-on: https://gerrit.libreoffice.org/56137

diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx
index 5c1d7d860ca7..e56bd570512c 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>
@@ -216,6 +217,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 c52c6a62b3cb..6e4442502b5d 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>
@@ -1748,68 +1747,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 )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to