summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-08-14 13:54:18 +0200
committerDavid Tardon <dtardon@redhat.com>2014-08-18 01:30:27 -0500
commiteff81a79fa09ce17ba77319b01e8a91a805a42c0 (patch)
treef8de6e8b99ca5941127ac7999680763f6fc02a7c /writerfilter
parent55fd7b2d236dc6dc09676b7dce60dc4e2e1786fc (diff)
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@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx48
-rw-r--r--writerfilter/source/dmapper/PropertyIds.cxx1
-rw-r--r--writerfilter/source/dmapper/PropertyIds.hxx1
-rw-r--r--writerfilter/source/dmapper/TablePropertiesHandler.cxx8
4 files changed, 58 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index a8650a52d86d..33f70cc9cbd0 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 e5b9918adfb1..3f5fa0571cdd 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 f1543befba4f..3510e6274771 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 64172a0a4d56..21160f753fdf 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;