[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Jun 17 17:28:22 UTC 2016


 sw/qa/extras/rtfimport/data/flip.rtf        |   96 +++++
 sw/qa/extras/rtfimport/data/tdf91684.rtf    |  460 ++++++++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx        |   27 +
 writerfilter/source/rtftok/rtfsdrimport.cxx |   24 +
 4 files changed, 606 insertions(+), 1 deletion(-)

New commits:
commit 6a10ad7145c0d77a8e9cf2481f2527a5c4d32173
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jun 16 09:13:04 2016 +0200

    tdf#91684 RTF import: handle fFlipH and fFlipV shape props
    
    Also:
    
    Related: tdf#91684 RTF import: fix scaling of group shape children
    
    It was assumed that the child size is in twips, but it's in relative
    coordinates.
    
    (cherry picked from commits c3acc06230169f141930945ebbff43b1a88dfdee and
    63965d7dc571c7dce999980737f9d57a7c5151da)
    
    Change-Id: I930f99647de00c2e43ef94b1ac0320daa440eae9
    Reviewed-on: https://gerrit.libreoffice.org/26430
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/rtfimport/data/flip.rtf b/sw/qa/extras/rtfimport/data/flip.rtf
new file mode 100644
index 0000000..84e9c2c
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/flip.rtf
@@ -0,0 +1,96 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+\pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0
+\f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid12721412
+{\shp
+{\*\shpinst\shpleft537\shptop201\shpright2361\shpbottom1136\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 6}
+}
+{\sp
+{\sn fFlipH}
+{\sv 1}
+}
+{\sp
+{\sn fFlipV}
+{\sv 1}
+}
+{\sp
+{\sn wzName}
+{\sv h-and-v}
+}
+}
+{\shprslt
+}
+}
+{\shp
+{\*\shpinst\shpleft537\shptop1201\shpright2361\shpbottom2136\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 6}
+}
+{\sp
+{\sn fFlipH}
+{\sv 1}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn wzName}
+{\sv h-only}
+}
+}
+{\shprslt
+}
+}
+{\shp
+{\*\shpinst\shpleft537\shptop2201\shpright2361\shpbottom3136\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 6}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 1}
+}
+{\sp
+{\sn wzName}
+{\sv v-only}
+}
+}
+{\shprslt
+}
+}
+{\shp
+{\*\shpinst\shpleft537\shptop3201\shpright2361\shpbottom4136\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 6}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn wzName}
+{\sv neither-h-nor-v}
+}
+}
+{\shprslt
+}
+}
+}
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid13321744
+\par }
+}
diff --git a/sw/qa/extras/rtfimport/data/tdf91684.rtf b/sw/qa/extras/rtfimport/data/tdf91684.rtf
new file mode 100644
index 0000000..4ec9e26
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf91684.rtf
@@ -0,0 +1,460 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+\pard\plain \ltrpar\ql \li0\ri0\sa160\sl259\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 
+{\field\fldedit\fldlock
+{\*\fldinst 
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \insrsid8943332  SHAPE  \\* MERGEFORMAT }
+}
+{\fldrslt 
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid8943332 
+{\shpgrp
+{\*\shpinst\shpleft0\shptop0\shpright780\shpbottom759\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplockanchor\shplid1026
+{\sp
+{\sn groupLeft}
+{\sv 8754}
+}
+{\sp
+{\sn groupTop}
+{\sv 11945}
+}
+{\sp
+{\sn groupRight}
+{\sv 11634}
+}
+{\sp
+{\sn groupBottom}
+{\sv 14804}
+}
+{\sp
+{\sn rotation}
+{\sv 0}
+}
+{\sp
+{\sn fLockAgainstUngrouping}
+{\sv 0}
+}
+{\sp
+{\sn fLockRotation}
+{\sv 0}
+}
+{\sp
+{\sn fLockAspectRatio}
+{\sv 0}
+}
+{\sp
+{\sn fLockPosition}
+{\sv 0}
+}
+{\sp
+{\sn fLockAgainstSelect}
+{\sv 0}
+}
+{\sp
+{\sn fLockAgainstGrouping}
+{\sv 0}
+}
+{\sp
+{\sn wzName}
+{\sv Group 
+450}
+}
+{\sp
+{\sn lidRegroup}
+{\sv 0}
+}
+{\sp
+{\sn posh}
+{\sv 0}
+}
+{\sp
+{\sn posrelh}
+{\sv 3}
+}
+{\sp
+{\sn posv}
+{\sv 0}
+}
+{\sp
+{\sn posrelv}
+{\sv 3}
+}
+{\sp
+{\sn dhgt}
+{\sv 0}
+}
+{\sp
+{\sn fAllowOverlap}
+{\sv 1}
+}
+{\sp
+{\sn fBehindDocument}
+{\sv 0}
+}
+{\sp
+{\sn fHidden}
+{\sv 0}
+}
+{\sp
+{\sn fPseudoInline}
+{\sv 1}
+}
+{\sp
+{\sn pctHorizPos}
+{\sv -10001}
+}
+{\sp
+{\sn pctVertPos}
+{\sv -10001}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 1}
+}
+{\sp
+{\sn fLockPosition}
+{\sv 1}
+}
+{\sp
+{\sn fLockRotation}
+{\sv 1}
+}
+{\shp
+{\*\shpinst\shplid1027
+{\sp
+{\sn relLeft}
+{\sv 10194}
+}
+{\sp
+{\sn relTop}
+{\sv 11945}
+}
+{\sp
+{\sn relRight}
+{\sv 11634}
+}
+{\sp
+{\sn relBottom}
+{\sv 13385}
+}
+{\sp
+{\sn shapeType}
+{\sv 1}
+}
+{\sp
+{\sn anchorText}
+{\sv 1}
+}
+{\sp
+{\sn fRotateText}
+{\sv 0}
+}
+{\sp
+{\sn fFitShapeToText}
+{\sv 0}
+}
+{\sp
+{\sn fillColor}
+{\sv 12566463}
+}
+{\sp
+{\sn fillOpacity}
+{\sv 32896}
+}
+{\sp
+{\sn fFilled}
+{\sv 1}
+}
+{\sp
+{\sn lineColor}
+{\sv 16777215}
+}
+{\sp
+{\sn lineWidth}
+{\sv 12700}
+}
+{\sp
+{\sn wzName}
+{\sv Rectangle 451}
+}
+}
+}
+{\shp
+{\*\shpinst\shplid1028
+{\sp
+{\sn relLeft}
+{\sv 10194}
+}
+{\sp
+{\sn relTop}
+{\sv 13364}
+}
+{\sp
+{\sn relRight}
+{\sv 11634}
+}
+{\sp
+{\sn relBottom}
+{\sv 14804}
+}
+{\sp
+{\sn shapeType}
+{\sv 1}
+}
+{\sp
+{\sn fLockRotation}
+{\sv 0}
+}
+{\sp
+{\sn fLockAspectRatio}
+{\sv 0}
+}
+{\sp
+{\sn fLockPosition}
+{\sv 0}
+}
+{\sp
+{\sn fLockAgainstSelect}
+{\sv 0}
+}
+{\sp
+{\sn fLockVerticies}
+{\sv 0}
+}
+{\sp
+{\sn fLockText}
+{\sv 0}
+}
+{\sp
+{\sn fLockAdjustHandles}
+{\sv 0}
+}
+{\sp
+{\sn fLockAgainstGrouping}
+{\sv 0}
+}
+{\sp
+{\sn anchorText}
+{\sv 1}
+}
+{\sp
+{\sn fRotateText}
+{\sv 0}
+}
+{\sp
+{\sn fFitShapeToText}
+{\sv 0}
+}
+{\sp
+{\sn fillColor}
+{\sv 3243501}
+}
+{\sp
+{\sn fFilled}
+{\sv 1}
+}
+{\sp
+{\sn lineColor}
+{\sv 16777215}
+}
+{\sp
+{\sn lineWidth}
+{\sv 12700}
+}
+{\sp
+{\sn fArrowheadsOK}
+{\sv 0}
+}
+{\sp
+{\sn fLine}
+{\sv 1}
+}
+{\sp
+{\sn shadowColor}
+{\sv 14211288}
+}
+{\sp
+{\sn shadowOffsetX}
+{\sv 38100}
+}
+{\sp
+{\sn shadowOffsetY}
+{\sv 38100}
+}
+{\sp
+{\sn fShadow}
+{\sv 0}
+}
+{\sp
+{\sn fshadowObscured}
+{\sv 0}
+}
+{\sp
+{\sn fLockShapeType}
+{\sv 0}
+}
+{\sp
+{\sn wzName}
+{\sv Rectangle 452}
+}
+{\sp
+{\sn dhgt}
+{\sv 251659264}
+}
+{\sp
+{\sn fHidden}
+{\sv 0}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 1}
+}
+}
+}
+{\shp
+{\*\shpinst\shplid1029
+{\sp
+{\sn relLeft}
+{\sv 8754}
+}
+{\sp
+{\sn relTop}
+{\sv 13364}
+}
+{\sp
+{\sn relRight}
+{\sv 10194}
+}
+{\sp
+{\sn relBottom}
+{\sv 14804}
+}
+{\sp
+{\sn shapeType}
+{\sv 1}
+}
+{\sp
+{\sn fLockRotation}
+{\sv 0}
+}
+{\sp
+{\sn fLockAspectRatio}
+{\sv 0}
+}
+{\sp
+{\sn fLockPosition}
+{\sv 0}
+}
+{\sp
+{\sn fLockAgainstSelect}
+{\sv 0}
+}
+{\sp
+{\sn fLockVerticies}
+{\sv 0}
+}
+{\sp
+{\sn fLockText}
+{\sv 0}
+}
+{\sp
+{\sn fLockAdjustHandles}
+{\sv 0}
+}
+{\sp
+{\sn fLockAgainstGrouping}
+{\sv 0}
+}
+{\sp
+{\sn anchorText}
+{\sv 1}
+}
+{\sp
+{\sn fRotateText}
+{\sv 0}
+}
+{\sp
+{\sn fFitShapeToText}
+{\sv 0}
+}
+{\sp
+{\sn fillColor}
+{\sv 12566463}
+}
+{\sp
+{\sn fillOpacity}
+{\sv 32896}
+}
+{\sp
+{\sn fFilled}
+{\sv 1}
+}
+{\sp
+{\sn lineColor}
+{\sv 16777215}
+}
+{\sp
+{\sn lineWidth}
+{\sv 12700}
+}
+{\sp
+{\sn fArrowheadsOK}
+{\sv 0}
+}
+{\sp
+{\sn fLine}
+{\sv 1}
+}
+{\sp
+{\sn shadowColor}
+{\sv 14211288}
+}
+{\sp
+{\sn shadowOffsetX}
+{\sv 38100}
+}
+{\sp
+{\sn shadowOffsetY}
+{\sv 38100}
+}
+{\sp
+{\sn fShadow}
+{\sv 0}
+}
+{\sp
+{\sn fshadowObscured}
+{\sv 0}
+}
+{\sp
+{\sn fLockShapeType}
+{\sv 0}
+}
+{\sp
+{\sn wzName}
+{\sv Rectangle 453}
+}
+{\sp
+{\sn dhgt}
+{\sv 251659264}
+}
+{\sp
+{\sn fHidden}
+{\sv 0}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 1}
+}
+}
+}
+}
+{\shprslt
+{\*\do\dobxcolumn\dobypara\dodhgt8192\dpgroup\dpcount4\dpx0\dpy0\dpxsize780\dpysize759
+\dprect\dpx0\dpy377\dpxsize390\dpysize382\dpfillfgcr255\dpfillfgcg255\dpfillfgcb255\dpfillbgcr108\dpfillbgcg9\dpfillbgcb0\dpfillpat1\dplinew20\dplinecor255\dplinecog255\dplinecob255\dprect\dpx0\dpy0\dpxsize390\dpysize382
+\dpfillfgcr255\dpfillfgcg255\dpfillfgcb255\dpfillbgcr133\dpfillbgcg12\dpfillbgcb0\dpfillpat1\dplinew20\dplinecor255\dplinecog255\dplinecob255\dprect\dpx390\dpy0\dpxsize390\dpysize382
+\dpfillfgcr255\dpfillfgcg255\dpfillfgcb255\dpfillbgcr108\dpfillbgcg9\dpfillbgcb0\dpfillpat1\dplinew20\dplinecor255\dplinecog255\dplinecob255\dpendgroup\dpx0\dpy0\dpxsize0\dpysize0}
+}
+}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 17445cd..73096c8 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -2634,6 +2634,33 @@ DECLARE_RTFIMPORT_TEST(testTdf50821, "tdf50821.rtf")
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(191), getProperty<sal_Int32>(xCell, "LeftBorderDistance"));
 }
 
