From 26d9efd36a16d2095d8fb885290c6816082ec814 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 15 Aug 2013 10:40:35 +0200 Subject: DOCX import: handle w:leftFromText and w:rightFromText for floating tables Left margin wasn't implemented, that's simple. Right margin of the table was set to the cell margin in commit 53d27a30ce5f2c9f7d37a4089286116854c16215, which turns out to be wrong: it's true that the right margin should be >0, but not because of the cell margin but because of the table margin. The new behavior matches what the binary import always did. Change-Id: Ifc24e4f086c49d5d575defdfca1d27e497fa03dc --- writerfilter/source/dmapper/TablePositionHandler.cxx | 20 ++++++++++++-------- writerfilter/source/dmapper/TablePositionHandler.hxx | 3 ++- writerfilter/source/ooxml/model.xml | 6 ++++-- 3 files changed, 18 insertions(+), 11 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/dmapper/TablePositionHandler.cxx b/writerfilter/source/dmapper/TablePositionHandler.cxx index 19613a0d6489..1ecf6c6d9344 100644 --- a/writerfilter/source/dmapper/TablePositionHandler.cxx +++ b/writerfilter/source/dmapper/TablePositionHandler.cxx @@ -30,10 +30,11 @@ TablePositionHandler::TablePositionHandler() : m_aXSpec( ), m_nY( 0 ), m_nX( 0 ), + m_nLeftFromText(0), + m_nRightFromText(0), m_nTopFromText(0), m_nBottomFromText(0), - m_nLeftBorderDistance(DEF_BORDER_DIST), - m_nRightBorderDistance(DEF_BORDER_DIST) + m_nLeftBorderDistance(DEF_BORDER_DIST) { } @@ -64,6 +65,12 @@ void TablePositionHandler::lcl_attribute(Id rName, Value& rVal) case NS_ooxml::LN_CT_TblPPr_tblpX: m_nX = rVal.getInt(); break; + case NS_ooxml::LN_CT_TblPPr_leftFromText: + m_nLeftFromText = rVal.getInt(); + break; + case NS_ooxml::LN_CT_TblPPr_rightFromText: + m_nRightFromText = rVal.getInt(); + break; case NS_ooxml::LN_CT_TblPPr_topFromText: m_nTopFromText = rVal.getInt(); break; @@ -86,7 +93,7 @@ void TablePositionHandler::lcl_sprm(Sprm& /*rSprm*/) uno::Sequence TablePositionHandler::getTablePosition() const { - uno::Sequence< beans::PropertyValue > aFrameProperties(19); + uno::Sequence< beans::PropertyValue > aFrameProperties(18); beans::PropertyValue* pFrameProperties = aFrameProperties.getArray(); pFrameProperties[0].Name = "LeftBorderDistance"; @@ -99,9 +106,9 @@ uno::Sequence TablePositionHandler::getTablePosition() con pFrameProperties[3].Value <<= sal_Int32(0); pFrameProperties[4].Name = "LeftMargin"; - pFrameProperties[4].Value <<= sal_Int32(0); + pFrameProperties[4].Value <<= ConversionHelper::convertTwipToMM100(m_nLeftFromText); pFrameProperties[5].Name = "RightMargin"; - pFrameProperties[5].Value <<= sal_Int32(0); + pFrameProperties[5].Value <<= ConversionHelper::convertTwipToMM100(m_nRightFromText); pFrameProperties[6].Name = "TopMargin"; pFrameProperties[6].Value <<= ConversionHelper::convertTwipToMM100(m_nTopFromText); pFrameProperties[7].Name = "BottomMargin"; @@ -172,9 +179,6 @@ uno::Sequence TablePositionHandler::getTablePosition() con pFrameProperties[17].Name = "VertOrientPosition"; pFrameProperties[17].Value <<= m_nY; - pFrameProperties[18].Name = "RightMargin"; - pFrameProperties[18].Value <<= m_nRightBorderDistance; - return aFrameProperties; } diff --git a/writerfilter/source/dmapper/TablePositionHandler.hxx b/writerfilter/source/dmapper/TablePositionHandler.hxx index 366a6e438303..d68800c51e9a 100644 --- a/writerfilter/source/dmapper/TablePositionHandler.hxx +++ b/writerfilter/source/dmapper/TablePositionHandler.hxx @@ -27,10 +27,11 @@ namespace writerfilter { OUString m_aXSpec; sal_Int32 m_nY; sal_Int32 m_nX; + sal_Int32 m_nLeftFromText; + sal_Int32 m_nRightFromText; sal_Int32 m_nTopFromText; sal_Int32 m_nBottomFromText; sal_Int32 m_nLeftBorderDistance; - sal_Int32 m_nRightBorderDistance; // Properties virtual void lcl_attribute(Id Name, Value & val); diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml index 402323fc1ff6..ea8f082c4d9c 100644 --- a/writerfilter/source/ooxml/model.xml +++ b/writerfilter/source/ooxml/model.xml @@ -17985,11 +17985,11 @@ - + Distance From Left of Table to Text - + (Distance From Right of Table to Text @@ -22913,6 +22913,8 @@ + + -- cgit