summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Eric Pelloux-Prayer <pierre-eric@lanedo.com>2012-09-20 11:49:29 +0200
committerC├ędric Bosdonnat <cedric.bosdonnat@free.fr>2012-09-20 18:20:18 +0200
commit53b7f7df0617bcbd7bbef9a34ef53e5097eb16dc (patch)
treed7dc599a9a9b566275dcc40af28c1dbe80dd85f9
parent064ae986a0aa55db9f3ee829a7c83bf2ac65c77f (diff)
docx import: position table using tblInd OR tblCellMar
Previously cell-margin was unconditionnaly used to compute table position. Office only does so on top-level tables and if tblInd is missing. Change-Id: I183647bcf090d5822b3f2e04e097c8bbd277168d
-rw-r--r--writerfilter/inc/resourcemodel/TableManager.hxx4
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx24
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.hxx2
-rw-r--r--writerfilter/source/doctok/WW8ResourceModelImpl.cxx4
-rw-r--r--writerfilter/source/resourcemodel/resourcemodel.cxx4
5 files changed, 29 insertions, 9 deletions
diff --git a/writerfilter/inc/resourcemodel/TableManager.hxx b/writerfilter/inc/resourcemodel/TableManager.hxx
index bb729346148a..c601adf32b31 100644
--- a/writerfilter/inc/resourcemodel/TableManager.hxx
+++ b/writerfilter/inc/resourcemodel/TableManager.hxx
@@ -62,7 +62,7 @@ public:
/**
Handle end of table.
*/
- virtual void endTable() = 0;
+ virtual void endTable(unsigned int nestedTableLevel) = 0;
/**
Handle start of row.
@@ -994,7 +994,7 @@ void TableManager<T, PropertiesPointer>::resolveCurrentTable()
mpTableDataHandler->endRow();
}
- mpTableDataHandler->endTable();
+ mpTableDataHandler->endTable(mTableDataStack.size() - 1);
}
catch (uno::Exception const& e)
{
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index fbdabd982bc4..dce337d40ea0 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -262,6 +262,7 @@ struct WRITERFILTER_DLLPRIVATE TableInfo
sal_Int32 nRightBorderDistance;
sal_Int32 nTopBorderDistance;
sal_Int32 nBottomBorderDistance;
+ sal_Int32 nNestLevel;
PropertyMapPtr pTableDefaults;
PropertyMapPtr pTableBorders;
TableStyleSheetEntry* pTableStyle;
@@ -272,6 +273,7 @@ struct WRITERFILTER_DLLPRIVATE TableInfo
, nRightBorderDistance(DEF_BORDER_DIST)
, nTopBorderDistance(0)
, nBottomBorderDistance(0)
+ , nNestLevel(0)
, pTableDefaults(new PropertyMap)
, pTableBorders(new PropertyMap)
, pTableStyle(NULL)
@@ -433,7 +435,24 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
lcl_debug_TableBorder(aTableBorder);
#endif
- m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance));
+ // Mimic Office behavior : if tlbInd is defined, use it place table.
+ // Otherwise, top-level table's position depends w:tblCellMar attribute (but not nested tables)
+ if (nLeftMargin)
+ {
+ m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( nLeftMargin - nGapHalf));
+ }
+ else
+ {
+ // TODO: top-level position depends on w:tblCellMar attribute, not w:cellMar
+ if (rInfo.nNestLevel > 1)
+ {
+ m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( - nGapHalf));
+ }
+ else
+ {
+ m_aTableProperties->Insert( PROP_LEFT_MARGIN, false, uno::makeAny( - nGapHalf - rInfo.nLeftBorderDistance));
+ }
+ }
m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, nTableWidth );
if( nTableWidth > 0 )
@@ -672,13 +691,14 @@ RowPropertyValuesSeq_t DomainMapperTableHandler::endTableGetRowProperties()
return aRowProperties;
}
-void DomainMapperTableHandler::endTable()
+void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel)
{
#ifdef DEBUG_DMAPPER_TABLE_HANDLER
dmapper_logger->startElement("tablehandler.endTable");
#endif
TableInfo aTableInfo;
+ aTableInfo.nNestLevel = nestedTableLevel;
aTableInfo.pTableStyle = endTableGetTableStyle(aTableInfo);
// expands to uno::Sequence< Sequence< beans::PropertyValues > >
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
index 0ccd71ce34f0..ea4c42135ed6 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.hxx
@@ -78,7 +78,7 @@ public:
virtual void startTable(unsigned int nRows, unsigned int nDepth,
TablePropertyMapPtr pProps);
- virtual void endTable();
+ virtual void endTable(unsigned int nestedTableLevel);
virtual void startRow(unsigned int nCells, TablePropertyMapPtr pProps);
virtual void endRow();
virtual void startCell(const Handle_t & start, TablePropertyMapPtr pProps);
diff --git a/writerfilter/source/doctok/WW8ResourceModelImpl.cxx b/writerfilter/source/doctok/WW8ResourceModelImpl.cxx
index 2b585ba7e74e..70016d51f129 100644
--- a/writerfilter/source/doctok/WW8ResourceModelImpl.cxx
+++ b/writerfilter/source/doctok/WW8ResourceModelImpl.cxx
@@ -44,7 +44,7 @@ public:
typedef boost::shared_ptr<WW8TableDataHandler> Pointer_t;
virtual void startTable(unsigned int nRows, unsigned int nDepth,
TablePropsPointer_t pProps);
- virtual void endTable();
+ virtual void endTable(unsigned int nestedTableLevel);
virtual void startRow(unsigned int nCols,
TablePropsPointer_t pProps);
virtual void endRow();
@@ -68,7 +68,7 @@ void WW8TableDataHandler::startTable(unsigned int nRows, unsigned int nDepth,
output.addItem(tmpStr);
}
-void WW8TableDataHandler::endTable()
+void WW8TableDataHandler::endTable(unsigned int /*nestedTableLevel*/)
{
output.addItem("</tabledata.table>");
}
diff --git a/writerfilter/source/resourcemodel/resourcemodel.cxx b/writerfilter/source/resourcemodel/resourcemodel.cxx
index 24f5798ac8af..1c9d89b66052 100644
--- a/writerfilter/source/resourcemodel/resourcemodel.cxx
+++ b/writerfilter/source/resourcemodel/resourcemodel.cxx
@@ -101,7 +101,7 @@ public:
typedef boost::shared_ptr<WW8TableDataHandler> Pointer_t;
virtual void startTable(unsigned int nRows, unsigned int nDepth,
TablePropsRef_t pProps);
- virtual void endTable();
+ virtual void endTable(unsigned int nestedTableLevel);
virtual void startRow(unsigned int nCols,
TablePropsRef_t pProps);
virtual void endRow();
@@ -125,7 +125,7 @@ void WW8TableDataHandler::startTable(unsigned int nRows, unsigned int nDepth,
output.addItem(tmpStr);
}
-void WW8TableDataHandler::endTable()
+void WW8TableDataHandler::endTable(unsigned int /*nestedTableLevel*/)
{
output.addItem("</tabledata.table>");
}