summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-02-25 21:38:48 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-02-26 08:56:48 +0100
commitb7dabb80f45a65713f114c61e1d695f3f8093812 (patch)
tree40092f7a59f8e81d12341504091e376f22ed688d /writerfilter
parent984a0c79cb57789cff6416900fc363eefead44db (diff)
tdf#123393 RTF import: fix too big font size in table cell
The reason was that A2 had an explicit paragraph style reference, but A1 did not, so table buffering caused A2 style to affect A1 style as well. Combine this with style deduplication, and then A2 style considered the direct formatting (font size) in A1 to be redundant, so it was lost on import. Fix the problem by moving the copy&pasted properties buffering to a single function, and there buffering not only the properties, but also the active style index. Change-Id: I99f2020b8bef237849fd622b25ac5ef0516d69e4 Reviewed-on: https://gerrit.libreoffice.org/68361 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/rtftok/rtfdispatchsymbol.cxx4
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx35
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx5
3 files changed, 31 insertions, 13 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
index e3b212a1dfdd..6d7d9cefabaa 100644
--- a/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchsymbol.cxx
@@ -184,10 +184,10 @@ RTFError RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
// There were no runs in the cell, so we need to send paragraph and character properties here.
auto pPValue = new RTFValue(m_aStates.top().aParagraphAttributes,
m_aStates.top().aParagraphSprms);
- m_aTableBufferStack.back().emplace_back(Buf_t(BUFFER_PROPS, pPValue, nullptr));
+ bufferProperties(m_aTableBufferStack.back(), pPValue, nullptr);
auto pCValue = new RTFValue(m_aStates.top().aCharacterAttributes,
m_aStates.top().aCharacterSprms);
- m_aTableBufferStack.back().emplace_back(Buf_t(BUFFER_PROPS, pCValue, nullptr));
+ bufferProperties(m_aTableBufferStack.back(), pCValue, nullptr);
}
RTFValue::Pointer_t pValue;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 2d2d63ca5a4e..c29a54d7fbc9 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -572,7 +572,7 @@ void RTFDocumentImpl::checkNeedPap()
{
auto pValue = new RTFValue(m_aStates.top().aParagraphAttributes,
m_aStates.top().aParagraphSprms);
- m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_PROPS, pValue, nullptr));
+ bufferProperties(*m_aStates.top().pCurrentBuffer, pValue, nullptr);
}
}
}
@@ -590,7 +590,7 @@ void RTFDocumentImpl::runProps()
{
auto pValue
= new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms);
- m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_PROPS, pValue, nullptr));
+ bufferProperties(*m_aStates.top().pCurrentBuffer, pValue, nullptr);
}
// Delete the sprm, so the trackchange range will be started only once.
@@ -1145,7 +1145,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
else
{
auto pValue = new RTFValue(aAttributes, aSprms);
- m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_PROPS, pValue, nullptr));
+ bufferProperties(*m_aStates.top().pCurrentBuffer, pValue, nullptr);
}
}
@@ -1674,6 +1674,11 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer, RTFSprms* const pSprms,
}
else if (std::get<0>(aTuple) == BUFFER_PICTURE)
m_aStates.top().aPicture = std::get<1>(aTuple)->getPicture();
+ else if (std::get<0>(aTuple) == BUFFER_SETSTYLE)
+ {
+ if (!m_aStates.empty())
+ m_aStates.top().nCurrentStyleIndex = std::get<1>(aTuple)->getInt();
+ }
else
assert(false);
}
@@ -2123,7 +2128,7 @@ RTFError RTFDocumentImpl::popState()
else
{
auto pFFValue = new RTFValue(aFFAttributes, aFFSprms);
- m_aStates.top().pCurrentBuffer->push_back(Buf_t(BUFFER_PROPS, pFFValue, nullptr));
+ bufferProperties(*m_aStates.top().pCurrentBuffer, pFFValue, nullptr);
}
m_aFormfieldAttributes.clear();
m_aFormfieldSprms.clear();
@@ -2316,8 +2321,8 @@ RTFError RTFDocumentImpl::popState()
if (!m_aStates.top().pCurrentBuffer)
Mapper().props(new RTFReferenceProperties(lcl_getBookmarkProperties(nPos, aStr)));
else
- m_aStates.top().pCurrentBuffer->push_back(Buf_t(
- BUFFER_PROPS, new RTFValue(lcl_getBookmarkProperties(nPos, aStr)), nullptr));
+ bufferProperties(*m_aStates.top().pCurrentBuffer,
+ new RTFValue(lcl_getBookmarkProperties(nPos, aStr)), nullptr);
}
break;
case Destination::BOOKMARKEND:
@@ -2329,9 +2334,9 @@ RTFError RTFDocumentImpl::popState()
Mapper().props(new RTFReferenceProperties(
lcl_getBookmarkProperties(m_aBookmarks[aStr], aStr)));
else
- m_aStates.top().pCurrentBuffer->push_back(Buf_t(
- BUFFER_PROPS, new RTFValue(lcl_getBookmarkProperties(m_aBookmarks[aStr], aStr)),
- nullptr));
+ bufferProperties(*m_aStates.top().pCurrentBuffer,
+ new RTFValue(lcl_getBookmarkProperties(m_aBookmarks[aStr], aStr)),
+ nullptr);
}
break;
case Destination::INDEXENTRY:
@@ -3033,8 +3038,8 @@ RTFError RTFDocumentImpl::popState()
if (!m_aStates.top().pCurrentBuffer)
Mapper().props(new RTFReferenceProperties(RTFSprms(), aTCSprms));
else
- m_aStates.top().pCurrentBuffer->push_back(
- Buf_t(BUFFER_PROPS, new RTFValue(RTFSprms(), aTCSprms), nullptr));
+ bufferProperties(*m_aStates.top().pCurrentBuffer, new RTFValue(RTFSprms(), aTCSprms),
+ nullptr);
}
// This is the end of the doc, see if we need to close the last section.
@@ -3462,6 +3467,14 @@ RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl)
void RTFDocumentImpl::resetFrame() { m_aStates.top().aFrame = RTFFrame(&m_aStates.top()); }
+void RTFDocumentImpl::bufferProperties(RTFBuffer_t& rBuffer, const RTFValue::Pointer_t& pValue,
+ const tools::SvRef<TableRowBuffer>& pTableProperties)
+{
+ rBuffer.emplace_back(
+ Buf_t(BUFFER_SETSTYLE, new RTFValue(m_aStates.top().nCurrentStyleIndex), nullptr));
+ rBuffer.emplace_back(Buf_t(BUFFER_PROPS, pValue, pTableProperties));
+}
+
RTFPicture::RTFPicture() = default;
RTFShape::RTFShape() = default;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index cb957ef975b8..85fe37d18b63 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -76,6 +76,8 @@ enum class RTFBorderState
/// Different kind of buffers for table cell contents.
enum RTFBufferTypes
{
+ BUFFER_SETSTYLE,
+ /// Stores properties, should be created only in bufferProperties().
BUFFER_PROPS,
BUFFER_NESTROW,
BUFFER_CELLEND,
@@ -590,6 +592,9 @@ public:
bool isStyleSheetImport();
/// Resets m_aStates.top().aFrame.
void resetFrame();
+ /// Buffers properties to be sent later.
+ void bufferProperties(RTFBuffer_t& rBuffer, const RTFValue::Pointer_t& pValue,
+ const tools::SvRef<TableRowBuffer>& pTableProperties);
private:
SvStream& Strm();