sw/qa/extras/ooxmlexport/data/anchor-position.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 9 +++++++++ sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 2 +- sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 2 +- sw/source/core/txtnode/ndtxt.cxx | 16 ++++++++++++++++ 5 files changed, 27 insertions(+), 2 deletions(-)
New commits: commit 0a4d77f35e96e4dfdf69cc5ceb788ddaa849084c Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Oct 6 15:26:35 2014 +0200 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 diff --git a/sw/qa/extras/ooxmlexport/data/anchor-position.docx b/sw/qa/extras/ooxmlexport/data/anchor-position.docx new file mode 100644 index 0000000..b210ee9 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/anchor-position.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index d1ef8ae..487728d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -403,6 +403,15 @@ DECLARE_OOXMLEXPORT_TEST(testTableStyleBorderExport, "table-style-border-export. 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(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 21b8976..7c36ee9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -466,7 +466,7 @@ DECLARE_OOXMLEXPORT_TEST(testFDO79915, "fdo79915.docx") if (!pXmlDoc) 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") diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx index dae2b59..d636f9d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx @@ -902,7 +902,7 @@ DECLARE_OOXMLEXPORT_TEST(testOuterShdw,"testOuterShdw.docx") xmlDocPtr pXmlDoc = parseExport("word/document.xml"); if (!pXmlDoc) 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") diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 83f6c98..5f9f95c 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -1097,6 +1097,22 @@ void SwTxtNode::Update( 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits