[Libreoffice-commits] .: 2 commits - sw/qa writerfilter/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Mon Jun 25 07:03:48 PDT 2012
sw/qa/extras/ooxmltok/data/n766481.docx |binary
sw/qa/extras/ooxmltok/ooxmltok.cxx | 21 ++++++++++++++
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
6 files changed, 74 insertions(+)
New commits:
commit 0eb3a0f2fa66e67f21035c5c14a41d2d6fb4b345
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Jun 25 16:01:37 2012 +0200
n#766481 testcase
Change-Id: I0ebcb5c35f2e255da593c62b0a98cd4e0f44ba99
diff --git a/sw/qa/extras/ooxmltok/data/n766481.docx b/sw/qa/extras/ooxmltok/data/n766481.docx
new file mode 100644
index 0000000..e1521ec
Binary files /dev/null and b/sw/qa/extras/ooxmltok/data/n766481.docx differ
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index 4cd2aa3..1d1bbb1 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -71,6 +71,7 @@ public:
void testN764745();
void testN766477();
void testN758883();
+ void testN766481();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -92,6 +93,7 @@ public:
CPPUNIT_TEST(testN764745);
CPPUNIT_TEST(testN766477);
CPPUNIT_TEST(testN758883);
+ CPPUNIT_TEST(testN766481);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -605,6 +607,25 @@ void Test::testN758883()
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, eAnchorType);
}
+void Test::testN766481()
+{
+ /*
+ * The problem was that we had an additional paragraph before the pagebreak.
+ *
+ * oParas = ThisComponent.Text.createEnumeration
+ * oPara = oParas.nextElement
+ * oPara = oParas.nextElement
+ * xray oParas.hasMoreElements ' should be false
+ */
+ load("n766481.docx");
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum(xParaEnumAccess->createEnumeration());
+ for (int i = 0; i < 2; ++i)
+ xParaEnum->nextElement();
+ CPPUNIT_ASSERT_EQUAL(sal_False, xParaEnum->hasMoreElements());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
commit b696600821d8aafb63b6a88016d299ef89478f56
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 8e6d2c6..776aaba 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