Kaydet (Commit) 11d87b35 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#109077 sw textbox: fix as-char shapes with custom print area in para

Regression from d379d186 (oox: import
WPS shape with text as shape with textbox, 2014-06-18), the position of
the textbox should be relative to the print area of the text frame, not
to the text frame itself.

Change-Id: I2b591dc46ad4967edd8a1691d9b100ef0d74bed3
Reviewed-on: https://gerrit.libreoffice.org/58009
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst eb880ce1
......@@ -27,6 +27,7 @@ public:
void testTdf117245();
void testTdf118672();
void testTdf117923();
void testTdf109077();
CPPUNIT_TEST_SUITE(SwLayoutWriter);
CPPUNIT_TEST(testTdf116830);
......@@ -39,6 +40,7 @@ public:
CPPUNIT_TEST(testTdf117245);
CPPUNIT_TEST(testTdf118672);
CPPUNIT_TEST(testTdf117923);
CPPUNIT_TEST(testTdf109077);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -236,6 +238,18 @@ void SwLayoutWriter::testTdf117923()
assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "220");
}
void SwLayoutWriter::testTdf109077()
{
createDoc("tdf109077.docx");
xmlDocPtr pXmlDoc = parseLayoutDump();
sal_Int32 nShapeTop
= getXPath(pXmlDoc, "//anchored/SwAnchoredDrawObject/bounds", "top").toInt32();
sal_Int32 nTextBoxTop = getXPath(pXmlDoc, "//anchored/fly/infos/bounds", "top").toInt32();
// This was 281: the top of the shape and its textbox should match, though
// tolerate differences <= 1px (about 15 twips).
CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(15), nTextBoxTop - nShapeTop);
}
CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -351,16 +351,20 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase,
{
// It has, so look up its text rectangle, and adjust the position
// of the textbox accordingly.
// Both rectangles are absolute, SwFormatHori/VertOrient's position
// is relative to the print area of the anchor text frame.
tools::Rectangle aTextRectangle = SwTextBoxHelper::getTextRectangle(pShape);
SwFormatHoriOrient aHori(pTextBox->GetHoriOrient());
aHori.SetHoriOrient(css::text::HoriOrientation::NONE);
sal_Int32 nLeft = aTextRectangle.getX() - rFrame.getFrameArea().Left();
sal_Int32 nLeft = aTextRectangle.getX() - rFrame.getFrameArea().Left()
- rFrame.getFramePrintArea().Left();
aHori.SetPos(nLeft);
SwFormatVertOrient aVert(pTextBox->GetVertOrient());
aVert.SetVertOrient(css::text::VertOrientation::NONE);
sal_Int32 const nTop = aTextRectangle.getY() - rFrame.getFrameArea().Top();
sal_Int32 const nTop = aTextRectangle.getY() - rFrame.getFrameArea().Top()
- rFrame.getFramePrintArea().Top();
aVert.SetPos(nTop);
pTextBox->LockModify();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment