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

Miklos Vajna vmiklos at collabora.co.uk
Wed Sep 3 12:25:24 PDT 2014


 sw/qa/extras/rtfexport/data/picture-wrap-polygon.rtf |   47 +++++++++++++++++++
 sw/qa/extras/rtfexport/rtfexport.cxx                 |   16 ++++++
 sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf |   47 -------------------
 sw/qa/extras/rtfimport/rtfimport.cxx                 |   15 ------
 sw/source/filter/ww8/rtfattributeoutput.cxx          |   27 ++++++++++
 5 files changed, 90 insertions(+), 62 deletions(-)

New commits:
commit f332db6864c1c0f28feb64a7f79b9b4ef3c76b58
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 3 21:09:37 2014 +0200

    RTF export: handle wrap polygon of Writer pictures
    
    Change-Id: I712d8f73466c662659a7b76ff363a44a71bba324

diff --git a/sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf b/sw/qa/extras/rtfexport/data/picture-wrap-polygon.rtf
similarity index 100%
rename from sw/qa/extras/rtfimport/data/picture-wrap-polygon.rtf
rename to sw/qa/extras/rtfexport/data/picture-wrap-polygon.rtf
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 644abaa..63df389 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -14,6 +14,7 @@
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
 #include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/PointSequenceSequence.hpp>
 #include <com/sun/star/frame/XStorable.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/ShadowFormat.hpp>
@@ -664,6 +665,21 @@ DECLARE_RTFEXPORT_TEST(testFdo32613, "fdo32613.odt")
     CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
 }
 
+DECLARE_RTFEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf")
+{
+    // The problem was that the wrap polygon was ignored during import.
+    drawing::PointSequenceSequence aSeqSeq = getProperty<drawing::PointSequenceSequence>(getShape(1), "ContourPolyPolygon");
+    // This was 0: the polygon list was empty.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeqSeq.getLength());
+
+    drawing::PointSequence aSeq = aSeqSeq[0];
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength());
+
+    // The shape also didn't have negative top / left coordinates.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-1177)), getProperty<sal_Int32>(getShape(1), "HoriOrientPosition"));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty<sal_Int32>(getShape(1), "VertOrientPosition"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 64e2b04..b2ed3d9 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1903,21 +1903,6 @@ DECLARE_RTFIMPORT_TEST(testBehindDoc, "behind-doc.rtf")
     CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xShape, "Opaque"));
 }
 
-DECLARE_RTFIMPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf")
-{
-    // The problem was that the wrap polygon was ignored during import.
-    drawing::PointSequenceSequence aSeqSeq = getProperty<drawing::PointSequenceSequence>(getShape(1), "ContourPolyPolygon");
-    // This was 0: the polygon list was empty.
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeqSeq.getLength());
-
-    drawing::PointSequence aSeq = aSeqSeq[0];
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength());
-
-    // The shape also didn't have negative top / left coordinates.
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-1177)), getProperty<sal_Int32>(getShape(1), "HoriOrientPosition"));
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty<sal_Int32>(getShape(1), "VertOrientPosition"));
-}
-
 DECLARE_RTFIMPORT_TEST(testFdo74229, "fdo74229.rtf")
 {
     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 7bd31cb..308e1f2 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -65,6 +65,7 @@
 #include <editeng/blinkitem.hxx>
 #include <editeng/charhiddenitem.hxx>
 #include <editeng/shaditem.hxx>
+#include <editeng/opaqitem.hxx>
 #include <svx/svdmodel.hxx>
 #include <svx/fmglob.hxx>
 #include <svx/svdouno.hxx>
@@ -2866,6 +2867,10 @@ void RtfAttributeOutput::FormatSurround(const SwFmtSurround& rSurround)
             oWrk = 3; // largest
             break;
         }
+
+        if (rSurround.IsContour())
+            nWr = 4; // tight
+
         m_rExport.Strm().WriteCharPtr(OOO_STRING_SVTOOLS_RTF_SHPWR);
         m_rExport.OutLong(nWr);
         if (oWrk)
@@ -3721,6 +3726,28 @@ void RtfAttributeOutput::FlyFrameGraphic(const SwFlyFrmFmt* pFlyFrmFmt, const Sw
         aFlyProperties.push_back(std::make_pair<OString, OString>("shapeType", OString::number(ESCHER_ShpInst_PictureFrame)));
         aFlyProperties.push_back(std::make_pair<OString, OString>("wzDescription", msfilter::rtfutil::OutString(pFlyFrmFmt->GetObjDescription(), m_rExport.eCurrentEncoding)));
         aFlyProperties.push_back(std::make_pair<OString, OString>("wzName", msfilter::rtfutil::OutString(pFlyFrmFmt->GetObjTitle(), m_rExport.eCurrentEncoding)));
+
+        // If we have a wrap polygon, then handle that here.
+        if (pFlyFrmFmt->GetSurround().IsContour())
+        {
+            if (const SwNoTxtNode* pNd = sw::util::GetNoTxtNodeFromSwFrmFmt(*pFlyFrmFmt))
+            {
+                const PolyPolygon* pPolyPoly = pNd->HasContour();
+                if (pPolyPoly && pPolyPoly->Count())
+                {
+                    Polygon aPoly = sw::util::CorrectWordWrapPolygonForExport(*pPolyPoly, pNd);
+                    OStringBuffer aVerticies;
+                    for (sal_uInt16 i = 0; i < aPoly.GetSize(); ++i)
+                        aVerticies.append(";(").append(aPoly[i].X()).append(",").append(aPoly[i].Y()).append(")");
+                    aFlyProperties.push_back(std::make_pair<OString, OString>("pWrapPolygonVertices", "8;" + OString::number(aPoly.GetSize()) + aVerticies.makeStringAndClear()));
+                }
+            }
+        }
+
+        // Below text, behind document, opaque: they all refer to the same thing.
+        if (!pFlyFrmFmt->GetOpaque().GetValue())
+            aFlyProperties.push_back(std::make_pair<OString, OString>("fBehindDocument", "1"));
+
         for (size_t i = 0; i < aFlyProperties.size(); ++i)
         {
             m_rExport.Strm().WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_SP "{");


More information about the Libreoffice-commits mailing list