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@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 0000000..2576966
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf116371.odt
Binary files differ
diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx
index 3d90659..fb5e0b8 100644
--- a/sw/qa/extras/rtfexport/rtfexport5.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport5.cxx
@@ -73,6 +73,14 @@
    }

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 @@
        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 995a43b..52e826a 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -4010,6 +4010,7 @@
       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 @@
        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 @@
    }

    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);