diff options
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/tdf115094.docx | bin | 0 -> 15064 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 18 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 2 |
4 files changed, 38 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf115094.docx b/sw/qa/extras/ooxmlimport/data/tdf115094.docx Binary files differnew file mode 100644 index 000000000000..38d84d88ed86 --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/tdf115094.docx 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 |