[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 6 13:28:12 UTC 2018
sw/qa/extras/ooxmlimport/data/tdf115094.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 20 ++++++++++++++++++++
sw/source/core/unocore/unotext.cxx | 18 +++++++++++++++++-
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 2 +-
4 files changed, 38 insertions(+), 2 deletions(-)
New commits:
commit 4d9dda3fd096b9bffba5a07243a86208affd893f
Author: Patrick Jaap <patrick.jaap at tu-dresden.de>
AuthorDate: Fri Sep 21 11:53:19 2018 +0200
Commit: Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Tue Nov 6 14:26:45 2018 +0100
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 at collabora.co.uk>
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
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf115094.docx 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())
{
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index f45e9b484cfd..e54453f261f5 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3615,7 +3615,7 @@ bool RTFFrame::hasProperties()
{
return m_nX != 0 || m_nY != 0 || m_nW != 0 || m_nH != 0 || m_nHoriPadding != 0
|| m_nVertPadding != 0 || m_nHoriAlign != 0 || m_nHoriAnchor != 0 || m_nVertAlign != 0
- || m_nVertAnchor != 0 || m_nAnchorType != 0;
+ || m_nVertAnchor != 0;
}
} // namespace rtftok
More information about the Libreoffice-commits
mailing list