summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapperTableHandler.cxx')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx38
1 files changed, 38 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 3d99fa25050e..250ea42ad0c5 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -19,9 +19,12 @@
#include <DomainMapperTableHandler.hxx>
#include <DomainMapper_Impl.hxx>
#include <StyleSheetTable.hxx>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/table/TableBorderDistances.hpp>
#include <com/sun/star/table/TableBorder.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
#include <com/sun/star/text/SizeType.hpp>
@@ -779,6 +782,22 @@ RowPropertyValuesSeq_t DomainMapperTableHandler::endTableGetRowProperties()
return aRowProperties;
}
+// Apply paragraph property to each paragraph within a cell.
+static void lcl_ApplyCellParaProps(uno::Reference<table::XCell> xCell, uno::Any aBottomMargin)
+{
+ uno::Reference<container::XEnumerationAccess> xEnumerationAccess(xCell, uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xEnumeration = xEnumerationAccess->createEnumeration();
+ while (xEnumeration->hasMoreElements())
+ {
+ uno::Reference<beans::XPropertySet> xParagraph(xEnumeration->nextElement(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertyState> xPropertyState(xParagraph, uno::UNO_QUERY);
+ // Don't apply in case direct formatting is already present.
+ // TODO: probably paragraph style has priority over table style here.
+ if (xPropertyState.is() && xPropertyState->getPropertyState("ParaBottomMargin") == beans::PropertyState_DEFAULT_VALUE)
+ xParagraph->setPropertyValue("ParaBottomMargin", aBottomMargin);
+ }
+}
+
void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel)
{
#ifdef DEBUG_DMAPPER_TABLE_HANDLER
@@ -825,6 +844,25 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel)
if (xTable.is())
m_xTableRange = xTable->getAnchor( );
+
+ // OOXML table style may container paragraph properties, apply these now.
+ for (int i = 0; i < aTableInfo.aTableProperties.getLength(); ++i)
+ {
+ if (aTableInfo.aTableProperties[i].Name == "ParaBottomMargin")
+ {
+ uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY);
+ uno::Any aBottomMargin = aTableInfo.aTableProperties[i].Value;
+ sal_Int32 nRows = aCellProperties.getLength();
+ for (sal_Int32 nRow = 0; nRow < nRows; ++nRow)
+ {
+ const uno::Sequence< beans::PropertyValues > aCurrentRow = aCellProperties[nRow];
+ sal_Int32 nCells = aCurrentRow.getLength();
+ for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
+ lcl_ApplyCellParaProps(xCellRange->getCellByPosition(nCell, nRow), aBottomMargin);
+ }
+ break;
+ }
+ }
}
}
catch ( const lang::IllegalArgumentException &e )