summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-07-10 18:52:42 +0200
committerLászló Németh <nemeth@numbertext.org>2020-07-14 13:02:13 +0200
commit616a47c9570f9ce67b18a124f08f4a342bff3468 (patch)
treea3c43e756b31dfa7f78cfaf61fe95d597433b41b /writerfilter
parentacedfab7a3fc0f49a77d674e393ff63125dc0d9b (diff)
tdf#134793 DOCX import: fix numbering with inline images
before page break. Previous fix for tdf#118701 didn't keep numbering of the paragraph marked for deletion. This reverts commit b216fc5b583050cfb1cdf9bd82ec3c1bd2e09d70 (tdf#118701 DOCX import: fix image position on page break). Change-Id: I5bde927f15b4b1f682d81482734fadff7690f6d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98541 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx5
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx22
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.hxx5
3 files changed, 12 insertions, 20 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 5df7bb33b1ae..65b0b4a86a83 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3500,7 +3500,8 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
&& !bSingleParagraphAfterRedline
&& !m_pImpl->GetIsDummyParaAddedForTableInSection()
&& !( pSectionContext && pSectionContext->GetBreakType() != -1 && pContext && pContext->isSet(PROP_BREAK_TYPE) )
- && !m_pImpl->GetIsPreviousParagraphFramed());
+ && !m_pImpl->GetIsPreviousParagraphFramed()
+ && !m_pImpl->IsParaWithInlineObject());
const bool bNoNumbering = bRemove || (!m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() && bSingleParagraph);
PropertyMapPtr xContext = bNoNumbering ? m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH) : PropertyMapPtr();
@@ -3516,7 +3517,7 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
}
m_pImpl->SetParaSectpr(false);
finishParagraph(bRemove);
- if (bRemove && m_pImpl->IsLastParaEmpty())
+ if (bRemove)
m_pImpl->RemoveLastParagraph();
}
else
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 777006bb58de..25820d086c12 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -309,7 +309,8 @@ DomainMapper_Impl::DomainMapper_Impl(
m_bParaHadField(false),
m_bParaAutoBefore(false),
m_bFirstParagraphInCell(true),
- m_bSaveFirstParagraphInCell(false)
+ m_bSaveFirstParagraphInCell(false),
+ m_bParaWithInlineObject(false)
{
m_aBaseUrl = rMediaDesc.getUnpackedValueOrDefault(
@@ -474,22 +475,6 @@ void DomainMapper_Impl::AddDummyParaForTableInSection()
}
}
-bool DomainMapper_Impl::IsLastParaEmpty()
-{
- bool bRet = true;
- if (!m_aTextAppendStack.empty() && m_aTextAppendStack.top().xTextAppend)
- {
- //creating cursor for finding text content
- uno::Reference<text::XTextCursor> xCursor = m_aTextAppendStack.top().xTextAppend->createTextCursor();
- xCursor->gotoEnd(false);
- //selecting the last 2 characters in the document
- xCursor->goLeft(2, true);
- //the last paragraph is empty, if they are newlines
- bRet = xCursor->getString().match(OUString(SAL_NEWLINE_STRING).concat(SAL_NEWLINE_STRING));
- }
- return bRet;
-}
-
void DomainMapper_Impl::RemoveLastParagraph( )
{
if (m_bDiscardHeaderFooter)
@@ -2056,6 +2041,7 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con
m_bFirstParagraphInCell = false;
m_bParaAutoBefore = false;
+ m_bParaWithInlineObject = false;
#ifdef DBG_UTIL
TagLogger::getInstance().endElement();
@@ -6600,6 +6586,8 @@ void DomainMapper_Impl::ImportGraphic(const writerfilter::Reference< Properties
}
m_aTextAppendStack.top().m_aAnchoredObjects.push_back(aInfo);
}
+ else if (eGraphicImportType == IMPORT_AS_DETECTED_INLINE)
+ m_bParaWithInlineObject = true;
}
// Clear the reference, so in case the embedded object is inside a
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index e145547f3ddd..9886f7665c6b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -626,7 +626,6 @@ public:
void RemoveDummyParaForTableInSection();
void AddDummyParaForTableInSection();
- bool IsLastParaEmpty();
void RemoveLastParagraph( );
void SetIsLastParagraphInSection( bool bIsLast );
bool GetIsLastParagraphInSection() const { return m_bIsLastParaInSection;}
@@ -1063,6 +1062,8 @@ public:
bool m_bIsActualParagraphFramed;
std::vector<css::uno::Any> aFramedRedlines;
+ bool IsParaWithInlineObject() const { return m_bParaWithInlineObject; }
+
private:
void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType);
// Start a new index section; if needed, finish current paragraph
@@ -1076,6 +1077,8 @@ private:
/// Current paragraph in a table is first paragraph of a cell
bool m_bFirstParagraphInCell;
bool m_bSaveFirstParagraphInCell;
+ /// Current paragraph had at least one inline object in it.
+ bool m_bParaWithInlineObject;
};
} //namespace dmapper