Kaydet (Commit) 4d9dda3f authored tarafından Patrick Jaap's avatar Patrick Jaap Kaydeden (comit) Miklos Vajna

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: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst ee9ccdf6
......@@ -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();
......
......@@ -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())
{
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment