sw/qa/extras/ooxmlimport/data/hidemark.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 13 ++++ sw/source/filter/ww8/rtfsdrexport.cxx | 4 - writerfilter/source/dmapper/DomainMapperTableHandler.cxx | 48 +++++++++++++++ writerfilter/source/dmapper/PropertyIds.cxx | 1 writerfilter/source/dmapper/PropertyIds.hxx | 1 writerfilter/source/dmapper/TablePropertiesHandler.cxx | 8 ++ 7 files changed, 72 insertions(+), 3 deletions(-)
New commits: commit d1278ef4849661b9ae0eb7aaf4d74fbf91ccaf11 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Aug 14 13:54:18 2014 +0200 bnc#865381 DOCX import: handle <w:hideMark> table cell property Change-Id: Id0dd34110376168e34df4956869608895b86abfe 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 371b303..7c8f13b 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -2320,6 +2320,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 8a121fa..0daa890 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_DOMAINMAPPER #include <PropertyMapHelper.hxx> @@ -804,12 +806,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]->isSet(PROP_CELL_HIDE_MARK)) + 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_DOMAINMAPPER 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(); @@ -826,6 +866,14 @@ RowPropertyValuesSeq_t DomainMapperTableHandler::endTableGetRowProperties() // tblHeader is only our property, remove before the property map hits UNO (*aRowIter)->Erase(PROP_TBL_HEADER); + 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_DOMAINMAPPER ((*aRowIter)->dumpXml( dmapper_logger )); diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index e95eaec..8ce4a73 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -399,6 +399,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const case PROP_PARA_CNF_STYLE: sName = "ParaCnfStyle"; break; case PROP_CELL_CNF_STYLE: sName = "CellCnfStyle"; break; case PROP_ROW_CNF_STYLE: sName = "RowCnfStyle"; 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 f9d65da..bfba954 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -371,6 +371,7 @@ enum PropertyIds ,PROP_PARA_CNF_STYLE ,PROP_CELL_CNF_STYLE ,PROP_ROW_CNF_STYLE + ,PROP_CELL_HIDE_MARK }; struct PropertyNameSupplier_Impl; class PropertyNameSupplier diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx index 8581ac0..6776a3a 100644 --- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx +++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx @@ -384,6 +384,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; commit ffdc8780eba3ec34e502b01b9a54401627ee25c5 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Aug 14 13:53:46 2014 +0200 fix indentation Change-Id: I93fffff150e76a20decf2dd418f4cbd2b7418735 diff --git a/sw/source/filter/ww8/rtfsdrexport.cxx b/sw/source/filter/ww8/rtfsdrexport.cxx index b32dae2..2b8e5fb 100644 --- a/sw/source/filter/ww8/rtfsdrexport.cxx +++ b/sw/source/filter/ww8/rtfsdrexport.cxx @@ -451,9 +451,7 @@ void RtfSdrExport::impl_writeGraphic() return; } OString aURLBS(OUStringToOString(sGraphicURL, RTL_TEXTENCODING_UTF8)); - Graphic aGraphic = GraphicObject( - aURLBS.copy(RTL_CONSTASCII_LENGTH("vnd.sun.star.GraphicObject:"))) - .GetTransformedGraphic(); + Graphic aGraphic = GraphicObject(aURLBS.copy(RTL_CONSTASCII_LENGTH("vnd.sun.star.GraphicObject:"))).GetTransformedGraphic(); // Export it to a stream. SvMemoryStream aStream; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits