Kaydet (Commit) 0a4d77f3 authored tarafından Miklos Vajna's avatar Miklos Vajna

SwTxtNode::Update: don't move anchors at insert position

Use cases:

1) User of the XTextAppend API's uses appendTextPortion(), then
appendTextContent(), then appendTextPortion() again. It's expected that
the text content will be in the middle of the paragraph, but before, it
was at the end of it.

It's possible to work this around by inserting the text contents only at
the end of the paragraph (like it's done for ODF import in
XMLParaContext::~XMLParaContext()), but probably it's not a good idea to
copy&paste this workaround in all the import filters.

2) User types some characters in a new document, then inserts a picture,
and sets anchor type to at-char. Now the anchor point is set to the end
of the paragraph, but it's impossible to type anything after that
character.

To be fair, now it's not possible to type something *before* the anchor
point, if it's at the first character, but hopefully that's less of an
issue, since setting the anchor type to at-char sets it to the end of
the paragraph, not at the start of it.

Change-Id: Ia8b33e8880aae86f62fae09cd5ac1cf82c83320f
üst 54e86f70
...@@ -403,6 +403,15 @@ DECLARE_OOXMLEXPORT_TEST(testTableStyleBorderExport, "table-style-border-export. ...@@ -403,6 +403,15 @@ DECLARE_OOXMLEXPORT_TEST(testTableStyleBorderExport, "table-style-border-export.
CPPUNIT_ASSERT_EQUAL(sal_Int32(0x8064A2), getProperty<table::BorderLine2>(xCell, "BottomBorder").Color); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x8064A2), getProperty<table::BorderLine2>(xCell, "BottomBorder").Color);
} }
DECLARE_OOXMLEXPORT_TEST(testAnchorPosition, "anchor-position.docx")
{
// The problem was that the at-char anchored picture was at the end of the
// paragraph, so there were only two postions: a Text, then a Frame one.
CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(getRun(getParagraph(1), 1), "TextPortionType"));
CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty<OUString>(getRun(getParagraph(1), 2), "TextPortionType"));
CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(getRun(getParagraph(1), 3), "TextPortionType"));
}
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -466,7 +466,7 @@ DECLARE_OOXMLEXPORT_TEST(testFDO79915, "fdo79915.docx") ...@@ -466,7 +466,7 @@ DECLARE_OOXMLEXPORT_TEST(testFDO79915, "fdo79915.docx")
if (!pXmlDoc) if (!pXmlDoc)
return; return;
assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[8]/w:t", "How much buoyancy does the water provide?"); assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[10]/w:t", "How much buoyancy does the water provide?");
} }
DECLARE_OOXMLEXPORT_TEST(testfdo79817, "fdo79817.docx") DECLARE_OOXMLEXPORT_TEST(testfdo79817, "fdo79817.docx")
......
...@@ -902,7 +902,7 @@ DECLARE_OOXMLEXPORT_TEST(testOuterShdw,"testOuterShdw.docx") ...@@ -902,7 +902,7 @@ DECLARE_OOXMLEXPORT_TEST(testOuterShdw,"testOuterShdw.docx")
xmlDocPtr pXmlDoc = parseExport("word/document.xml"); xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc) if (!pXmlDoc)
return; return;
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:effectLst[1]/a:outerShdw[1]", "dist", "57811035"); assertXPath(pXmlDoc, "//mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:effectLst[1]/a:outerShdw[1]", "dist", "57811035");
} }
DECLARE_OOXMLEXPORT_TEST(testExtentValue, "fdo74605.docx") DECLARE_OOXMLEXPORT_TEST(testExtentValue, "fdo74605.docx")
......
...@@ -1097,6 +1097,22 @@ void SwTxtNode::Update( ...@@ -1097,6 +1097,22 @@ void SwTxtNode::Update(
bSortMarks = bAtLeastOneBookmarkMoved && bAtLeastOneExpandedBookmarkAtInsertionPosition; bSortMarks = bAtLeastOneBookmarkMoved && bAtLeastOneExpandedBookmarkAtInsertionPosition;
} }
// at-char anchored flys shouldn't be moved, either.
const SwFrmFmts& rFmts = *GetDoc()->GetSpzFrmFmts();
for (SwFrmFmts::const_iterator pFmt = rFmts.begin(); pFmt != rFmts.end(); ++pFmt)
{
const SwFmtAnchor& rAnchor = (*pFmt)->GetAnchor();
const SwPosition* pCntntAnchor = rAnchor.GetCntntAnchor();
if (rAnchor.GetAnchorId() == FLY_AT_CHAR && pCntntAnchor)
{
// The fly is at-char anchored and has an anchor position.
SwIndex& rEndIdx = const_cast<SwIndex&>(pCntntAnchor->nContent);
if (&pCntntAnchor->nNode.GetNode() == this && rEndIdx.GetIndex() == rPos.GetIndex())
// The anchor position is exactly our insert position.
rEndIdx.Assign(&aTmpIdxReg, rEndIdx.GetIndex());
}
}
} }
// base class // base class
......
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