[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sw/qa writerfilter/source
László Németh (via logerrit)
logerrit at kemper.freedesktop.org
Thu Feb 18 13:29:14 UTC 2021
sw/qa/extras/ooxmlexport/data/tdf132271.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 8 ++
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 2
writerfilter/source/dmapper/PropertyMap.cxx | 81 ++++++++++++++++++++++
4 files changed, 90 insertions(+), 1 deletion(-)
New commits:
commit 3908f51a95be1460612924cb2dd1b00cdb2ae2bc
Author: László Németh <nemeth at numbertext.org>
AuthorDate: Mon Sep 7 09:48:45 2020 +0200
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Feb 18 14:28:35 2021 +0100
tdf#132271 DOCX: import change tracking in floating tables
Change-Id: If892a16875ef16015639aacf8359d15c953fb1d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102149
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 288db6eb47fbbd2b3ca34ffea0686d8ed8ed9be9)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111138
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf132271.docx b/sw/qa/extras/ooxmlexport/data/tdf132271.docx
new file mode 100644
index 000000000000..202bfdda2ba0
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf132271.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 984564415989..10ea1017e577 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -970,6 +970,14 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf125894, "tdf125894.docx")
assertXPath(pXmlDoc, "//w:ins");
}
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf132271, "tdf132271.docx")
+{
+ xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+ // import change tracking in floating tables
+ assertXPath(pXmlDoc, "//w:del", 2);
+ assertXPath(pXmlDoc, "//w:ins", 2);
+}
+
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf128156, "tdf128156.docx")
{
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 07de495c68f2..48b5bd6fea53 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2619,7 +2619,7 @@ void DomainMapper_Impl::CreateRedline(uno::Reference<text::XTextRange> const& xR
uno::Reference < text::XRedline > xRedline( xRange, uno::UNO_QUERY_THROW );
xRedline->makeRedline( sType, aRedlineProperties );
}
- else
+ if (m_bIsActualParagraphFramed || (hasTableManager() && getTableManager().isInTable()))
{
aFramedRedlines.push_back( uno::makeAny(xRange) );
aFramedRedlines.push_back( uno::makeAny(sType) );
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index d510bfc8be35..a97933f7aeb3 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -45,8 +45,11 @@
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/WritingMode.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/text/XRedline.hpp>
#include <com/sun/star/text/XTextColumns.hpp>
#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XTextFrame.hpp>
+#include <com/sun/star/text/XTextTablesSupplier.hpp>
#include <com/sun/star/text/TextGridMode.hpp>
#include <com/sun/star/text/XTextCopy.hpp>
#include <com/sun/star/style/VerticalAlignment.hpp>
@@ -1355,15 +1358,93 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
rInfo.m_nBreakType = m_nBreakType;
if ( FloatingTableConversion( rDM_Impl, rInfo ) )
{
+ std::vector<css::uno::Any> aFramedRedlines = rDM_Impl.aFramedRedlines;
try
{
+ // convert redline ranges to cursor movement and character length
+ std::vector<sal_Int32> redPos, redLen;
+ std::vector<OUString> redCell;
+ OUString sTableName;
+ for( size_t i = 0; i < aFramedRedlines.size(); i+=3)
+ {
+ uno::Reference<text::XText> xCell;
+ uno::Reference< text::XTextRange > xRange;
+ aFramedRedlines[i] >>= xRange;
+ uno::Reference< beans::XPropertySet > xRangeProperties;
+ if ( xRange.is() )
+ {
+ xRangeProperties.set( xRange, uno::UNO_QUERY_THROW );
+
+ const uno::Sequence<beans::Property> aRangeProperties
+ = xRangeProperties->getPropertySetInfo()->getProperties();
+
+ for (const beans::Property& rProperty : aRangeProperties)
+ {
+ const OUString& rKey = rProperty.Name;
+ uno::Any aValue = xRangeProperties->getPropertyValue(rKey);
+ if ( rKey == "TextTable" )
+ {
+ uno::Reference<text::XTextTable> xTable;
+ aValue >>= xTable;
+ uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY);
+ xTableProperties->getPropertyValue("TableName") >>= sTableName;
+ }
+ else if ( rKey == "Cell" )
+ {
+ OUString sCellName;
+ aValue >>= xCell;
+ uno::Reference<beans::XPropertySet> xCellProperties(xCell, uno::UNO_QUERY);
+ xCellProperties->getPropertyValue("CellName") >>= sCellName;
+ redCell.push_back(sCellName);
+ }
+ }
+
+ uno::Reference<text::XTextCursor> xRangeCursor = xCell->createTextCursorByRange( xRange );
+ if ( xRangeCursor.is() )
+ {
+ sal_Int32 nLen = xRange->getString().getLength();
+ redLen.push_back(nLen);
+ xRangeCursor->gotoStart(true);
+ redPos.push_back(xRangeCursor->getString().getLength() - nLen);
+ }
+ else
+ {
+ // failed createTextCursorByRange()
+ redLen.push_back(-1);
+ redPos.push_back(-1);
+ }
+ }
+ }
+
xBodyText->convertToTextFrame(rInfo.m_xStart, rInfo.m_xEnd,
rInfo.m_aFrameProperties);
+
+ uno::Reference<text::XTextTablesSupplier> xTextDocument(rDM_Impl.GetTextDocument(), uno::UNO_QUERY);
+ uno::Reference<container::XNameAccess> xTables = xTextDocument->getTextTables();
+ uno::Reference<text::XTextTable> xTable(xTables->getByName(sTableName), uno::UNO_QUERY);
+ for( size_t i = 0; i < aFramedRedlines.size(); i+=3)
+ {
+ OUString sType;
+ beans::PropertyValues aRedlineProperties( 3 );
+ // skip failed createTextCursorByRange()
+ if (redPos[i/3] == -1)
+ continue;
+ aFramedRedlines[i+1] >>= sType;
+ aFramedRedlines[i+2] >>= aRedlineProperties;
+ uno::Reference<text::XText> xCell(xTable->getCellByName(redCell[i/3]), uno::UNO_QUERY);
+ uno::Reference<text::XTextCursor> xCrsr = xCell->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", "convertToTextFrame() failed");
}
+
+ aFramedRedlines.clear();
}
}
rPendingFloatingTables.clear();
More information about the Libreoffice-commits
mailing list