Kaydet (Commit) 7329df74 authored tarafından Miklos Vajna's avatar Miklos Vajna

fdo#59273 import w:tblLayout of DOCX tables

Change-Id: I9af50a4c176168e2794eaa9b0e8eaeb6b9d06b13
üst 4821d894
...@@ -122,6 +122,7 @@ public: ...@@ -122,6 +122,7 @@ public:
void testFdo61343(); void testFdo61343();
void testToolsLineNumbering(); void testToolsLineNumbering();
void testFdo60922(); void testFdo60922();
void testFdo59273();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
...@@ -195,6 +196,7 @@ void Test::run() ...@@ -195,6 +196,7 @@ void Test::run()
{"fdo61343.docx", &Test::testFdo61343}, {"fdo61343.docx", &Test::testFdo61343},
{"tools-line-numbering.docx", &Test::testToolsLineNumbering}, {"tools-line-numbering.docx", &Test::testToolsLineNumbering},
{"fdo60922.docx", &Test::testFdo60922}, {"fdo60922.docx", &Test::testFdo60922},
{"fdo59273.docx", &Test::testFdo59273},
}; };
header(); header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
...@@ -1288,6 +1290,16 @@ void Test::testFdo60922() ...@@ -1288,6 +1290,16 @@ void Test::testFdo60922()
CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharEscapementHeight")); CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharEscapementHeight"));
} }
void Test::testFdo59273()
{
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
// Was 9997, so the 4th column had ~zero width
CPPUNIT_ASSERT_EQUAL(sal_Int16(7498), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators")[2].Position);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -53,6 +53,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) : ...@@ -53,6 +53,7 @@ DomainMapperTableManager::DomainMapperTableManager(bool bOOXML) :
m_bOOXML( bOOXML ), m_bOOXML( bOOXML ),
m_bPushCurrentWidth(false), m_bPushCurrentWidth(false),
m_bRowSizeTypeInserted(false), m_bRowSizeTypeInserted(false),
m_nLayoutType(0),
m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) ) m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) )
{ {
m_pTablePropsHandler->SetTableManager( this ); m_pTablePropsHandler->SetTableManager( this );
...@@ -403,6 +404,7 @@ void DomainMapperTableManager::startLevel( ) ...@@ -403,6 +404,7 @@ void DomainMapperTableManager::startLevel( )
m_aTablePositions.push_back( pNewPositionHandler ); m_aTablePositions.push_back( pNewPositionHandler );
m_nCell.push_back( 0 ); m_nCell.push_back( 0 );
m_nTableWidth = 0; m_nTableWidth = 0;
m_nLayoutType = 0;
// And push it back to the right level. // And push it back to the right level.
if (oCurrentWidth) if (oCurrentWidth)
...@@ -416,6 +418,7 @@ void DomainMapperTableManager::endLevel( ) ...@@ -416,6 +418,7 @@ void DomainMapperTableManager::endLevel( )
m_aCellWidths.pop_back( ); m_aCellWidths.pop_back( );
m_nCell.pop_back( ); m_nCell.pop_back( );
m_nTableWidth = 0; m_nTableWidth = 0;
m_nLayoutType = 0;
DomainMapperTableManager_Base_t::endLevel( ); DomainMapperTableManager_Base_t::endLevel( );
...@@ -556,12 +559,13 @@ void DomainMapperTableManager::endOfRowAction() ...@@ -556,12 +559,13 @@ void DomainMapperTableManager::endOfRowAction()
#endif #endif
insertRowProps(pPropMap); insertRowProps(pPropMap);
} }
else if (pCellWidths->size() > 0) else if (pCellWidths->size() > 0 && m_nLayoutType == NS_ooxml::LN_Value_wordprocessingml_ST_TblLayout_fixed)
{ {
// If we're here, then the number of cells does not equal to the amount // If we're here, then the number of cells does not equal to the amount
// defined by the grid, even after taking care of // defined by the grid, even after taking care of
// gridSpan/gridBefore/gridAfter. Handle this by ignoring the grid and // gridSpan/gridBefore/gridAfter. Handle this by ignoring the grid and
// providing the separators based on the provided cell widths. // providing the separators based on the provided cell widths, as long
// as we have a fixed layout.
uno::Sequence< text::TableColumnSeparator > aSeparators(pCellWidths->size() - 1); uno::Sequence< text::TableColumnSeparator > aSeparators(pCellWidths->size() - 1);
text::TableColumnSeparator* pSeparators = aSeparators.getArray(); text::TableColumnSeparator* pSeparators = aSeparators.getArray();
sal_Int16 nSum = 0; sal_Int16 nSum = 0;
...@@ -602,7 +606,7 @@ void DomainMapperTableManager::endOfRowAction() ...@@ -602,7 +606,7 @@ void DomainMapperTableManager::endOfRowAction()
void DomainMapperTableManager::clearData() void DomainMapperTableManager::clearData()
{ {
m_nRow = m_nCellBorderIndex = m_nHeaderRepeat = m_nTableWidth = 0; m_nRow = m_nCellBorderIndex = m_nHeaderRepeat = m_nTableWidth = m_nLayoutType = 0;
m_sTableStyleName = OUString(); m_sTableStyleName = OUString();
m_pTableStyleTextProperies.reset(); m_pTableStyleTextProperies.reset();
} }
......
...@@ -56,6 +56,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t ...@@ -56,6 +56,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
::std::vector< IntVectorPtr > m_aCellWidths; ::std::vector< IntVectorPtr > m_aCellWidths;
/// Remember if a cell already set this, then it should not be set at a row level. /// Remember if a cell already set this, then it should not be set at a row level.
bool m_bRowSizeTypeInserted; bool m_bRowSizeTypeInserted;
/// Table layout algorithm, IOW if we should consider fixed column width or not.
sal_uInt32 m_nLayoutType;
TablePropertiesHandler *m_pTablePropsHandler; TablePropertiesHandler *m_pTablePropsHandler;
PropertyMapPtr m_pStyleProps; PropertyMapPtr m_pStyleProps;
...@@ -126,6 +128,11 @@ public: ...@@ -126,6 +128,11 @@ public:
return m_bRowSizeTypeInserted; return m_bRowSizeTypeInserted;
} }
void SetLayoutType(sal_uInt32 nLayoutType)
{
m_nLayoutType = nLayoutType;
}
}; };
}} }}
......
...@@ -161,6 +161,13 @@ namespace dmapper { ...@@ -161,6 +161,13 @@ namespace dmapper {
} }
} }
break; break;
case NS_ooxml::LN_CT_TblPrBase_tblLayout:
{
DomainMapperTableManager* pManager = dynamic_cast<DomainMapperTableManager*>(m_pTableManager);
if (pManager)
pManager->SetLayoutType(static_cast<sal_uInt32>(nIntValue));
}
break;
case NS_ooxml::LN_CT_TcPrBase_tcBorders ://cell borders case NS_ooxml::LN_CT_TcPrBase_tcBorders ://cell borders
//contains CT_TcBorders_left, right, top, bottom //contains CT_TcBorders_left, right, top, bottom
{ {
......
...@@ -17882,7 +17882,7 @@ ...@@ -17882,7 +17882,7 @@
<xs:documentation>Revision Identifier for Table Row Properties</xs:documentation> <xs:documentation>Revision Identifier for Table Row Properties</xs:documentation>
</attribute> </attribute>
</define> </define>
<define name="ST_TblLayoutType"> <define name="ST_TblLayout">
<list> <list>
<xs:documentation>Table Layout Type</xs:documentation> <xs:documentation>Table Layout Type</xs:documentation>
<choice> <choice>
...@@ -17893,9 +17893,9 @@ ...@@ -17893,9 +17893,9 @@
</choice> </choice>
</list> </list>
</define> </define>
<define name="CT_TblLayoutType"> <define name="CT_TblLayout">
<attribute name="type"> <attribute name="type">
<text/> <ref name="ST_TblLayout"/>
<xs:documentation>Table Layout Setting</xs:documentation> <xs:documentation>Table Layout Setting</xs:documentation>
</attribute> </attribute>
</define> </define>
...@@ -18095,7 +18095,7 @@ ...@@ -18095,7 +18095,7 @@
</optional> </optional>
<optional> <optional>
<element name="tblLayout"> <element name="tblLayout">
<ref name="CT_TblLayoutType"/> <ref name="CT_TblLayout"/>
</element> </element>
</optional> </optional>
<optional> <optional>
...@@ -18150,7 +18150,7 @@ ...@@ -18150,7 +18150,7 @@
</optional> </optional>
<optional> <optional>
<element name="tblLayout"> <element name="tblLayout">
<ref name="CT_TblLayoutType"/> <ref name="CT_TblLayout"/>
</element> </element>
</optional> </optional>
<optional> <optional>
...@@ -22938,9 +22938,12 @@ ...@@ -22938,9 +22938,12 @@
<action name="end" action="sendTableProperties"/> <action name="end" action="sendTableProperties"/>
<action name="end" action="endRow"/> <action name="end" action="endRow"/>
</resource> </resource>
<resource name="ST_TblLayoutType" resource="List" generated="yes"> <resource name="ST_TblLayout" resource="List">
<value name="fixed" tokenid="ooxml:Value_wordprocessingml_ST_TblLayoutType_fixed">fixed</value> <value tokenid="ooxml:Value_wordprocessingml_ST_TblLayout_fixed">fixed</value>
<value name="autofit" tokenid="ooxml:Value_wordprocessingml_ST_TblLayoutType_autofit">autofit</value> <value tokenid="ooxml:Value_wordprocessingml_ST_TblLayout_autofit">autofit</value>
</resource>
<resource name="CT_TblLayout" resource="Value" tag="table">
<attribute name="type" tokenid="ooxml:CT_TblLayout_type" action="setValue"/>
</resource> </resource>
<resource name="ST_TblOverlap" resource="List"> <resource name="ST_TblOverlap" resource="List">
<value tokenid="ooxml:Value_ST_TblOverlap_never">never</value> <value tokenid="ooxml:Value_ST_TblOverlap_never">never</value>
......
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