+DECLARE_RTFIMPORT_TEST(testTdf91684, "tdf91684.rtf")
+{
+    // Scaling of the group shape children were incorrect, this was 3203.
+    // (Unit was assumed to be twips, but it was relative coordinates.)
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1337), getShape(1)->getSize().Height);
+}
+
+DECLARE_RTFIMPORT_TEST(testFlip, "flip.rtf")
+{
+    comphelper::SequenceAsHashMap aMap = getProperty< uno::Sequence<beans::PropertyValue> >(getShapeByName("h-and-v"), "CustomShapeGeometry");
+    // This resulted in a uno::RuntimeException, as MirroredX wasn't set at all, so could not extract void to boolean.
+    CPPUNIT_ASSERT_EQUAL(true, aMap["MirroredX"].get<bool>());
+    CPPUNIT_ASSERT_EQUAL(true, aMap["MirroredY"].get<bool>());
+
+    aMap = getProperty< uno::Sequence<beans::PropertyValue> >(getShapeByName("h-only"), "CustomShapeGeometry");
+    CPPUNIT_ASSERT_EQUAL(true, aMap["MirroredX"].get<bool>());
+    CPPUNIT_ASSERT(!aMap["MirroredY"].hasValue());
+
+    aMap = getProperty< uno::Sequence<beans::PropertyValue> >(getShapeByName("v-only"), "CustomShapeGeometry");
+    CPPUNIT_ASSERT(!aMap["MirroredX"].hasValue());
+    CPPUNIT_ASSERT_EQUAL(true, aMap["MirroredY"].get<bool>());
+
+    aMap = getProperty< uno::Sequence<beans::PropertyValue> >(getShapeByName("neither-h-nor-v"), "CustomShapeGeometry");
+    CPPUNIT_ASSERT(!aMap["MirroredX"].hasValue());
+    CPPUNIT_ASSERT(!aMap["MirroredY"].hasValue());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 7062c48..b3517b8 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -349,6 +349,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
     sal_Int16 nRelativeWidthRelation = text::RelOrientation::PAGE_FRAME;
     sal_Int16 nRelativeHeightRelation = text::RelOrientation::PAGE_FRAME;
     boost::logic::tribool obRelFlipV(boost::logic::indeterminate);
+    boost::logic::tribool obFlipH(boost::logic::indeterminate);
+    boost::logic::tribool obFlipV(boost::logic::indeterminate);
 
     bool bCustom(false);
     int const nType = initShape(xShape, xPropertySet, bCustom, rShape, bClose, shapeOrPict);
@@ -781,6 +783,10 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
         }
         else if (rProperty.first == "fRelFlipV")
             obRelFlipV = rProperty.second.toInt32() == 1;
