Kaydet (Commit) 92863700 authored tarafından László Németh's avatar László Németh

tdf#121623 RTF import: keep table in multicolumn section

instead of losing columns when the section starts with that table.

Change-Id: I1c9d4eb03d24e54600956cb41b835c5e37bfdd8b
Reviewed-on: https://gerrit.libreoffice.org/65730
Tested-by: Jenkins
Reviewed-by: 's avatarLászló Németh <nemeth@numbertext.org>
üst 6f967e34
This diff is collapsed.
......@@ -193,6 +193,12 @@ DECLARE_RTFEXPORT_TEST(testTdf112520, "tdf112520.docx")
getProperty<text::TextContentAnchorType>(getShape(3), "AnchorType"));
}
DECLARE_RTFEXPORT_TEST(testTdf121623, "tdf121623.rtf")
{
// This was 2, multicolumn section was ignored at the table.
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -44,6 +44,7 @@
#include "rtfreferenceproperties.hxx"
#include "rtfskipdestination.hxx"
#include "rtftokenizer.hxx"
#include "rtflookahead.hxx"
using namespace com::sun::star;
......@@ -258,6 +259,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
, m_aDefaultState(this)
, m_bSkipUnknown(false)
, m_bFirstRun(true)
, m_bFirstRunException(false)
, m_bNeedPap(true)
, m_bNeedCr(false)
, m_bNeedCrOrig(false)
......@@ -377,7 +379,7 @@ void RTFDocumentImpl::checkFirstRun()
outputSettingsTable();
// start initial paragraph
m_bFirstRun = false;
assert(!m_bNeedSect);
assert(!m_bNeedSect || m_bFirstRunException);
setNeedSect(true); // first call that succeeds
// set the requested default font, if there are none
......@@ -397,8 +399,18 @@ void RTFDocumentImpl::setNeedPar(bool bNeedPar) { m_bNeedPar = bNeedPar; }
void RTFDocumentImpl::setNeedSect(bool bNeedSect)
{
if (!m_bNeedSect && bNeedSect && m_bFirstRun)
{
RTFLookahead aLookahead(Strm(), m_pTokenizer->getGroupStart());
if (aLookahead.hasTable() && aLookahead.hasColumns())
{
m_bFirstRunException = true;
}
}
// ignore setting before checkFirstRun - every keyword calls setNeedSect!
if (!m_bNeedSect && bNeedSect && !m_bFirstRun)
// except the case of a table in a multicolumn section
if (!m_bNeedSect && bNeedSect && (!m_bFirstRun || m_bFirstRunException))
{
if (!m_pSuperstream) // no sections in header/footer!
{
......
......@@ -570,7 +570,10 @@ private:
std::map<int, Id> m_aStyleTypes;
/// Color index <-> RGB color value map
std::vector<Color> m_aColorTable;
/// to start initial paragraph / section after font/style tables
bool m_bFirstRun;
/// except in the case of tables in initial multicolumn section (global for assertion)
bool m_bFirstRunException;
/// If paragraph properties should be emitted on next run.
bool m_bNeedPap;
/// If we need to emit a CR at the end of substream.
......
......@@ -35,6 +35,7 @@ namespace rtftok
RTFLookahead::RTFLookahead(SvStream& rStream, sal_uInt64 nGroupStart)
: m_rStream(rStream)
, m_bHasTable(false)
, m_bHasColumns(false)
{
sal_uInt64 const nPos = m_rStream.Tell();
m_rStream.Seek(nGroupStart);
......@@ -62,8 +63,10 @@ RTFError RTFLookahead::dispatchToggle(RTFKeyword /*nKeyword*/, bool /*bParam*/,
return RTFError::OK;
}
RTFError RTFLookahead::dispatchValue(RTFKeyword /*nKeyword*/, int /*nParam*/)
RTFError RTFLookahead::dispatchValue(RTFKeyword nKeyword, int nParam)
{
if (nKeyword == RTF_COLS && nParam >= 2)
m_bHasColumns = true;
return RTFError::OK;
}
......
......@@ -48,11 +48,13 @@ public:
void finishSubstream() override;
bool isSubstream() const override;
bool hasTable() { return m_bHasTable; }
bool hasColumns() { return m_bHasColumns; }
private:
tools::SvRef<RTFTokenizer> m_pTokenizer;
SvStream& m_rStream;
bool m_bHasTable;
bool m_bHasColumns;
};
} // namespace rtftok
} // namespace writerfilter
......
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