summaryrefslogtreecommitdiffstats
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-05-11 23:24:22 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-05-12 12:50:25 +0200
commite702c78843e387d83fd9c8fbd1597cbe27e3e656 (patch)
tree4caac601e739070a35a643a977dc991260545c8c /writerfilter
parentjava dir for powepc64 and powepc64le can differ (diff)
downloadcore-e702c78843e387d83fd9c8fbd1597cbe27e3e656.tar.gz
core-e702c78843e387d83fd9c8fbd1597cbe27e3e656.zip
tdf#90260 writerfilter: pasted RTF documents may contain no \par
sw core is not yet adapted, will be done in the next commit. Change-Id: If8da12427e0cdaced4c1c1776b9f0b8cbde5c57c
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/inc/rtftok/RTFDocument.hxx3
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx3
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx4
-rw-r--r--writerfilter/source/filter/RtfFilter.cxx3
-rw-r--r--writerfilter/source/rtftok/rtfdocumentfactory.cxx5
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx13
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx6
7 files changed, 25 insertions, 12 deletions
diff --git a/writerfilter/inc/rtftok/RTFDocument.hxx b/writerfilter/inc/rtftok/RTFDocument.hxx
index bea19a4f7bc2..01a988029505 100644
--- a/writerfilter/inc/rtftok/RTFDocument.hxx
+++ b/writerfilter/inc/rtftok/RTFDocument.hxx
@@ -43,7 +43,8 @@ public:
css::uno::Reference<css::io::XInputStream> const& xInputStream,
css::uno::Reference<css::lang::XComponent> const& xDstDoc,
css::uno::Reference<css::frame::XFrame> const& xFrame,
- css::uno::Reference<css::task::XStatusIndicator> const& xStatusIndicator);
+ css::uno::Reference<css::task::XStatusIndicator> const& xStatusIndicator,
+ bool bIsNewDoc);
};
} // namespace rtftok
} // namespace writerfilter
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 70a59ed21df5..5634ff332167 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2651,7 +2651,8 @@ void DomainMapper::lcl_endSectionGroup()
m_pImpl->ExecuteFrameConversion();
// First paragraph in a footnote doesn't count: that would create
// additional paragraphs before and after the real footnote content.
- if(m_pImpl->GetIsFirstParagraphInSection() && !m_pImpl->IsInFootOrEndnote())
+ // Also, when pasting, it's fine to not have any paragraph inside the document at all.
+ if (m_pImpl->GetIsFirstParagraphInSection() && !m_pImpl->IsInFootOrEndnote() && m_pImpl->IsNewDoc())
{
// This section has no paragraph at all (e.g. they are all actually in a frame).
// If this section has a page break, there would be nothing to apply to the page
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 337930b5dac5..b0d4ca539066 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -266,7 +266,9 @@ DomainMapper_Impl::DomainMapper_Impl(
DomainMapper_Impl::~DomainMapper_Impl()
{
ChainTextFrames();
- RemoveLastParagraph( );
+ // Don't remove last paragraph when pasting, sw expects that empty paragraph.
+ if (m_bIsNewDoc)
+ RemoveLastParagraph();
getTableManager( ).endLevel();
popTableManager( );
}
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
index bea67c9608e6..7bf88b2d218f 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -147,7 +147,8 @@ sal_Bool RtfFilter::filter(const uno::Sequence< beans::PropertyValue >& aDescrip
writerfilter::dmapper::SourceDocumentType eType = writerfilter::dmapper::SourceDocumentType::RTF;
writerfilter::Stream::Pointer_t pStream(
writerfilter::dmapper::DomainMapperFactory::createMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, eType, xInsertTextRange, aMediaDesc));
- writerfilter::rtftok::RTFDocument::Pointer_t pDocument(writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator));
+ writerfilter::rtftok::RTFDocument::Pointer_t pDocument(
+ writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator, bIsNewDoc));
pDocument->resolve(*pStream);
bResult = true;
sal_uInt32 nEndTime = osl_getGlobalTimer();
diff --git a/writerfilter/source/rtftok/rtfdocumentfactory.cxx b/writerfilter/source/rtftok/rtfdocumentfactory.cxx
index ace9ad3f9a96..0722bff44ee3 100644
--- a/writerfilter/source/rtftok/rtfdocumentfactory.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentfactory.cxx
@@ -18,9 +18,10 @@ RTFDocument::Pointer_t RTFDocumentFactory::createDocument(css::uno::Reference< c
css::uno::Reference< css::io::XInputStream > const& xInputStream,
css::uno::Reference< css::lang::XComponent > const& xDstDoc,
css::uno::Reference< css::frame::XFrame > const& xFrame,
- css::uno::Reference< css::task::XStatusIndicator > const& xStatusIndicator)
+ css::uno::Reference< css::task::XStatusIndicator > const& xStatusIndicator,
+ bool bIsNewDoc)
{
- return std::make_shared<RTFDocumentImpl>(xContext, xInputStream, xDstDoc, xFrame, xStatusIndicator);
+ return std::make_shared<RTFDocumentImpl>(xContext, xInputStream, xDstDoc, xFrame, xStatusIndicator, bIsNewDoc);
}
} // namespace rtftok
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 72fc1fc8ff1a..625818cd88f7 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -211,7 +211,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
uno::Reference<io::XInputStream> const& xInputStream,
uno::Reference<lang::XComponent> const& xDstDoc,
uno::Reference<frame::XFrame> const& xFrame,
- uno::Reference<task::XStatusIndicator> const& xStatusIndicator)
+ uno::Reference<task::XStatusIndicator> const& xStatusIndicator,
+ bool bIsNewDoc)
: m_xContext(xContext),
m_xInputStream(xInputStream),
m_xDstDoc(xDstDoc),
@@ -271,7 +272,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
m_bHadPicture(false),
m_bHadSect(false),
m_nCellxMax(0),
- m_nListPictureId(0)
+ m_nListPictureId(0),
+ m_bIsNewDoc(bIsNewDoc)
{
OSL_ASSERT(xInputStream.is());
m_pInStream.reset(utl::UcbStreamHelper::CreateStream(xInputStream, true));
@@ -342,7 +344,7 @@ void RTFDocumentImpl::resolveSubstream(sal_Size nPos, Id nId, OUString& rIgnoreF
{
sal_Size nCurrent = Strm().Tell();
// Seek to header position, parse, then seek back.
- auto pImpl = std::make_shared<RTFDocumentImpl>(m_xContext, m_xInputStream, m_xDstDoc, m_xFrame, m_xStatusIndicator);
+ auto pImpl = std::make_shared<RTFDocumentImpl>(m_xContext, m_xInputStream, m_xDstDoc, m_xFrame, m_xStatusIndicator, m_bIsNewDoc);
pImpl->setSuperstream(this);
pImpl->setStreamType(nId);
pImpl->setIgnoreFirst(rIgnoreFirst);
@@ -570,7 +572,8 @@ void RTFDocumentImpl::sectBreak(bool bFinal = false)
bool bContinuous = pBreak.get() && pBreak->getInt() == static_cast<sal_Int32>(NS_ooxml::LN_Value_ST_SectionMark_continuous);
// If there is no paragraph in this section, then insert a dummy one, as required by Writer,
// unless this is the end of the doc, we had nothing since the last section break and this is not a continuous one.
- if (m_bNeedPar && !(bFinal && !m_bNeedSect && !bContinuous) && !isSubstream())
+ // Also, when pasting, it's fine to not have any paragraph inside the document at all.
+ if (m_bNeedPar && !(bFinal && !m_bNeedSect && !bContinuous) && !isSubstream() && m_bIsNewDoc)
dispatchSymbol(RTF_PAR);
// It's allowed to not have a non-table paragraph at the end of an RTF doc, add it now if required.
if (m_bNeedFinalPar && bFinal)
@@ -5765,7 +5768,7 @@ RTFError RTFDocumentImpl::popState()
{
// \par means an empty paragraph at the end of footnotes/endnotes, but
// not in case of other substreams, like headers.
- if (m_bNeedCr && !(m_nStreamType == NS_ooxml::LN_footnote || m_nStreamType == NS_ooxml::LN_endnote))
+ if (m_bNeedCr && !(m_nStreamType == NS_ooxml::LN_footnote || m_nStreamType == NS_ooxml::LN_endnote) && m_bIsNewDoc)
dispatchSymbol(RTF_PAR);
if (m_bNeedSect) // may be set by dispatchSymbol above!
sectBreak(true);
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 45d3f6fa9018..ae320adf5425 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -331,7 +331,8 @@ public:
css::uno::Reference<css::io::XInputStream> const& xInputStream,
css::uno::Reference<css::lang::XComponent> const& xDstDoc,
css::uno::Reference<css::frame::XFrame> const& xFrame,
- css::uno::Reference<css::task::XStatusIndicator> const& xStatusIndicator);
+ css::uno::Reference<css::task::XStatusIndicator> const& xStatusIndicator,
+ bool bIsNewDoc);
virtual ~RTFDocumentImpl();
// RTFDocument
@@ -590,6 +591,9 @@ private:
int m_nCellxMax;
/// ID of the next \listlevel picture.
int m_nListPictureId;
+
+ /// New document means not pasting into an existing one.
+ bool m_bIsNewDoc;
};
} // namespace rtftok
} // namespace writerfilter