Kaydet (Commit) 67163f55 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#66474 DOCX import: fix handling of mixed fixed/auto cell widths

Instead of checking if any cells have fixed width, check if all calls
have fixed with.  Regression from
74c5ed19.

Change-Id: I58d3d16cbaa2c54a8a1ac309910336c72dcb39b7
üst 4a1c808b
...@@ -125,6 +125,7 @@ public: ...@@ -125,6 +125,7 @@ public:
void testTableAutoColumnFixedSize(); void testTableAutoColumnFixedSize();
void testFdo46361(); void testFdo46361();
void testFdo65632(); void testFdo65632();
void testFdo66474();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -215,6 +216,7 @@ void Test::run() ...@@ -215,6 +216,7 @@ void Test::run()
{"table-auto-column-fixed-size.docx", &Test::testTableAutoColumnFixedSize}, {"table-auto-column-fixed-size.docx", &Test::testTableAutoColumnFixedSize},
{"fdo46361.docx", &Test::testFdo46361}, {"fdo46361.docx", &Test::testFdo46361},
{"fdo65632.docx", &Test::testFdo65632}, {"fdo65632.docx", &Test::testFdo65632},
{"fdo66474.docx", &Test::testFdo66474},
}; };
header(); header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
...@@ -1516,6 +1518,15 @@ void Test::testFdo65632() ...@@ -1516,6 +1518,15 @@ void Test::testFdo65632()
CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "TextPortionType")); CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "TextPortionType"));
} }
void Test::testFdo66474()
{
// The table wasn't relative (relative with was 0), so the table didn't
// take the full available width, like it would have to.
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), getProperty<sal_Int16>(xTables->getByIndex(0), "RelativeWidth"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -140,20 +140,24 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) ...@@ -140,20 +140,24 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
the final sizing of the table, but then must use the contents of each cell to determine final column widths. the final sizing of the table, but then must use the contents of each cell to determine final column widths.
(See 17.18.87 of the ISO/IEC 29500-1:2011.) (See 17.18.87 of the ISO/IEC 29500-1:2011.)
*/ */
bool bFixed = false; bool bFixed = true;
sal_Int32 nRowFixedWidth = 0; sal_Int32 nRowFixedWidth = 0;
if (!m_aCellWidths.empty()) if (!m_aCellWidths.empty())
{ {
// Step 1. Check whether any cell has fixed width in the given row of table. // Step 1. Check whether all cells have fixed widths in the given row of table.
::std::vector< IntVectorPtr >::iterator itr; ::std::vector< IntVectorPtr >::iterator itr;
for (itr = m_aCellWidths.begin(); itr != m_aCellWidths.end(); itr ++) for (itr = m_aCellWidths.begin(); itr != m_aCellWidths.end(); itr ++)
{ {
IntVectorPtr itrVal = (*itr); IntVectorPtr itrVal = (*itr);
for (std::vector<sal_Int32>::const_iterator aValIter = itrVal->begin(); aValIter != itrVal->end(); ++aValIter) for (std::vector<sal_Int32>::const_iterator aValIter = itrVal->begin(); aValIter != itrVal->end(); ++aValIter)
{ {
if (*aValIter == -1)
{
bFixed = false;
break;
}
// Sum the width of cells to find the total width of given row // Sum the width of cells to find the total width of given row
nRowFixedWidth += (*aValIter); nRowFixedWidth += (*aValIter);
bFixed = true;
} }
} }
} }
...@@ -368,7 +372,10 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) ...@@ -368,7 +372,10 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
{ {
MeasureHandlerPtr pMeasureHandler(new MeasureHandler()); MeasureHandlerPtr pMeasureHandler(new MeasureHandler());
pProperties->resolve(*pMeasureHandler); pProperties->resolve(*pMeasureHandler);
getCurrentCellWidths()->push_back(pMeasureHandler->getMeasureValue()); if (sal::static_int_cast<Id>(pMeasureHandler->getUnit()) == NS_ooxml::LN_Value_ST_TblWidth_auto)
getCurrentCellWidths()->push_back(sal_Int32(-1));
else
getCurrentCellWidths()->push_back(pMeasureHandler->getMeasureValue());
if (getTableDepthDifference() > 0) if (getTableDepthDifference() > 0)
m_bPushCurrentWidth = true; m_bPushCurrentWidth = true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment