summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-08-15 16:31:51 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-08-21 17:48:13 +0200
commitedc4861a68e0269b83b17e0ec57912a1ce4220ad (patch)
treece57e67f97f7428e7a2d8a13a931f10e49a48147 /writerfilter/source/dmapper/DomainMapperTableHandler.cxx
parent25ef6ea63ac2d329b510e921d013f6382b280673 (diff)
n#775899 initial docx import of w:vertAnchor inside w:tblpPr
Change-Id: I5c848a8d4c860a83d6729b8db40f744afad906d5
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapperTableHandler.cxx')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx65
1 files changed, 64 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 7fcd9e3e64ec..e0d831680d4a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/table/TableBorder.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
#include <dmapperLoggers.hxx>
#ifdef DEBUG_DMAPPER_TABLE_HANDLER
@@ -691,11 +692,24 @@ void DomainMapperTableHandler::endTable()
if (m_pTableSeq->getLength() > 0)
{
+ uno::Reference<text::XTextRange> xStart;
+ uno::Reference<text::XTextRange> xEnd;
+ // If we want to make this table a floating one.
+ bool bFloating = !m_rDMapper_Impl.getTableManager().getTableVertAnchor().isEmpty();
+ // Additional checks: if we can do this.
+ if (bFloating && (*m_pTableSeq)[0].getLength() > 0 && (*m_pTableSeq)[0][0].getLength() > 0)
+ {
+ xStart = (*m_pTableSeq)[0][0][0];
+ uno::Sequence< uno::Sequence< uno::Reference<text::XTextRange> > >& rLastRow = (*m_pTableSeq)[m_pTableSeq->getLength() - 1];
+ uno::Sequence< uno::Reference<text::XTextRange> >& rLastCell = rLastRow[rLastRow.getLength() - 1];
+ xEnd = rLastCell[1];
+ }
+ uno::Reference<text::XTextTable> xTable;
try
{
if (m_xText.is())
{
- uno::Reference<text::XTextTable> xTable = m_xText->convertToTable(*m_pTableSeq,
+ xTable = m_xText->convertToTable(*m_pTableSeq,
aCellProperties,
aRowProperties,
aTableInfo.aTableProperties);
@@ -723,6 +737,55 @@ void DomainMapperTableHandler::endTable()
(void) e;
#endif
}
+
+ // If we have a table with a start and an end position, we should make it a floating one.
+ if (xTable.is() && xStart.is() && xEnd.is())
+ {
+ uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY);
+ uno::Sequence< beans::PropertyValue > aFrameProperties(16);
+ beans::PropertyValue* pFrameProperties = aFrameProperties.getArray();
+ pFrameProperties[0].Name = "Width";
+ pFrameProperties[0].Value = xTableProperties->getPropertyValue("Width");
+
+ pFrameProperties[1].Name = "LeftBorderDistance";
+ pFrameProperties[1].Value <<= sal_Int32(0);
+ pFrameProperties[2].Name = "RightBorderDistance";
+ pFrameProperties[2].Value <<= sal_Int32(0);
+ pFrameProperties[3].Name = "TopBorderDistance";
+ pFrameProperties[3].Value <<= sal_Int32(0);
+ pFrameProperties[4].Name = "BottomBorderDistance";
+ pFrameProperties[4].Value <<= sal_Int32(0);
+
+ pFrameProperties[5].Name = "LeftMargin";
+ pFrameProperties[5].Value <<= sal_Int32(0);
+ pFrameProperties[6].Name = "RightMargin";
+ pFrameProperties[6].Value <<= sal_Int32(0);
+ pFrameProperties[7].Name = "TopMargin";
+ pFrameProperties[7].Value <<= sal_Int32(0);
+ pFrameProperties[8].Name = "BottomMargin";
+ pFrameProperties[8].Value <<= sal_Int32(0);
+
+ table::BorderLine2 aEmptyBorder;
+ pFrameProperties[9].Name = "TopBorder";
+ pFrameProperties[9].Value <<= aEmptyBorder;
+ pFrameProperties[10].Name = "BottomBorder";
+ pFrameProperties[10].Value <<= aEmptyBorder;
+ pFrameProperties[11].Name = "LeftBorder";
+ pFrameProperties[11].Value <<= aEmptyBorder;
+ pFrameProperties[12].Name = "RightBorder";
+ pFrameProperties[12].Value <<= aEmptyBorder;
+
+ pFrameProperties[13].Name = "HoriOrient";
+ pFrameProperties[13].Value <<= text::HoriOrientation::NONE;
+ pFrameProperties[14].Name = "HoriOrientRelation";
+ pFrameProperties[14].Value <<= text::RelOrientation::FRAME;
+ // A non-zero left margin would move the table out of the frame, move the frame itself instead.
+ pFrameProperties[15].Name = "HoriOrientPosition";
+ pFrameProperties[15].Value <<= xTableProperties->getPropertyValue("LeftMargin");
+ xTableProperties->setPropertyValue("LeftMargin", uno::makeAny(sal_Int32(0)));
+
+ uno::Reference< text::XTextContent > xFrame = m_xText->convertToTextFrame(xStart, xEnd, aFrameProperties);
+ }
}
m_aTableProperties.reset();