diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-06 15:26:35 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-10-06 17:12:45 +0200 |
commit | 0a4d77f35e96e4dfdf69cc5ceb788ddaa849084c (patch) | |
tree | 33373508e1f3f212a420297cd9a493315a55b477 /sw | |
parent | 54e86f708cf0274ec6b2536200802cf6f406101d (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/anchor-position.docx | bin | 0 -> 14599 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 9 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 16 |
5 files changed, 27 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/anchor-position.docx b/sw/qa/extras/ooxmlexport/data/anchor-position.docx Binary files differnew file mode 100644 index 000000000000..b210ee930e3f --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/anchor-position.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index d1ef8ae77766..487728defec1 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 21b8976b59a8..7c36ee9106db 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 dae2b598cdfb..d636f9d437df 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 83f6c9864927..5f9f95ccf233 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 |