Kaydet (Commit) cbcc6189 authored tarafından Ravindra Vidhate's avatar Ravindra Vidhate Kaydeden (comit) Miklos Vajna

fdo#77887 : Floating Table positions are not preserved when doing Export

The margin of the floating table from top of the page is not being preserved correctly and it also get increased.

The w:tblpPr tag is also not preserved.

Reviewed on:
	https://gerrit.libreoffice.org/9185

Change-Id: I8a27a4bab94a1afd27a7ba49ca55ff014918fffc
üst a4ff20ee
...@@ -3174,6 +3174,23 @@ DECLARE_OOXMLEXPORT_TEST(testFDO77117, "fdo77117.docx") ...@@ -3174,6 +3174,23 @@ DECLARE_OOXMLEXPORT_TEST(testFDO77117, "fdo77117.docx")
CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight")); CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight"));
} }
DECLARE_OOXMLEXPORT_TEST(testFloatingTable, "fdo77887.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "horzAnchor", "margin");
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "leftFromText", "141");
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "rightFromText", "141");
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpXSpec", "center");
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpY", "2266");
assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "vertAnchor", "page");
}
DECLARE_OOXMLEXPORT_TEST(testFDO75431, "fdo75431.docx") DECLARE_OOXMLEXPORT_TEST(testFDO75431, "fdo75431.docx")
{ {
xmlDocPtr pXmlDoc = parseExport("word/document.xml"); xmlDocPtr pXmlDoc = parseExport("word/document.xml");
......
...@@ -2728,6 +2728,63 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t ...@@ -2728,6 +2728,63 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
m_aTableStyleConf[ BOX_LINE_LEFT ] = aGrabBagElement->second.get<table::BorderLine2>(); m_aTableStyleConf[ BOX_LINE_LEFT ] = aGrabBagElement->second.get<table::BorderLine2>();
else if( aGrabBagElement->first == "TableStyleRightBorder" ) else if( aGrabBagElement->first == "TableStyleRightBorder" )
m_aTableStyleConf[ BOX_LINE_RIGHT ] = aGrabBagElement->second.get<table::BorderLine2>(); m_aTableStyleConf[ BOX_LINE_RIGHT ] = aGrabBagElement->second.get<table::BorderLine2>();
else if (aGrabBagElement->first == "TablePosition" )
{
FastAttributeList *attrListTablePos = m_pSerializer->createAttrList( );
uno::Sequence<beans::PropertyValue> aTablePosition = aGrabBagElement->second.get<uno::Sequence<beans::PropertyValue> >();
for (sal_Int32 i = 0; i < aTablePosition.getLength(); ++i)
{
if (aTablePosition[i].Name == "vertAnchor")
{
OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
attrListTablePos->add( FSNS( XML_w, XML_vertAnchor ), strTemp.getStr() );
}
else if (aTablePosition[i].Name == "tblpYSpec")
{
OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
attrListTablePos->add( FSNS( XML_w, XML_tblpYSpec ), strTemp.getStr() );
}
else if (aTablePosition[i].Name == "horzAnchor")
{
OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
attrListTablePos->add( FSNS( XML_w, XML_horzAnchor ), strTemp.getStr() );
}
else if (aTablePosition[i].Name == "tblpXSpec")
{
OString strTemp = OUStringToOString(aTablePosition[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8);
attrListTablePos->add( FSNS( XML_w, XML_tblpXSpec ), strTemp.getStr() );
}
else if (aTablePosition[i].Name == "bottomFromText")
{
attrListTablePos->add( FSNS( XML_w, XML_bottomFromText ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) );
}
else if (aTablePosition[i].Name == "leftFromText")
{
attrListTablePos->add( FSNS( XML_w, XML_leftFromText ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) );
}
else if (aTablePosition[i].Name == "rightFromText")
{
attrListTablePos->add( FSNS( XML_w, XML_rightFromText ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) );
}
else if (aTablePosition[i].Name == "topFromText")
{
attrListTablePos->add( FSNS( XML_w, XML_topFromText ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) );
}
else if (aTablePosition[i].Name == "tblpX")
{
attrListTablePos->add( FSNS( XML_w, XML_tblpX ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) );
}
else if (aTablePosition[i].Name == "tblpY")
{
attrListTablePos->add( FSNS( XML_w, XML_tblpY ), OString::number( aTablePosition[i].Value.get<sal_Int32>() ) );
}
}
XFastAttributeListRef xAttrListTablePosRef( attrListTablePos );
m_pSerializer->singleElementNS( XML_w, XML_tblpPr, xAttrListTablePosRef);
attrListTablePos = NULL;
}
} }
// Output the table alignement // Output the table alignement
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#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 <dmapperLoggers.hxx> #include <dmapperLoggers.hxx>
#include <TablePositionHandler.hxx>
#ifdef DEBUG_DMAPPER_TABLE_HANDLER #ifdef DEBUG_DMAPPER_TABLE_HANDLER
#include <PropertyMapHelper.hxx> #include <PropertyMapHelper.hxx>
...@@ -354,8 +355,50 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -354,8 +355,50 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
PropertyMap::iterator aTableStyleIter = PropertyMap::iterator aTableStyleIter =
m_aTableProperties->find(META_PROP_TABLE_STYLE_NAME); m_aTableProperties->find(META_PROP_TABLE_STYLE_NAME);
uno::Sequence< beans::PropertyValue > aGrabBag( 5 ); uno::Sequence< beans::PropertyValue > aGrabBag( 6 );
sal_Int32 nGrabBagSize = 0; sal_Int32 nGrabBagSize = 0;
if (0 != m_rDMapper_Impl.getTableManager().getCurrentTableRealPosition())
{
TablePositionHandler *pTablePositions = m_rDMapper_Impl.getTableManager().getCurrentTableRealPosition();
uno::Sequence< beans::PropertyValue > aGrabBagTS( 10 );
aGrabBagTS[0].Name = "bottomFromText";
aGrabBagTS[0].Value = uno::makeAny(pTablePositions->getBottomFromText() );
aGrabBagTS[1].Name = "horzAnchor";
aGrabBagTS[1].Value = uno::makeAny( pTablePositions->getHorzAnchor() );
aGrabBagTS[2].Name = "leftFromText";
aGrabBagTS[2].Value = uno::makeAny( pTablePositions->getLeftFromText() );
aGrabBagTS[3].Name = "rightFromText";
aGrabBagTS[3].Value = uno::makeAny( pTablePositions->getRightFromText() );
aGrabBagTS[4].Name = "tblpX";
aGrabBagTS[4].Value = uno::makeAny( pTablePositions->getX() );
aGrabBagTS[5].Name = "tblpXSpec";
aGrabBagTS[5].Value = uno::makeAny( pTablePositions->getXSpec() );
aGrabBagTS[6].Name = "tblpY";
aGrabBagTS[6].Value = uno::makeAny( pTablePositions->getY() );
aGrabBagTS[7].Name = "tblpYSpec";
aGrabBagTS[7].Value = uno::makeAny( pTablePositions->getYSpec() );
aGrabBagTS[8].Name = "topFromText";
aGrabBagTS[8].Value = uno::makeAny( pTablePositions->getTopFromText() );
aGrabBagTS[9].Name = "vertAnchor";
aGrabBagTS[9].Value = uno::makeAny( pTablePositions->getVertAnchor() );
aGrabBag[nGrabBagSize].Name = "TablePosition";
aGrabBag[nGrabBagSize].Value = uno::makeAny( aGrabBagTS );
nGrabBagSize++;
}
if(aTableStyleIter != m_aTableProperties->end()) if(aTableStyleIter != m_aTableProperties->end())
{ {
// Apply table style properties recursively // Apply table style properties recursively
...@@ -366,8 +409,8 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -366,8 +409,8 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) ); pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) );
m_aTableProperties->erase( aTableStyleIter ); m_aTableProperties->erase( aTableStyleIter );
aGrabBag[0].Name = "TableStyleName"; aGrabBag[nGrabBagSize].Name = "TableStyleName";
aGrabBag[0].Value = uno::makeAny( sTableStyleName ); aGrabBag[nGrabBagSize].Value = uno::makeAny( sTableStyleName );
nGrabBagSize++; nGrabBagSize++;
if( pStyleSheet ) if( pStyleSheet )
...@@ -384,26 +427,26 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo ...@@ -384,26 +427,26 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
TableInfo rStyleInfo; TableInfo rStyleInfo;
if (lcl_extractTableBorderProperty(pMergedProperties, PROP_TOP_BORDER, rStyleInfo, aBorderLine)) if (lcl_extractTableBorderProperty(pMergedProperties, PROP_TOP_BORDER, rStyleInfo, aBorderLine))
{ {
aGrabBag[1].Name = "TableStyleTopBorder"; aGrabBag[nGrabBagSize].Name = "TableStyleTopBorder";
aGrabBag[1].Value = uno::makeAny( aBorderLine ); aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine );
nGrabBagSize++; nGrabBagSize++;
} }
if (lcl_extractTableBorderProperty(pMergedProperties, PROP_BOTTOM_BORDER, rStyleInfo, aBorderLine)) if (lcl_extractTableBorderProperty(pMergedProperties, PROP_BOTTOM_BORDER, rStyleInfo, aBorderLine))
{ {
aGrabBag[2].Name = "TableStyleBottomBorder"; aGrabBag[nGrabBagSize].Name = "TableStyleBottomBorder";
aGrabBag[2].Value = uno::makeAny( aBorderLine ); aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine );
nGrabBagSize++; nGrabBagSize++;
} }
if (lcl_extractTableBorderProperty(pMergedProperties, PROP_LEFT_BORDER, rStyleInfo, aBorderLine)) if (lcl_extractTableBorderProperty(pMergedProperties, PROP_LEFT_BORDER, rStyleInfo, aBorderLine))
{ {
aGrabBag[3].Name = "TableStyleLeftBorder"; aGrabBag[nGrabBagSize].Name = "TableStyleLeftBorder";
aGrabBag[3].Value = uno::makeAny( aBorderLine ); aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine );
nGrabBagSize++; nGrabBagSize++;
} }
if (lcl_extractTableBorderProperty(pMergedProperties, PROP_RIGHT_BORDER, rStyleInfo, aBorderLine)) if (lcl_extractTableBorderProperty(pMergedProperties, PROP_RIGHT_BORDER, rStyleInfo, aBorderLine))
{ {
aGrabBag[4].Name = "TableStyleRightBorder"; aGrabBag[nGrabBagSize].Name = "TableStyleRightBorder";
aGrabBag[4].Value = uno::makeAny( aBorderLine ); aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine );
nGrabBagSize++; nGrabBagSize++;
} }
......
...@@ -457,6 +457,14 @@ const uno::Sequence<beans::PropertyValue> DomainMapperTableManager::getCurrentTa ...@@ -457,6 +457,14 @@ const uno::Sequence<beans::PropertyValue> DomainMapperTableManager::getCurrentTa
return uno::Sequence< beans::PropertyValue >( 0 ); return uno::Sequence< beans::PropertyValue >( 0 );
} }
TablePositionHandler* DomainMapperTableManager::getCurrentTableRealPosition()
{
if ( !m_aTablePositions.empty( ) && m_aTablePositions.back() )
return (m_aTablePositions.back( )).get();
else
return 0;
}
void DomainMapperTableManager::startLevel( ) void DomainMapperTableManager::startLevel( )
{ {
DomainMapperTableManager_Base_t::startLevel( ); DomainMapperTableManager_Base_t::startLevel( );
......
...@@ -94,6 +94,7 @@ public: ...@@ -94,6 +94,7 @@ public:
const OUString& getTableStyleName() const { return m_sTableStyleName; } const OUString& getTableStyleName() const { return m_sTableStyleName; }
const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getCurrentTablePosition(); const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getCurrentTablePosition();
TablePositionHandler* getCurrentTableRealPosition();
virtual void cellProps(TablePropertyMapPtr pProps) SAL_OVERRIDE virtual void cellProps(TablePropertyMapPtr pProps) SAL_OVERRIDE
{ {
......
...@@ -38,6 +38,48 @@ class TablePositionHandler ...@@ -38,6 +38,48 @@ class TablePositionHandler
virtual void lcl_sprm(Sprm& sprm) SAL_OVERRIDE; virtual void lcl_sprm(Sprm& sprm) SAL_OVERRIDE;
public: public:
int getY()
{
return m_nY;
}
int getX()
{
return m_nX;
}
int getLeftFromText()
{
return m_nLeftFromText;
}
int getRightFromText()
{
return m_nRightFromText;
}
int getTopFromText()
{
return m_nTopFromText;
}
int getBottomFromText()
{
return m_nBottomFromText;
}
OUString getVertAnchor()
{
return m_aVertAnchor;
}
OUString getYSpec()
{
return m_aYSpec;
}
OUString getHorzAnchor()
{
return m_aHorzAnchor;
}
OUString getXSpec()
{
return m_aXSpec;
}
TablePositionHandler(); TablePositionHandler();
virtual ~TablePositionHandler(); virtual ~TablePositionHandler();
......
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