sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 2 - writerfilter/source/dmapper/DomainMapper_Impl.cxx | 28 +++++++++++++++++++++- writerfilter/source/dmapper/DomainMapper_Impl.hxx | 2 + 3 files changed, 30 insertions(+), 2 deletions(-)
New commits: commit fc3eb493ac9e8dec35060524db4dc8ca3210631a Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Jul 15 18:18:19 2014 +0200 Related: bnc#875718 DOCX import: fix missing character grab-bag on fields The problem was that in case: 1) The paragraph only had a single text portion, which was a field and char grab-bag was set on it and 2) The paragraph had a style which also set the character grab-bag then during import the field's gra-bag was set on the paragraph (as it's the only portion) and later the paragraph style overwrote this, in case that had a grab-bag, too. Work this around by ensuring that in case of portion fields (i.e. not ToC, which has its own paragraphs), there are always at least two portions in a paragraph (the second is removed later). This also fixes the fake paragraph problem at the end of the bnc#875718 testcase. (There was an empty paragraph at the end of the document, but not in the file itself.) Change-Id: Ie404bc043d46157ea6157b18c4a46395cf496118 diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 8d85f1d..efbfebb 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2190,7 +2190,7 @@ DECLARE_OOXMLIMPORT_TEST(testBnc875718, "bnc875718.docx") // Also check that the footer contents are not in the body text. uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XText> text(textDocument->getText(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL( OUString( "Text\n" ), text->getString()); + CPPUNIT_ASSERT_EQUAL( OUString( "Text" ), text->getString()); } DECLARE_OOXMLIMPORT_TEST(testCaption, "caption.docx") diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index e74383e..6645e23 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -208,7 +208,8 @@ DomainMapper_Impl::DomainMapper_Impl( m_bIgnoreNextTab(false), m_bFrameBtLr(false), m_bIsSplitPara(false), - m_vTextFramesForChaining() + m_vTextFramesForChaining(), + m_bParaHadField(false) { appendTableManager( ); @@ -1112,7 +1113,27 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap ) rAppendContext.pLastParagraphProperties->SetEndingRange(xTextRange->getEnd()); } else + { + uno::Reference<text::XTextCursor> xCursor; + if (m_bParaHadField) + { + // Workaround to make sure char props of the field are not lost. + OUString sMarker("X"); + xCursor = xTextAppend->getText()->createTextCursor(); + if (xCursor.is()) + xCursor->gotoEnd(false); + PropertyMapPtr pEmpty(new PropertyMap()); + appendTextPortion("X", pEmpty); + } + xTextRange = xTextAppend->finishParagraph( aProperties ); + + if (xCursor.is()) + { + xCursor->goLeft(1, true); + xCursor->setString(OUString()); + } + } getTableManager( ).handle(xTextRange); // Get the end of paragraph character inserted @@ -1153,6 +1174,7 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap ) } SetIsOutsideAParagraph(true); + m_bParaHadField = false; #ifdef DEBUG_DOMAINMAPPER dmapper_logger->endElement(); #endif @@ -2426,6 +2448,7 @@ uno::Reference< beans::XPropertySet > DomainMapper_Impl::FindOrCreateFieldMaster -----------------------------------------------------------------------*/ void DomainMapper_Impl::PushFieldContext() { + m_bParaHadField = true; if(m_bDiscardHeaderFooter) return; #ifdef DEBUG_DOMAINMAPPER @@ -3134,6 +3157,7 @@ void DomainMapper_Impl::handleToc } } pContext->SetTOC( xTOC ); + m_bParaHadField = false; OUString sMarker("Y"); //insert index @@ -3171,6 +3195,7 @@ void DomainMapper_Impl::handleBibliography xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ), uno::makeAny(OUString())); pContext->SetTOC( xTOC ); + m_bParaHadField = false; uno::Reference< text::XTextContent > xToInsert( xTOC, uno::UNO_QUERY ); appendTextContent(xToInsert, uno::Sequence< beans::PropertyValue >() ); @@ -3215,6 +3240,7 @@ void DomainMapper_Impl::handleIndex } } pContext->SetTOC( xTOC ); + m_bParaHadField = false; uno::Reference< text::XTextContent > xToInsert( xTOC, uno::UNO_QUERY ); appendTextContent(xToInsert, uno::Sequence< beans::PropertyValue >() ); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index e577c86..60c8c65 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -812,6 +812,8 @@ public: private: void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType); std::vector<css::uno::Reference< css::drawing::XShape > > m_vTextFramesForChaining ; + /// Current paragraph had at least one field in it. + bool m_bParaHadField; }; // export just for test _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits