tdf#91684 RTF import: handle fFlipH and fFlipV shape props
Change-Id: I930f99647de00c2e43ef94b1ac0320daa440eae9 Reviewed-on: https://gerrit.libreoffice.org/26349 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
96
sw/qa/extras/rtfimport/data/flip.rtf
Normal file
96
sw/qa/extras/rtfimport/data/flip.rtf
Normal file
@@ -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 }
|
||||||
|
}
|
@@ -2641,6 +2641,26 @@ DECLARE_RTFIMPORT_TEST(testTdf91684, "tdf91684.rtf")
|
|||||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1337), getShape(1)->getSize().Height);
|
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();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -351,6 +351,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
|
|||||||
sal_Int16 nRelativeWidthRelation = text::RelOrientation::PAGE_FRAME;
|
sal_Int16 nRelativeWidthRelation = text::RelOrientation::PAGE_FRAME;
|
||||||
sal_Int16 nRelativeHeightRelation = text::RelOrientation::PAGE_FRAME;
|
sal_Int16 nRelativeHeightRelation = text::RelOrientation::PAGE_FRAME;
|
||||||
boost::logic::tribool obRelFlipV(boost::logic::indeterminate);
|
boost::logic::tribool obRelFlipV(boost::logic::indeterminate);
|
||||||
|
boost::logic::tribool obFlipH(boost::logic::indeterminate);
|
||||||
|
boost::logic::tribool obFlipV(boost::logic::indeterminate);
|
||||||
|
|
||||||
bool bCustom(false);
|
bool bCustom(false);
|
||||||
int const nType = initShape(xShape, xPropertySet, bCustom, rShape, bClose, shapeOrPict);
|
int const nType = initShape(xShape, xPropertySet, bCustom, rShape, bClose, shapeOrPict);
|
||||||
@@ -783,6 +785,10 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
|
|||||||
}
|
}
|
||||||
else if (rProperty.first == "fRelFlipV")
|
else if (rProperty.first == "fRelFlipV")
|
||||||
obRelFlipV = rProperty.second.toInt32() == 1;
|
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
|
else
|
||||||
SAL_INFO("writerfilter", "TODO handle shape property '" << rProperty.first << "':'" << rProperty.second << "'");
|
SAL_INFO("writerfilter", "TODO handle shape property '" << rProperty.first << "':'" << rProperty.second << "'");
|
||||||
}
|
}
|
||||||
@@ -908,6 +914,17 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
|
|||||||
else
|
else
|
||||||
xShape->setSize(awt::Size(rShape.nRight - rShape.nLeft, rShape.nBottom - rShape.nTop));
|
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)
|
if (rShape.nHoriOrientRelation != 0)
|
||||||
xPropertySet->setPropertyValue("HoriOrientRelation", uno::makeAny(rShape.nHoriOrientRelation));
|
xPropertySet->setPropertyValue("HoriOrientRelation", uno::makeAny(rShape.nHoriOrientRelation));
|
||||||
if (rShape.nVertOrientRelation != 0)
|
if (rShape.nVertOrientRelation != 0)
|
||||||
|
Reference in New Issue
Block a user