[Libreoffice-commits] core.git: sw/qa sw/source

Adam Co rattles2013 at gmail.com
Thu Nov 14 07:30:37 PST 2013


 sw/qa/extras/ooxmlexport/data/fdo65295.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   55 +++++++++++++++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   11 +++++
 3 files changed, 66 insertions(+)

New commits:
commit 1a466b8a3bc178436b41351dd277840872764446
Author: Adam Co <rattles2013 at gmail.com>
Date:   Tue Nov 12 16:32:30 2013 +0200

    fdo#65295 - add export of text-box gradient fill angle
    
    Currently - the angle of the gradient fill of a text-box was not
    being exported. This resulted in the gradient always being a horizontal
    gradient. This patch fixes that and exports the angle.
    
    Conflicts:
    	sw/qa/extras/ooxmlexport/ooxmlexport.cxx
    Reviewed on:
    	https://gerrit.libreoffice.org/6653
    
    Change-Id: I1da60a8e82705097e9e699549d3828375967e744

diff --git a/sw/qa/extras/ooxmlexport/data/fdo65295.docx b/sw/qa/extras/ooxmlexport/data/fdo65295.docx
new file mode 100644
index 0000000..3cc790e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo65295.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 12abe5b..b622cb2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1728,6 +1728,61 @@ DECLARE_OOXML_TEST(testHyperlineIsEnd, "hyperlink.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:hyperlink",1);
 }
 
+DECLARE_OOXML_TEST(testTextBoxGradientAngle, "fdo65295.docx")
+{
+    uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xIndexAccess->getCount());
+
+    // Angle of frame#1 is 135 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
+    uno::Reference<beans::XPropertySet> xFrame1(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame1, "FillStyle"));
+    awt::Gradient aGradient1 = getProperty<awt::Gradient>(xFrame1, "FillGradient");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(135 * 10), aGradient1.Angle);
+
+    // Angle of frame#2 is 180 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
+    uno::Reference<beans::XPropertySet> xFrame2(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame2, "FillStyle"));
+    awt::Gradient aGradient2 = getProperty<awt::Gradient>(xFrame2, "FillGradient");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(180 * 10), aGradient2.Angle);
+
+    // Angle of frame#3 is  90 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
+    uno::Reference<beans::XPropertySet> xFrame3(xIndexAccess->getByIndex(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame3, "FillStyle"));
+    awt::Gradient aGradient3 = getProperty<awt::Gradient>(xFrame3, "FillGradient");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16( 90 * 10), aGradient3.Angle);
+
+    // Angle of frame#4 is 225 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
+    uno::Reference<beans::XPropertySet> xFrame4(xIndexAccess->getByIndex(3), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame4, "FillStyle"));
+    awt::Gradient aGradient4 = getProperty<awt::Gradient>(xFrame4, "FillGradient");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(225 * 10), aGradient4.Angle);
+
+    // Angle of frame#5 is 270 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
+    uno::Reference<beans::XPropertySet> xFrame5(xIndexAccess->getByIndex(4), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame5, "FillStyle"));
+    awt::Gradient aGradient5 = getProperty<awt::Gradient>(xFrame5, "FillGradient");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(270 * 10), aGradient5.Angle);
+
+    // Angle of frame#6 is 315 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
+    uno::Reference<beans::XPropertySet> xFrame6(xIndexAccess->getByIndex(5), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame6, "FillStyle"));
+    awt::Gradient aGradient6 = getProperty<awt::Gradient>(xFrame6, "FillGradient");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(315 * 10), aGradient6.Angle);
+
+    // Angle of frame#7 is   0 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
+    uno::Reference<beans::XPropertySet> xFrame7(xIndexAccess->getByIndex(6), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame7, "FillStyle"));
+    awt::Gradient aGradient7 = getProperty<awt::Gradient>(xFrame7, "FillGradient");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(  0 * 10), aGradient7.Angle);
+
+    // Angle of frame#8 is  45 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
+    uno::Reference<beans::XPropertySet> xFrame8(xIndexAccess->getByIndex(7), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame8, "FillStyle"));
+    awt::Gradient aGradient8 = getProperty<awt::Gradient>(xFrame8, "FillGradient");
+    CPPUNIT_ASSERT_EQUAL(sal_Int16( 45 * 10), aGradient8.Angle);
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 6f22fdc..54e0a5f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -5899,6 +5899,17 @@ void DocxAttributeOutput::FormatFillGradient( const XFillGradientItem& rFillGrad
         OString sStartColor = msfilter::util::ConvertColor(rGradient.GetStartColor());
         OString sEndColor = msfilter::util::ConvertColor(rGradient.GetEndColor());
 
+        // Calculate the angle that was originally in the imported DOCX file
+        // (reverse calculate the angle that was converted in the file
+        //     /oox/source/vml/vmlformatting.cxx :: FillModel::pushToPropMap
+        // and also in
+        //     /oox/source/drawingml/fillproperties.cxx :: FillProperties::pushToPropMap
+        sal_Int32 nReverseAngle = 4500 - rGradient.GetAngle();
+        nReverseAngle = nReverseAngle / 10;
+        nReverseAngle = (270 - nReverseAngle) % 360;
+        if (nReverseAngle != 0)
+            m_pFlyFillAttrList->add(XML_angle, OString::number(nReverseAngle));
+
         OString sColor1 = sStartColor;
         OString sColor2 = sEndColor;
 


More information about the Libreoffice-commits mailing list