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
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index c85b288..bf7db73 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1566,7 +1566,7 @@ void Test::testTableFloating()
    // This was 0, should be the the opposite of (left margin + half of the border width).
    CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty<sal_Int32>(xFrame, "HoriOrientPosition"));
    // Was 0 as well, should be the right margin.
    CPPUNIT_ASSERT_EQUAL(sal_Int32(191), getProperty<sal_Int32>(xFrame, "RightMargin"));
    CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xFrame, "RightMargin"));
}

CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/writerfilter/source/dmapper/TablePositionHandler.cxx b/writerfilter/source/dmapper/TablePositionHandler.cxx
index 19613a0..1ecf6c6 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<beans::PropertyValue> 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<beans::PropertyValue> 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<beans::PropertyValue> 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 366a6e4..d68800c 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 402323f..ea8f082 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -17985,11 +17985,11 @@
      </define>
      <define name="CT_TblPPr">
        <attribute name="leftFromText">
          <text/>
          <ref name="ST_SignedTwipsMeasure"/>
          <xs:documentation>Distance From Left of Table to Text</xs:documentation>
        </attribute>
        <attribute name="rightFromText">
          <text/>
          <ref name="ST_SignedTwipsMeasure"/>
          <xs:documentation>(Distance From Right of Table to Text</xs:documentation>
        </attribute>
        <attribute name="topFromText">
@@ -22913,6 +22913,8 @@
      <attribute name="tblpXSpec" tokenid="ooxml:CT_TblPPr_tblpXSpec"/>
      <attribute name="tblpY" tokenid="ooxml:CT_TblPPr_tblpY"/>
      <attribute name="tblpX" tokenid="ooxml:CT_TblPPr_tblpX"/>
      <attribute name="leftFromText" tokenid="ooxml:CT_TblPPr_leftFromText"/>
      <attribute name="rightFromText" tokenid="ooxml:CT_TblPPr_rightFromText"/>
      <attribute name="topFromText" tokenid="ooxml:CT_TblPPr_topFromText"/>
      <attribute name="bottomFromText" tokenid="ooxml:CT_TblPPr_bottomFromText"/>
    </resource>