fdo#55525 import RTF_TRLEFT
Additionally: 1) Make sure cell margins are zero when they are not defined. 2) Handle cellx values in case of a negative left margin. Change-Id: I9b8fb700b6459e622396c98e4344aba79f62c96e
This commit is contained in:
12
sw/qa/extras/rtfimport/data/fdo55525.rtf
Normal file
12
sw/qa/extras/rtfimport/data/fdo55525.rtf
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{\rtf1
|
||||||
|
\marglsxn1418\margrsxn1418
|
||||||
|
\trowd\trql\trleft-1064\cellx-250\cellx-106\cellx8006
|
||||||
|
\pard\plain \intbl
|
||||||
|
A1
|
||||||
|
\cell\pard\plain\intbl
|
||||||
|
A2
|
||||||
|
\cell\pard\plain\intbl
|
||||||
|
A3
|
||||||
|
\cell\row\pard
|
||||||
|
\pard\plain \par
|
||||||
|
}
|
@@ -42,6 +42,7 @@
|
|||||||
#include <com/sun/star/table/BorderLineStyle.hpp>
|
#include <com/sun/star/table/BorderLineStyle.hpp>
|
||||||
#include <com/sun/star/text/RelOrientation.hpp>
|
#include <com/sun/star/text/RelOrientation.hpp>
|
||||||
#include <com/sun/star/text/SizeType.hpp>
|
#include <com/sun/star/text/SizeType.hpp>
|
||||||
|
#include <com/sun/star/text/TableColumnSeparator.hpp>
|
||||||
#include <com/sun/star/text/TextContentAnchorType.hpp>
|
#include <com/sun/star/text/TextContentAnchorType.hpp>
|
||||||
#include <com/sun/star/text/XFootnotesSupplier.hpp>
|
#include <com/sun/star/text/XFootnotesSupplier.hpp>
|
||||||
#include <com/sun/star/text/XPageCursor.hpp>
|
#include <com/sun/star/text/XPageCursor.hpp>
|
||||||
@@ -124,6 +125,7 @@ public:
|
|||||||
void testFdo56512();
|
void testFdo56512();
|
||||||
void testFdo52989();
|
void testFdo52989();
|
||||||
void testFdo48442();
|
void testFdo48442();
|
||||||
|
void testFdo55525();
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(Test);
|
CPPUNIT_TEST_SUITE(Test);
|
||||||
#if !defined(MACOSX) && !defined(WNT)
|
#if !defined(MACOSX) && !defined(WNT)
|
||||||
@@ -199,6 +201,7 @@ void Test::run()
|
|||||||
{"fdo56512.rtf", &Test::testFdo56512},
|
{"fdo56512.rtf", &Test::testFdo56512},
|
||||||
{"fdo52989.rtf", &Test::testFdo52989},
|
{"fdo52989.rtf", &Test::testFdo52989},
|
||||||
{"fdo48442.rtf", &Test::testFdo48442},
|
{"fdo48442.rtf", &Test::testFdo48442},
|
||||||
|
{"fdo55525.rtf", &Test::testFdo55525},
|
||||||
};
|
};
|
||||||
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
|
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
|
||||||
{
|
{
|
||||||
@@ -917,6 +920,18 @@ void Test::testFdo48442()
|
|||||||
CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation")); // was FRAME
|
CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation")); // was FRAME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Test::testFdo55525()
|
||||||
|
{
|
||||||
|
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
|
||||||
|
uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
|
||||||
|
uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
|
||||||
|
// Negative left margin was ~missing, -191
|
||||||
|
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1877), getProperty<sal_Int32>(xTable, "LeftMargin"));
|
||||||
|
// Cell width of A1 was 3332 (e.g. not set, 30% percent of total width)
|
||||||
|
uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
|
||||||
|
CPPUNIT_ASSERT_EQUAL(sal_Int16(1016), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[0].Position);
|
||||||
|
}
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
|
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@@ -1699,6 +1699,22 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
|
|||||||
RTFValue::Pointer_t pRowValue(new RTFValue(1));
|
RTFValue::Pointer_t pRowValue(new RTFValue(1));
|
||||||
if (m_aStates.top().nCells > 0)
|
if (m_aStates.top().nCells > 0)
|
||||||
m_aStates.top().aTableRowSprms.set(NS_sprm::LN_PRow, pRowValue);
|
m_aStates.top().aTableRowSprms.set(NS_sprm::LN_PRow, pRowValue);
|
||||||
|
|
||||||
|
RTFValue::Pointer_t pCellMar = m_aStates.top().aTableRowSprms.find(NS_ooxml::LN_CT_TblPrBase_tblCellMar);
|
||||||
|
if (!pCellMar.get())
|
||||||
|
{
|
||||||
|
// If no cell margins are defined, the default left/right margin is 0 in Word, but not in Writer.
|
||||||
|
RTFSprms aAttributes;
|
||||||
|
aAttributes.set(NS_ooxml::LN_CT_TblWidth_type, RTFValue::Pointer_t(new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa)));
|
||||||
|
aAttributes.set(NS_ooxml::LN_CT_TblWidth_w, RTFValue::Pointer_t(new RTFValue(0)));
|
||||||
|
lcl_putNestedSprm(m_aStates.top().aTableRowSprms,
|
||||||
|
NS_ooxml::LN_CT_TblPrBase_tblCellMar, NS_ooxml::LN_CT_TblCellMar_left,
|
||||||
|
RTFValue::Pointer_t(new RTFValue(aAttributes)));
|
||||||
|
lcl_putNestedSprm(m_aStates.top().aTableRowSprms,
|
||||||
|
NS_ooxml::LN_CT_TblPrBase_tblCellMar, NS_ooxml::LN_CT_TblCellMar_right,
|
||||||
|
RTFValue::Pointer_t(new RTFValue(aAttributes)));
|
||||||
|
}
|
||||||
|
|
||||||
writerfilter::Reference<Properties>::Pointer_t const pTableRowProperties(
|
writerfilter::Reference<Properties>::Pointer_t const pTableRowProperties(
|
||||||
new RTFReferenceProperties(m_aStates.top().aTableRowAttributes, m_aStates.top().aTableRowSprms)
|
new RTFReferenceProperties(m_aStates.top().aTableRowAttributes, m_aStates.top().aTableRowSprms)
|
||||||
);
|
);
|
||||||
@@ -2845,6 +2861,16 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
|
|||||||
case RTF_CELLX:
|
case RTF_CELLX:
|
||||||
{
|
{
|
||||||
int nCellX = nParam - m_aStates.top().nCellX;
|
int nCellX = nParam - m_aStates.top().nCellX;
|
||||||
|
|
||||||
|
// If there is a negative left margin, then the first cellx is relateve to that.
|
||||||
|
RTFValue::Pointer_t pTblInd = m_aStates.top().aTableRowSprms.find(NS_ooxml::LN_CT_TblPrBase_tblInd);
|
||||||
|
if (m_aStates.top().nCellX == 0 && pTblInd.get())
|
||||||
|
{
|
||||||
|
RTFValue::Pointer_t pWidth = pTblInd->getAttributes().find(NS_ooxml::LN_CT_TblWidth_w);
|
||||||
|
if (pWidth.get() && pWidth->getInt() < 0)
|
||||||
|
nCellX = -1 * (pWidth->getInt() - nParam);
|
||||||
|
}
|
||||||
|
|
||||||
m_aStates.top().nCellX = nParam;
|
m_aStates.top().nCellX = nParam;
|
||||||
RTFValue::Pointer_t pXValue(new RTFValue(nCellX));
|
RTFValue::Pointer_t pXValue(new RTFValue(nCellX));
|
||||||
m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, false);
|
m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, false);
|
||||||
@@ -2880,6 +2906,17 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
|
|||||||
NS_ooxml::LN_CT_TrPrBase_trHeight, NS_ooxml::LN_CT_Height_hRule, pHRule);
|
NS_ooxml::LN_CT_TrPrBase_trHeight, NS_ooxml::LN_CT_Height_hRule, pHRule);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case RTF_TRLEFT:
|
||||||
|
{
|
||||||
|
// the value is in twips
|
||||||
|
lcl_putNestedAttribute(m_aStates.top().aTableRowSprms,
|
||||||
|
NS_ooxml::LN_CT_TblPrBase_tblInd, NS_ooxml::LN_CT_TblWidth_type,
|
||||||
|
RTFValue::Pointer_t(new RTFValue(NS_ooxml::LN_Value_ST_TblWidth_dxa)));
|
||||||
|
lcl_putNestedAttribute(m_aStates.top().aTableRowSprms,
|
||||||
|
NS_ooxml::LN_CT_TblPrBase_tblInd, NS_ooxml::LN_CT_TblWidth_w,
|
||||||
|
RTFValue::Pointer_t(new RTFValue(nParam)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
case RTF_COLS:
|
case RTF_COLS:
|
||||||
lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
|
lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
|
||||||
NS_ooxml::LN_EG_SectPrContents_cols, NS_ooxml::LN_CT_Columns_num, pIntValue);
|
NS_ooxml::LN_EG_SectPrContents_cols, NS_ooxml::LN_CT_Columns_num, pIntValue);
|
||||||
|
Reference in New Issue
Block a user