[Libreoffice-commits] core.git: sw/qa writerfilter/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 18 12:43:19 UTC 2019
sw/qa/extras/ooxmlexport/data/tdf125894.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 8 +++
writerfilter/source/dmapper/DomainMapper.cxx | 2
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 47 ++++++++++++++++++++--
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 5 ++
5 files changed, 59 insertions(+), 3 deletions(-)
New commits:
commit e8bae67b3dbcc90ace8264b6b1aefaf0ce459aba
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Wed Jul 17 13:37:44 2019 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Thu Jul 18 14:42:07 2019 +0200
tdf#125894: DOCX: import tracked changes in frames
Tracked changes weren't imported in frames, losing also
the actual text content: also tracked deletion reappeared
as normal text here, not only the tracked insertions.
Change-Id: I5fc8135cfb7402ad71c5c24eae606aa7ed707dfc
Reviewed-on: https://gerrit.libreoffice.org/75779
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf125894.docx b/sw/qa/extras/ooxmlexport/data/tdf125894.docx
new file mode 100644
index 000000000000..1214f2c09cb7
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf125894.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 98e137327787..c542a7b4394b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -883,6 +883,14 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf126245, "tdf126245.docx")
assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange/w:pPr/w:numPr/w:numId", "val", "1");
}
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf125894, "tdf125894.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ // import change tracking in frames
+ assertXPath(pXmlDoc, "//w:del", 2);
+ assertXPath(pXmlDoc, "//w:ins");
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf118691, "tdf118691.docx")
{
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 173a0a1f99aa..f219330d52a2 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1991,6 +1991,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const PropertyMapPtr& rContext )
ParagraphPropertyMap* pParaContext = dynamic_cast< ParagraphPropertyMap* >( pContext.get() );
if (pParaContext)
pParaContext->SetFrameMode();
+
+ m_pImpl->m_bIsActualParagraphFramed = true;
}
else
{
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 51b5c1e2cf96..21beb6965bf9 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -251,6 +251,7 @@ DomainMapper_Impl::DomainMapper_Impl(
m_bCheckFirstFootnoteTab(false),
m_bIgnoreNextTab(false),
m_bIsSplitPara(false),
+ m_bIsActualParagraphFramed( false ),
m_vTextFramesForChaining(),
m_bParaHadField(false),
m_bParaAutoBefore(false),
@@ -2085,7 +2086,6 @@ void DomainMapper_Impl::CreateRedline(uno::Reference<text::XTextRange> const& xR
default:
throw lang::IllegalArgumentException("illegal redline token type", nullptr, 0);
}
- uno::Reference < text::XRedline > xRedline( xRange, uno::UNO_QUERY_THROW );
beans::PropertyValues aRedlineProperties( 3 );
beans::PropertyValue * pRedlineProperties = aRedlineProperties.getArray( );
pRedlineProperties[0].Name = getPropertyName( PROP_REDLINE_AUTHOR );
@@ -2094,7 +2094,17 @@ void DomainMapper_Impl::CreateRedline(uno::Reference<text::XTextRange> const& xR
pRedlineProperties[1].Value <<= ConversionHelper::ConvertDateStringToDateTime( pRedline->m_sDate );
pRedlineProperties[2].Name = getPropertyName( PROP_REDLINE_REVERT_PROPERTIES );
pRedlineProperties[2].Value <<= pRedline->m_aRevertProperties;
- xRedline->makeRedline( sType, aRedlineProperties );
+ if (!m_bIsActualParagraphFramed)
+ {
+ uno::Reference < text::XRedline > xRedline( xRange, uno::UNO_QUERY_THROW );
+ xRedline->makeRedline( sType, aRedlineProperties );
+ }
+ else
+ {
+ aFramedRedlines.push_back( uno::makeAny(xRange) );
+ aFramedRedlines.push_back( uno::makeAny(sType) );
+ aFramedRedlines.push_back( uno::makeAny(aRedlineProperties) );
+ }
}
catch( const uno::Exception & )
{
@@ -5709,15 +5719,46 @@ void DomainMapper_Impl::ExecuteFrameConversion()
try
{
uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert( GetTopTextAppend(), uno::UNO_QUERY_THROW );
- xTextAppendAndConvert->convertToTextFrame(
+ // convert redline ranges to cursor movement and character length
+ std::vector<sal_Int32> redPos, redLen;
+ for( size_t i = 0; i < aFramedRedlines.size(); i+=3)
+ {
+ uno::Reference< text::XTextRange > xRange;
+ aFramedRedlines[i] >>= xRange;
+ uno::Reference<text::XTextCursor> xRangeCursor = GetTopTextAppend()->createTextCursorByRange( xRange );
+ sal_Int32 nLen = xRange->getString().getLength();
+ redLen.push_back(nLen);
+ xRangeCursor->gotoRange(m_xFrameStartRange, true);
+ redPos.push_back(xRangeCursor->getString().getLength() - nLen);
+ }
+
+ const uno::Reference< text::XTextContent >& xTextContent = xTextAppendAndConvert->convertToTextFrame(
m_xFrameStartRange,
m_xFrameEndRange,
comphelper::containerToSequence(m_aFrameProperties) );
+
+ // create redlines in the previous frame
+ for( size_t i = 0; i < aFramedRedlines.size(); i+=3)
+ {
+ OUString sType;
+ beans::PropertyValues aRedlineProperties( 3 );
+ aFramedRedlines[i+1] >>= sType;
+ aFramedRedlines[i+2] >>= aRedlineProperties;
+ uno::Reference< text::XTextFrame > xFrame( xTextContent, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextCursor > xCrsr = xFrame->getText()->createTextCursor();
+ xCrsr->goRight(redPos[i/3], false);
+ xCrsr->goRight(redLen[i/3], true);
+ uno::Reference < text::XRedline > xRedline( xCrsr, uno::UNO_QUERY_THROW );
+ xRedline->makeRedline( sType, aRedlineProperties );
+ }
}
catch( const uno::Exception&)
{
DBG_UNHANDLED_EXCEPTION( "writerfilter.dmapper", "Exception caught when converting to frame");
}
+
+ m_bIsActualParagraphFramed = false;
+ aFramedRedlines.clear();
}
m_xFrameStartRange = nullptr;
m_xFrameEndRange = nullptr;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 040b8df0cc28..185c143af47b 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -1004,6 +1004,11 @@ public:
/// start/end node.
void ClearPreviousParagraph();
+ /// Handle redline text portions in frames:
+ /// store their data, and create them after frame creation
+ bool m_bIsActualParagraphFramed;
+ std::vector<css::uno::Any> aFramedRedlines;
+
private:
void PushPageHeaderFooter(bool bHeader, SectionPropertyMap::PageType eType);
std::vector<css::uno::Reference< css::drawing::XShape > > m_vTextFramesForChaining ;
More information about the Libreoffice-commits
mailing list