+        else if (rProperty.first == "fFlipH")
+            obFlipH = rProperty.second.toInt32() == 1;
+        else if (rProperty.first == "fFlipV")
+            obFlipV = rProperty.second.toInt32() == 1;
         else
             SAL_INFO("writerfilter", "TODO handle shape property '" << rProperty.first << "':'" << rProperty.second << "'");
     }
@@ -875,6 +881,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
 
         bool bInShapeGroup = oGroupLeft && oGroupTop && oGroupRight && oGroupBottom
                              && oRelLeft && oRelTop && oRelRight && oRelBottom;
+        awt::Size aSize;
         if (bInShapeGroup)
         {
             // See lclGetAbsPoint() in the VML import: rShape is the group shape, oGroup is its coordinate system, oRel is the relative child shape.
@@ -886,6 +893,10 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
             double fHeightRatio = static_cast< double >(nShapeHeight) / nCoordSysHeight;
             nLeft = static_cast< sal_Int32 >(rShape.nLeft + fWidthRatio * (*oRelLeft - *oGroupLeft));
             nTop = static_cast< sal_Int32 >(rShape.nTop + fHeightRatio * (*oRelTop - *oGroupTop));
+
+            // See lclGetAbsRect() in the VML import.
+            aSize.Width = static_cast<sal_Int32>(fWidthRatio * (*oRelRight - *oRelLeft) + 0.5);
+            aSize.Height = static_cast<sal_Int32>(fHeightRatio * (*oRelBottom - *oRelTop) + 0.5);
         }
 
         if (m_bTextFrame)
@@ -897,10 +908,21 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
             xShape->setPosition(awt::Point(nLeft, nTop));
 
         if (bInShapeGroup)
-            xShape->setSize(awt::Size(*oRelRight - *oRelLeft, *oRelBottom - *oRelTop));
+            xShape->setSize(aSize);
         else
             xShape->setSize(awt::Size(rShape.nRight - rShape.nLeft, rShape.nBottom - rShape.nTop));
 
+        if (obFlipH == true || obFlipV == true)
+        {
+            // This has to be set after position and size is set, otherwise flip will affect the position.
+            comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
+            if (obFlipH == true)
+                aCustomShapeGeometry["MirroredX"] <<= true;
+            if (obFlipV == true)
+                aCustomShapeGeometry["MirroredY"] <<= true;
+            xPropertySet->setPropertyValue("CustomShapeGeometry", uno::makeAny(aCustomShapeGeometry.getAsConstPropertyValueList()));
+        }
+
         if (rShape.nHoriOrientRelation != 0)
             xPropertySet->setPropertyValue("HoriOrientRelation", uno::makeAny(rShape.nHoriOrientRelation));
         if (rShape.nVertOrientRelation != 0)


More information about the Libreoffice-commits mailing list