Kaydet (Commit) 3d922d7d authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#98806 RTF import: handle bookmarks in table text

Mapper().props() was called directly, so all bookmarks pointed to the
start of the A1 cell instead of the correct text range.

Change-Id: I40eeb85b61d2ae9138cd666d4a6a3c08eda47da3
üst e944b64a
{\rtf1
\trowd\cellx4000\cellx8000\pard\plain\intbl
A1\cell AAA
{\*\bkmkstart bookmark}
BBB
{\*\bkmkend bookmark}
CCC\cell
\row
\pard\plain
\par
}
......@@ -1013,6 +1013,14 @@ DECLARE_RTFEXPORT_TEST(testPgnlcltr, "pgnlcltr.rtf")
CPPUNIT_ASSERT_EQUAL(style::NumberingType::CHARS_LOWER_LETTER_N, getProperty<sal_Int16>(getStyles("PageStyles")->getByName("Converted1"), "NumberingType"));
}
DECLARE_RTFEXPORT_TEST(testTdf98806, "tdf98806.rtf")
{
uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextContent> xBookmark(xBookmarksSupplier->getBookmarks()->getByName("bookmark"), uno::UNO_QUERY);
// This was empty, bookmark in table wasn't imported correctly.
CPPUNIT_ASSERT_EQUAL(OUString("BBB"), xBookmark->getAnchor()->getString());
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -161,7 +161,7 @@ static OString lcl_DTTM22OString(long lDTTM)
return DateTimeToOString(msfilter::util::DTTM2DateTime(lDTTM));
}
static writerfilter::Reference<Properties>::Pointer_t lcl_getBookmarkProperties(int nPos, OUString& rString)
static RTFSprms lcl_getBookmarkProperties(int nPos, OUString& rString)
{
RTFSprms aAttributes;
auto pPos = std::make_shared<RTFValue>(nPos);
......@@ -172,7 +172,7 @@ static writerfilter::Reference<Properties>::Pointer_t lcl_getBookmarkProperties(
aAttributes.set(NS_ooxml::LN_CT_Bookmark_name, pString);
}
aAttributes.set(NS_ooxml::LN_CT_MarkupRangeBookmark_id, pPos);
return std::make_shared<RTFReferenceProperties>(aAttributes);
return aAttributes;
}
static const char* lcl_RtfToString(RTFKeyword nKeyword)
......@@ -5357,7 +5357,10 @@ RTFError RTFDocumentImpl::popState()
OUString aStr = m_aStates.top().pDestinationText->makeStringAndClear();
int nPos = m_aBookmarks.size();
m_aBookmarks[aStr] = nPos;
Mapper().props(lcl_getBookmarkProperties(nPos, aStr));
if (!m_aStates.top().pCurrentBuffer)
Mapper().props(std::make_shared<RTFReferenceProperties>(lcl_getBookmarkProperties(nPos, aStr)));
else
m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_PROPS, std::make_shared<RTFValue>(lcl_getBookmarkProperties(nPos, aStr)), nullptr));
}
break;
case Destination::BOOKMARKEND:
......@@ -5365,7 +5368,10 @@ RTFError RTFDocumentImpl::popState()
if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText)
break; // not for nested group
OUString aStr = m_aStates.top().pDestinationText->makeStringAndClear();
Mapper().props(lcl_getBookmarkProperties(m_aBookmarks[aStr], aStr));
if (!m_aStates.top().pCurrentBuffer)
Mapper().props(std::make_shared<RTFReferenceProperties>(lcl_getBookmarkProperties(m_aBookmarks[aStr], aStr)));
else
m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_PROPS, std::make_shared<RTFValue>(lcl_getBookmarkProperties(m_aBookmarks[aStr], aStr)), nullptr));
}
break;
case Destination::INDEXENTRY:
......
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