[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Apr 14 08:16:32 UTC 2016
sw/qa/extras/rtfexport/data/tdf98806.rtf | 11 +++++++++++
sw/qa/extras/rtfexport/rtfexport.cxx | 8 ++++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 14 ++++++++++----
3 files changed, 29 insertions(+), 4 deletions(-)
New commits:
commit 7dece94d6aa122d69e9740b93597d13347b5cb11
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Mar 31 08:37:43 2016 +0200
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.
(cherry picked from commit 3d922d7da4fa11b8c22bbdffd141fa1398b2fcd4)
Conflicts:
sw/qa/extras/rtfexport/rtfexport.cxx
Change-Id: I40eeb85b61d2ae9138cd666d4a6a3c08eda47da3
Reviewed-on: https://gerrit.libreoffice.org/23913
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/sw/qa/extras/rtfexport/data/tdf98806.rtf b/sw/qa/extras/rtfexport/data/tdf98806.rtf
new file mode 100644
index 0000000..e356682
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/tdf98806.rtf
@@ -0,0 +1,11 @@
+{\rtf1
+\trowd\cellx4000\cellx8000\pard\plain\intbl
+A1\cell AAA
+{\*\bkmkstart bookmark}
+BBB
+{\*\bkmkend bookmark}
+CCC\cell
+\row
+\pard\plain
+\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 0825034..11b92e8 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -983,6 +983,14 @@ DECLARE_RTFEXPORT_TEST(testTdf96175, "tdf96175.rtf")
CPPUNIT_ASSERT_EQUAL(OUString("foobar"), getProperty<OUString>(xUserDefinedProperties, "Company"));
}
+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: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index cc01274..bb1991d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -156,7 +156,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);
@@ -167,7 +167,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)
@@ -5313,7 +5313,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:
@@ -5321,7 +5324,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:
More information about the Libreoffice-commits
mailing list