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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 31 18:14:04 UTC 2019


 sw/qa/extras/rtfexport/data/tdf116371.odt   |binary
 sw/qa/extras/rtfexport/rtfexport5.cxx       |   17 +++++++++++++++++
 sw/source/filter/ww8/rtfattributeoutput.cxx |   15 ++++++++++++++-
 3 files changed, 31 insertions(+), 1 deletion(-)

New commits:
commit d8cf61f39181073da2d8748be74d9dadae79d647
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jan 31 15:37:13 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jan 31 19:13:34 2019 +0100

    Related: tdf#116371 RTF export: handle rotation of SwGrfNode
    
    This is similar to commit b226383a83e41bbced9fc2a02dc09a449401ec97
    (tdf#116371: export rotation of SwGrfNode, 2019-01-26), just this is for
    RTF, not DOCX.
    
    Make sure we don't test the ODT import result as it's done already in
    CppunitTest_sw_ooxmlexport13.
    
    Change-Id: Iaf2d3011c45f3459e920f679683b1a45de42efe7
    Reviewed-on: https://gerrit.libreoffice.org/67218
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/rtfexport/data/tdf116371.odt b/sw/qa/extras/rtfexport/data/tdf116371.odt
new file mode 100644
index 000000000000..257696616e8c
Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf116371.odt differ
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 3d906598e4e9..fb5e0b8f4168 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -73,6 +73,14 @@ public:
     }
 
 protected:
+    /// Blacklist handling.
+    bool mustTestImportOf(const char* filename) const override
+    {
+        // If the testcase is stored in some other format, it's pointless to
+        // test.
+        return OString(filename).endsWith(".rtf");
+    }
+
     AllSettings m_aSavedSettings;
 };
 
@@ -1098,6 +1106,15 @@ DECLARE_RTFEXPORT_TEST(testTdf106950, "tdf106950.rtf")
         static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xPara, "ParaAdjust")));
 }
 
+DECLARE_RTFEXPORT_TEST(testTdf116371, "tdf116371.odt")
+{
+    auto xShape(getShape(1));
+    // Without the accompanying fix in place, this test would have failed with
+    // 'Unknown property: RotateAngle', i.e. export lost the rotation, and then
+    // import created a Writer picture (instead of a Draw one).
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(4700.0, getProperty<double>(xShape, "RotateAngle"), 10);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 995a43bd0a9b..52e826af9d9d 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -4010,6 +4010,7 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
        a wmf already then we don't need any such wrapping
        */
     bool bIsWMF = pBLIPType && std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
+    const SwAttrSet* pAttrSet = pGrfNode->GetpSwAttrSet();
     if (!pFrame || pFrame->IsInline())
     {
         if (!bIsWMF)
@@ -4070,6 +4071,19 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
         if (!pFlyFrameFormat->GetOpaque().GetValue())
             aFlyProperties.push_back(std::make_pair<OString, OString>("fBehindDocument", "1"));
 
+        if (pAttrSet)
+        {
+            if (sal_Int32 nRot = pAttrSet->Get(RES_GRFATR_ROTATION).GetValue())
+            {
+                // See writerfilter::rtftok::RTFSdrImport::applyProperty(),
+                // positive rotation angles are clockwise in RTF, we have them
+                // as counter-clockwise.
+                // Additionally, RTF type is 0..360*2^16, our is 0..360*10.
+                nRot = nRot * -1 * RTF_MULTIPLIER / 10;
+                aFlyProperties.emplace_back("rotation", OString::number(nRot));
+            }
+        }
+
         for (std::pair<OString, OString>& rPair : aFlyProperties)
         {
             m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{");
@@ -4085,7 +4099,6 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrameFormat* pFlyFrameFormat
     }
 
     bool bWritePicProp = !pFrame || pFrame->IsInline();
-    const SwAttrSet* pAttrSet = pGrfNode->GetpSwAttrSet();
     if (pBLIPType)
         ExportPICT(pFlyFrameFormat, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize,
                    m_rExport, &m_rExport.Strm(), bWritePicProp, pAttrSet);


More information about the Libreoffice-commits mailing list