src/lib/MSPUBBlockID.h | 1 + src/lib/MSPUBCollector.cpp | 14 +++++++++++++- src/lib/MSPUBParser.cpp | 35 ++++++++++------------------------- src/lib/TableInfo.h | 8 ++++---- 4 files changed, 28 insertions(+), 30 deletions(-)
New commits: commit b5bab87065d029d8e1f7ddb214619511e2d1e23d Author: David Tardon <dtar...@redhat.com> Date: Fri Feb 13 14:26:48 2015 +0100 tdf#89061 parse table row/column sizes Change-Id: I5471eac69e89eec51018572ff3b541e6953c43be diff --git a/src/lib/MSPUBBlockID.h b/src/lib/MSPUBBlockID.h index c99f22a..a4cafa4 100644 --- a/src/lib/MSPUBBlockID.h +++ b/src/lib/MSPUBBlockID.h @@ -73,6 +73,7 @@ enum MSPUBBlockID // Don't be alarmed by multiple elements with the same value; TABLE_NUM_COLS = 0x67, TABLE_ROWCOL_ARRAY = 0x6D, TABLE_ROWCOL_OFFSET = 0x01, + TABLE_ROWCOL_SIZE = 0x02, FONT_CONTAINER_ARRAY = 0x02, EMBEDDED_EOT = 0x0C, EMBEDDED_FONT_NAME = 0x04, diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp index e2cd967..af6224f 100644 --- a/src/lib/MSPUBCollector.cpp +++ b/src/lib/MSPUBCollector.cpp @@ -1005,6 +1005,15 @@ boost::function<void(void)> MSPUBCollector::paintShape(const ShapeInfo &info, co if (isTable) { + librevenge::RVNGPropertyListVector columnWidths; + for (unsigned col = 0; col < (get(info.m_tableInfo).m_columnWidthsInEmu.size()); ++col) + { + librevenge::RVNGPropertyList columnWidth; + columnWidth.insert("style:column-width", double(get(info.m_tableInfo).m_columnWidthsInEmu[col]) / EMUS_IN_INCH); + columnWidths.append(columnWidth); + } + props.insert("librevenge:table-columns", columnWidths); + m_painter->startTableObject(props); const std::map<unsigned, std::vector<unsigned> >::const_iterator it = m_tableCellTextEndsByTextId.find(get(info.m_textId)); @@ -1019,7 +1028,10 @@ boost::function<void(void)> MSPUBCollector::paintShape(const ShapeInfo &info, co for (unsigned row = 0; row != tableLayout.shape()[0]; ++row) { - m_painter->openTableRow(librevenge::RVNGPropertyList()); + librevenge::RVNGPropertyList rowProps; + if (row < (get(info.m_tableInfo).m_rowHeightsInEmu.size())) + rowProps.insert("librevenge:row-height", double(get(info.m_tableInfo).m_rowHeightsInEmu[row]) / EMUS_IN_INCH); + m_painter->openTableRow(rowProps); for (unsigned col = 0; col != tableLayout.shape()[1]; ++col) { diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp index 2f2b805..b680f71 100644 --- a/src/lib/MSPUBParser.cpp +++ b/src/lib/MSPUBParser.cpp @@ -707,10 +707,8 @@ bool MSPUBParser::parseShape(librevenge::RVNGInputStream *input, unsigned nc = numCols.get(); unsigned rcao = rowcolArrayOffset.get(); unsigned csn = cellsSeqNum.get(); - std::vector<unsigned> rowOffsetsInEmu; - std::vector<unsigned> columnOffsetsInEmu; - unsigned rowFirstOffset = 0; - unsigned columnFirstOffset = 0; + std::vector<unsigned> rowHeightsInEmu; + std::vector<unsigned> columnWidthsInEmu; input->seek(rcao, librevenge::RVNG_SEEK_SET); unsigned arrayLength = readU32(input); while (stillReading(input, rcao + arrayLength)) @@ -722,30 +720,17 @@ bool MSPUBParser::parseShape(librevenge::RVNGInputStream *input, while (stillReading(input, info.dataOffset + info.dataLength)) { MSPUBBlockInfo subInfo = parseBlock(input, true); - if (subInfo.id == TABLE_ROWCOL_OFFSET) + if (subInfo.id == TABLE_ROWCOL_SIZE) { - unsigned rowcolOffset = readU32(input); - if (columnOffsetsInEmu.size() < nc) - { - if (columnOffsetsInEmu.empty()) - { - columnFirstOffset = rowcolOffset; - } - columnOffsetsInEmu.push_back(rowcolOffset - columnFirstOffset); - } - else if (rowOffsetsInEmu.size() < nr) - { - if (rowOffsetsInEmu.empty()) - { - rowFirstOffset = rowcolOffset; - } - rowOffsetsInEmu.push_back(rowcolOffset - rowFirstOffset); - } + if (columnWidthsInEmu.size() < nc) + columnWidthsInEmu.push_back(subInfo.data); + else if (rowHeightsInEmu.size() < nr) + rowHeightsInEmu.push_back(subInfo.data); } } } } - if (rowOffsetsInEmu.size() != nr || columnOffsetsInEmu.size() != nc) + if (rowHeightsInEmu.size() != nr || columnWidthsInEmu.size() != nc) { MSPUB_DEBUG_MSG(("ERROR: Wrong number of rows or columns found in table definition.\n")); return false; @@ -761,8 +746,8 @@ bool MSPUBParser::parseShape(librevenge::RVNGInputStream *input, } TableInfo ti(nr, nc); - ti.m_rowOffsetsInEmu = rowOffsetsInEmu; - ti.m_columnOffsetsInEmu = columnOffsetsInEmu; + ti.m_rowHeightsInEmu = rowHeightsInEmu; + ti.m_columnWidthsInEmu = columnWidthsInEmu; if (!index) { diff --git a/src/lib/TableInfo.h b/src/lib/TableInfo.h index 7869c7c..d661d16 100644 --- a/src/lib/TableInfo.h +++ b/src/lib/TableInfo.h @@ -33,13 +33,13 @@ struct CellInfo struct TableInfo { - std::vector<unsigned> m_rowOffsetsInEmu; - std::vector<unsigned> m_columnOffsetsInEmu; + std::vector<unsigned> m_rowHeightsInEmu; + std::vector<unsigned> m_columnWidthsInEmu; unsigned m_numRows; unsigned m_numColumns; std::vector<CellInfo> m_cells; - TableInfo(unsigned numRows, unsigned numColumns) : m_rowOffsetsInEmu(), - m_columnOffsetsInEmu(), m_numRows(numRows), m_numColumns(numColumns), + TableInfo(unsigned numRows, unsigned numColumns) : m_rowHeightsInEmu(), + m_columnWidthsInEmu(), m_numRows(numRows), m_numColumns(numColumns), m_cells() { } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits