RTF import: fix handling of RTF_SHPFBLWTXT

Commit 6cac123a8d (fdo#45183 import
RTF_SHPFBLWTXT, 2012-12-27) fixed this already once in the past -- fix
it again, this time with a testcase.

Change-Id: I0cbbfb1ba4eef42b2ee32f6f77065afaad3ddc1b
This commit is contained in:
Miklos Vajna 2014-08-13 14:39:40 +02:00
parent 3c491f05d5
commit 37ecf08237
4 changed files with 41 additions and 8 deletions

View file

@ -0,0 +1,19 @@
{\rtf1
{\shp
{\*\shpinst\shpleft-7\shptop-7\shpright1274\shpbottom1274\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz0\shplid1026
{\sp
{\sn shapeType}
{\sv 75}
}
{\sp
{\sn pib}
{\sv
{\pict\picscalex100\picscaley100\piccropl0\piccropr0\piccropt0\piccropb0\picw2258\pich2258\picwgoal1280\pichgoal1280\pngblip\bliptag1974568719
{\*\blipuid 75b1870fd12614068d19954c8cfee5d1}
47494638396110001000d5ff00000000ffffffc0c0c0555f00ffffaafcfcfcf6f6f6eaeaeae6e6e6e4e4e4e3e3e3c2c2c2c1c1c1bcbcbcb5b5b5b3b3b3b0b0b0adadada5a5a5a2a2a2a1a1a19f9f9f9494948a8a8a8888888686867b7b7b6c6c6c5c5c5c4e4e4e4b4b4b4747474646463d3d3d3c3c3c2e2e2e2525251b1b1b18181810101009090906060603030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021f90401000002002c0000000010001000000684408170482c0a06c8a4728924389f506833b281302a8e6b164b18103024c52111504cca67332102e0042e9a40d9319f8300a343c1200f54e47f7e2a00001e0b0a7d0d728a010d838400261a7c0d94947784252700127e9d159f6c8411140019080ea7a9a85f842122281612b1b3b25d6b1f29291d0fbbbdbc5d5e51c34e4cc64a46c94341003b}
}
}
}
}
aaa\par
}

View file

@ -1893,6 +1893,15 @@ DECLARE_RTFIMPORT_TEST(testFdo82106, "fdo82106.rtf")
getParagraph(2, "before\tafter");
}
DECLARE_RTFIMPORT_TEST(testBehindDoc, "behind-doc.rtf")
{
// The problem was that "behind doc" didn't result in the shape being in the background, only in being wrapped as "through".
uno::Reference<drawing::XShape> xShape = getShape(1);
CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_THROUGHT, getProperty<text::WrapTextMode>(xShape, "Surround"));
// This was true.
CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xShape, "Opaque"));
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -887,20 +887,25 @@ int RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XSh
// wrap sprm
RTFSprms aAnchorWrapAttributes;
RTFSprms aAnchorAttributes;
aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_behindDoc, RTFValue::Pointer_t(new RTFValue(m_aStates.top().aShape.bInBackground)));
RTFSprms aAnchorSprms;
for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes.begin(); i != m_aStates.top().aCharacterAttributes.end(); ++i)
{
if (i->first == NS_ooxml::LN_CT_WrapSquare_wrapText)
aAnchorWrapAttributes.set(i->first, i->second);
}
sal_Int32 nWrap = -1;
for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterSprms.begin(); i != m_aStates.top().aCharacterSprms.end(); ++i)
{
if (i->first == NS_ooxml::LN_EG_WrapType_wrapNone)
{
nWrap = NS_ooxml::LN_EG_WrapType_wrapNone;
aAnchorSprms.set(i->first, i->second);
}
}
RTFValue::Pointer_t pAnchorWrapValue(new RTFValue(aAnchorWrapAttributes));
aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_extent, pExtentValue);
if (aAnchorWrapAttributes.size())
if (aAnchorWrapAttributes.size() && nWrap != NS_ooxml::LN_EG_WrapType_wrapNone)
aAnchorSprms.set(NS_ooxml::LN_EG_WrapType_wrapSquare, pAnchorWrapValue);
// See OOXMLFastContextHandler::positionOffset(), we can't just put offset values in an RTFValue.
@ -3966,6 +3971,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
break;
case 3:
m_aStates.top().aShape.nWrap = com::sun::star::text::WrapTextMode_THROUGHT;
m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_WrapType_wrapNone, RTFValue::Pointer_t(new RTFValue()));
break;
case 4:
m_aStates.top().aShape.nWrap = com::sun::star::text::WrapTextMode_PARALLEL;
@ -4469,12 +4475,8 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
break;
case RTF_SHPFBLWTXT:
if (nParam == 1)
{
// Shape is below text -> send it to the background.
m_aStates.top().aCharacterAttributes.erase(NS_ooxml::LN_CT_WrapSquare_wrapText);
m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_WrapType_wrapNone, RTFValue::Pointer_t(new RTFValue()));
}
// Shape is below text -> send it to the background.
m_aStates.top().aShape.bInBackground = nParam;
break;
case RTF_CLPADB:
case RTF_CLPADL:
@ -5934,7 +5936,8 @@ RTFShape::RTFShape()
nVertOrientRelation(0),
nHoriOrientRelationToken(0),
nVertOrientRelationToken(0),
nWrap(-1)
nWrap(-1),
bInBackground(false)
{
}

View file

@ -137,6 +137,8 @@ public:
sal_uInt32 nHoriOrientRelationToken; ///< Horizontal dmapper token for Writer pictures.
sal_uInt32 nVertOrientRelationToken; ///< Vertical dmapper token for Writer pictures.
int nWrap;
/// If shape is below text (true) or text is below shape (false).
bool bInBackground;
};
/// Stores the properties of a drawing object.