[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Sun Aug 17 23:30:48 PDT 2014
sw/qa/extras/ooxmlimport/data/hidemark.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 13 ++++
writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 48 +++++++++++++++
writerfilter/source/dmapper/PropertyIds.cxx | 1
writerfilter/source/dmapper/PropertyIds.hxx | 1
writerfilter/source/dmapper/TablePropertiesHandler.cxx | 8 ++
6 files changed, 71 insertions(+)
New commits:
commit eff81a79fa09ce17ba77319b01e8a91a805a42c0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 14 13:54:18 2014 +0200
bnc#865381 DOCX import: handle <w:hideMark> table cell property
(cherry picked from commit d1278ef4849661b9ae0eb7aaf4d74fbf91ccaf11)
Conflicts:
writerfilter/source/dmapper/PropertyIds.cxx
writerfilter/source/dmapper/PropertyIds.hxx
Change-Id: Id0dd34110376168e34df4956869608895b86abfe
Reviewed-on: https://gerrit.libreoffice.org/10922
Reviewed-by: David Tardon <dtardon at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
diff --git a/sw/qa/extras/ooxmlimport/data/hidemark.docx b/sw/qa/extras/ooxmlimport/data/hidemark.docx
new file mode 100644
index 0000000..4a273d6
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/hidemark.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 1dc6161..fb82c8f 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2220,6 +2220,19 @@ DECLARE_OOXMLIMPORT_TEST(testFloatingTableSectionColumns, "floating-table-sectio
CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
}
+DECLARE_OOXMLIMPORT_TEST(testHidemark, "hidemark.docx")
+{
+ // Problem was that <w:hideMark> cell property was ignored.
+ uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
+ // Height should be minimal
+ CPPUNIT_ASSERT_EQUAL(convertTwipToMm100(MINLAY), getProperty<sal_Int64>(xTableRows->getByIndex(1), "Height"));
+ // Size type was MIN, should be FIX to avoid considering the end of paragraph marker.
+ CPPUNIT_ASSERT_EQUAL(text::SizeType::FIX, getProperty<sal_Int16>(xTableRows->getByIndex(1), "SizeType"));
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index a8650a5..33f70cc 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -29,9 +29,11 @@
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/SizeType.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
+#include <com/sun/star/text/XTextRangeCompare.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <dmapperLoggers.hxx>
#include <TablePositionHandler.hxx>
+#include <ConversionHelper.hxx>
#ifdef DEBUG_DMAPPER_TABLE_HANDLER
#include <PropertyMapHelper.hxx>
@@ -886,12 +888,50 @@ CellPropertyValuesSeq_t DomainMapperTableHandler::endTableGetCellProperties(Tabl
return aCellProperties;
}
+/// Do all cells in this row have a CellHideMark property?
+bool lcl_hideMarks(PropertyMapVector1& rCellProperties)
+{
+ for (size_t nCell = 0; nCell < rCellProperties.size(); ++nCell)
+ if (rCellProperties[nCell]->find(PROP_CELL_HIDE_MARK) == rCellProperties[nCell]->end())
+ return false;
+ return true;
+}
+
+/// Are all cells in this row empty?
+bool lcl_emptyRow(TableSequence_t& rTableSeq, sal_Int32 nRow)
+{
+ if (nRow >= rTableSeq.getLength())
+ {
+ SAL_WARN("writerfilter", "m_aCellProperties not in sync with m_pTableSeq?");
+ return false;
+ }
+
+ RowSequence_t rRowSeq = rTableSeq[nRow];
+ uno::Reference<text::XTextRangeCompare> xTextRangeCompare(rRowSeq[0][0]->getText(), uno::UNO_QUERY);
+ try
+ {
+ for (sal_Int32 nCell = 0; nCell < rRowSeq.getLength(); ++nCell)
+ // See SwXText::Impl::ConvertCell(), we need to compare the start of
+ // the start and the end of the end. However for our text ranges, only
+ // the starts are set, so compareRegionStarts() does what we need.
+ if (xTextRangeCompare->compareRegionStarts(rRowSeq[nCell][0], rRowSeq[nCell][1]) != 0)
+ return false;
+ }
+ catch (lang::IllegalArgumentException& e)
+ {
+ SAL_WARN("writerfilter", "compareRegionStarts() failed: " << e.Message);
+ return false;
+ }
+ return true;
+}
+
RowPropertyValuesSeq_t DomainMapperTableHandler::endTableGetRowProperties()
{
#ifdef DEBUG_DMAPPER_TABLE_HANDLER
dmapper_logger->startElement("getRowProperties");
#endif
+ static const int MINLAY = 23; // sw/inc/swtypes.hxx, minimal possible size of frames.
RowPropertyValuesSeq_t aRowProperties( m_aRowProperties.size() );
PropertyMapVector1::const_iterator aRowIter = m_aRowProperties.begin();
PropertyMapVector1::const_iterator aRowIterEnd = m_aRowProperties.end();
@@ -911,6 +951,14 @@ RowPropertyValuesSeq_t DomainMapperTableHandler::endTableGetRowProperties()
if (aIter != aRowIter->get()->end())
aRowIter->get()->erase(aIter);
+ if (lcl_hideMarks(m_aCellProperties[nRow]) && lcl_emptyRow(*m_pTableSeq, nRow))
+ {
+ // We have CellHideMark on all cells, and also all cells are empty:
+ // Set the row height to minimal as Word does.
+ (*aRowIter)->Insert(PROP_SIZE_TYPE, uno::makeAny(text::SizeType::FIX));
+ (*aRowIter)->Insert(PROP_HEIGHT, uno::makeAny(static_cast<sal_Int32>(ConversionHelper::convertTwipToMM100(MINLAY))));
+ }
+
aRowProperties[nRow] = (*aRowIter)->GetPropertyValues();
#ifdef DEBUG_DMAPPER_TABLE_HANDLER
((*aRowIter)->dumpXml( dmapper_logger ));
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index e5b9918..3f5fa05 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -393,6 +393,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
case PROP_TABLE_INTEROP_GRAB_BAG : sName = "TableInteropGrabBag"; break;
case PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING : sName = "ApplyParagraphMarkFormatToNumbering"; break;
case PROP_CELL_DIRECTION: sName = "CellDirection"; break;
+ case PROP_CELL_HIDE_MARK: sName = "CellHideMark"; break;
}
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index f1543be..3510e62 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -365,6 +365,7 @@ enum PropertyIds
,PROP_INDEX_ENTRY_TYPE
,PROP_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING
,PROP_CELL_DIRECTION
+ ,PROP_CELL_HIDE_MARK
};
struct PropertyNameSupplier_Impl;
class PropertyNameSupplier
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index 64172a0..21160f7 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -381,6 +381,14 @@ namespace dmapper {
}
}
break;
+ case NS_ooxml::LN_CT_TcPrBase_hideMark:
+ if (nIntValue)
+ {
+ TablePropertyMapPtr pPropMap(new TablePropertyMap());
+ pPropMap->Insert(PROP_CELL_HIDE_MARK, uno::makeAny(nIntValue));
+ cellProps(pPropMap);
+ }
+ break;
default:
// Not handled here, give the next handler a chance.
bRet = false;
More information about the Libreoffice-commits
mailing list