[Libreoffice-commits] .: Branch 'libreoffice-3-6' - writerfilter/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Mon Jun 25 08:21:48 PDT 2012
writerfilter/source/dmapper/DomainMapper.cxx | 11 +++++++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 31 ++++++++++++++++++++++
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 10 +++++++
writerfilter/source/dmapper/PropertyMap.cxx | 1
4 files changed, 53 insertions(+)
New commits:
commit ca555c596043c88894b964ac5e21f5a7271d5f3b
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Jun 25 15:58:11 2012 +0200
n#766481 dmapper: don't import fake paragraph containing sectpr only, take two
Change-Id: I4623dfd05498b5ba8de73b7e301eaf486f667738
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index f51ce3f..c11935d 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2795,6 +2795,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
case NS_ooxml::LN_CT_Style_rPr:
case NS_ooxml::LN_CT_PPr_rPr:
case NS_ooxml::LN_CT_PPrBase_numPr:
+ if (nSprmId == NS_ooxml::LN_CT_PPr_sectPr)
+ m_pImpl->SetParaSectpr(true);
resolveSprmProps(*this, rSprm);
break;
case NS_ooxml::LN_EG_SectPrContents_footnotePr:
@@ -3396,7 +3398,16 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len)
// RTF always uses text() instead of utext() for run break
if(len == 1 && ((*data_) == 0x0d || (*data_) == 0x07) && !IsRTFImport())
+ {
+ bool bSingleParagraph = m_pImpl->GetIsFirstParagraphInSection() && m_pImpl->GetIsLastParagraphInSection();
+ // If the paragraph contains only the section properties and it has
+ // no runs, we should not create a paragraph for it in Writer, unless that would remove the whole section.
+ bool bRemove = !m_pImpl->GetParaChanged() && m_pImpl->GetParaSectpr() && !bSingleParagraph;
+ m_pImpl->SetParaSectpr(false);
m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH));
+ if (bRemove)
+ m_pImpl->RemoveLastParagraph();
+ }
else
{
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 0f9af17..897402c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -206,7 +206,9 @@ DomainMapper_Impl::DomainMapper_Impl(
m_bIsCustomFtnMark( false ),
m_bIsParaChange( false ),
m_bParaChanged( false ),
+ m_bIsFirstParaInSection( true ),
m_bIsLastParaInSection( false ),
+ m_bParaSectpr( false ),
m_bUsingEnhancedFields( false )
{
appendTableManager( );
@@ -307,7 +309,35 @@ void DomainMapper_Impl::SetIsLastParagraphInSection( bool bIsLast )
m_bIsLastParaInSection = bIsLast;
}
+bool DomainMapper_Impl::GetIsLastParagraphInSection()
+{
+ return m_bIsLastParaInSection;
+}
+
+void DomainMapper_Impl::SetIsFirstParagraphInSection( bool bIsFirst )
+{
+ m_bIsFirstParaInSection = bIsFirst;
+}
+
+bool DomainMapper_Impl::GetIsFirstParagraphInSection()
+{
+ return m_bIsFirstParaInSection;
+}
+void DomainMapper_Impl::SetParaSectpr(bool bParaSectpr)
+{
+ m_bParaSectpr = bParaSectpr;
+}
+
+bool DomainMapper_Impl::GetParaSectpr()
+{
+ return m_bParaSectpr;
+}
+
+bool DomainMapper_Impl::GetParaChanged()
+{
+ return m_bParaChanged;
+}
void DomainMapper_Impl::PushProperties(ContextType eId)
{
@@ -1030,6 +1060,7 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
uno::Reference< text::XTextRange > xParaEnd( xCur, uno::UNO_QUERY );
CheckParaRedline( xParaEnd );
+ m_bIsFirstParaInSection = false;
m_bIsLastParaInSection = false;
m_bParaChanged = false;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 77a2b62..0cfee56 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -349,8 +349,12 @@ private:
RedlineParamsPtr m_pParaRedline;
bool m_bIsParaChange;
+ /// If the current paragraph has any runs.
bool m_bParaChanged;
+ bool m_bIsFirstParaInSection;
bool m_bIsLastParaInSection;
+ /// If the current paragraph contains section property definitions.
+ bool m_bParaSectpr;
bool m_bUsingEnhancedFields;
//annotation import
@@ -406,6 +410,12 @@ public:
void RemoveLastParagraph( );
void SetIsLastParagraphInSection( bool bIsLast );
+ bool GetIsLastParagraphInSection();
+ void SetIsFirstParagraphInSection( bool bIsFirst );
+ bool GetIsFirstParagraphInSection();
+ void SetParaSectpr(bool bParaSectpr);
+ bool GetParaSectpr();
+ bool GetParaChanged();
void deferBreak( BreakType deferredBreakType );
bool isBreakDeferred( BreakType deferredBreakType );
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 913eaac..2d3d4cb 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1025,6 +1025,7 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
OSL_FAIL( "Exception in SectionPropertyMap::CloseSectionGroup");
}
}
+ rDM_Impl.SetIsFirstParagraphInSection(true);
}
More information about the Libreoffice-commits
mailing list