summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorPatrick Jaap <patrick.jaap@tu-dresden.de>2018-09-21 11:53:19 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-11-06 14:26:45 +0100
commit4d9dda3fd096b9bffba5a07243a86208affd893f (patch)
treedc6059bac85b77a2a4973c71bc8a2adf2048a57a /sw
parentee9ccdf6ecd944c2f448a30d10700754d1f0cfa2 (diff)
tdf#115094 part I: do not move graphic nodes
Do not move graphic nodes in SwXText::convertToTextFrame() since it is not reasonable (they are anchored to something that already moved) and hence it causes errors. A static function checks wether the current node is a graphic. A small change in writerfilter was done since a unit test failed: The condition "m_nAnchorType != 0" was removed since it is not reasonable at this place. Change-Id: I8f27985f6f6c8329483370a7b8baaf9949513f1b Reviewed-on: https://gerrit.libreoffice.org/60860 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf115094.docxbin0 -> 15064 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport2.cxx20
-rw-r--r--sw/source/core/unocore/unotext.cxx18
3 files changed, 37 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf115094.docx b/sw/qa/extras/ooxmlimport/data/tdf115094.docx
new file mode 100644
index 000000000000..38d84d88ed86
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf115094.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 7f548f47e65d..6fe7784cd062 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -223,6 +223,26 @@ DECLARE_OOXMLIMPORT_TEST(testTdf119200, "tdf119200.docx")
CPPUNIT_ASSERT_EQUAL(OUString(u" size 12{ func \u2287 } {}"), getFormula(getRun(xPara, 7)));
}
+DECLARE_OOXMLIMPORT_TEST(testTdf115094, "tdf115094.docx")
+{
+ // anchor of graphic has to be the text in the text frame
+ // xray ThisComponent.DrawPage(1).Anchor.Text
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(),
+ uno::UNO_QUERY);
+ uno::Reference<text::XTextContent> xShape(xDrawPage->getByIndex(1), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText1(xShape->getAnchor()->getText(), uno::UNO_QUERY);
+
+ // xray ThisComponent.TextTables(0).getCellByName("A1")
+ uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
+ uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xText2(xTable->getCellByName("A1"), uno::UNO_QUERY);
+
+ CPPUNIT_ASSERT_EQUAL(xText1.get(), xText2.get());
+}
+
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index dbf00411ece5..e27630e16445 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1487,6 +1487,20 @@ SwXText::appendTextContent(
return insertTextContentWithProperties(xTextContent, rCharacterAndParagraphProperties, xInsertPosition);
}
+// determine wether SwFrameFormat is a graphic node
+static bool isGraphicNode(const SwFrameFormat* pFrameFormat)
+{
+ // safety
+ if( !pFrameFormat->GetContent().GetContentIdx() )
+ {
+ return false;
+ }
+ auto index = *pFrameFormat->GetContent().GetContentIdx();
+ // consider the next node -> there is the graphic stored
+ index++;
+ return index.GetNode().IsGrfNode();
+}
+
// move previously appended paragraphs into a text frames
// to support import filters
uno::Reference< text::XTextContent > SAL_CALL
@@ -1632,13 +1646,15 @@ SwXText::convertToTextFrame(
// see if there are frames already anchored to this node
// we have to work with the SdrObjects, as unique name is not guaranteed in their frame format
+ // tdf#115094: do nothing if we have a graphic node
std::set<const SdrObject*> aAnchoredObjectsByPtr;
std::set<OUString> aAnchoredObjectsByName;
for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrameFormats()->size(); ++i)
{
const SwFrameFormat* pFrameFormat = (*m_pImpl->m_pDoc->GetSpzFrameFormats())[i];
const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
- if ((RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId() || RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId()) &&
+ if ( !isGraphicNode(pFrameFormat) &&
+ (RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId() || RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId()) &&
aStartPam.Start()->nNode.GetIndex() <= rAnchor.GetContentAnchor()->nNode.GetIndex() &&
aStartPam.End()->nNode.GetIndex() >= rAnchor.GetContentAnchor()->nNode.GetIndex())
{