summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinaya Mandke <vinaya.mandke@synerzip.com>2014-04-04 15:07:52 +0530
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-04-14 08:49:58 +0200
commitc1e563f6efd09cd3463f1b92a3022ae288c92087 (patch)
tree79b4290ea72ee188905702050566757c29a64c56
parent8a3eeff238d97d9d5ae548193e32c8b00a22219e (diff)
fdo#76741 [DOCX] Table Alignment and width type
There are two issue related to table in the saved(exported) file - the table alignment in saved file is "left" instead of "center" - the table width type in properties is "auto" instead of "dxa" In the issue file alignment was specified in w:tblpXSpec="center" and so were missed at import. Added support to fetch HORI_ORIENT from frame properties if its not set in Table Properties The ::GetTablePageSize returns 0 if the table width is FIXED. Modified it to return the tableWidth in such case. Conflicts: writerfilter/source/dmapper/DomainMapperTableHandler.cxx Reviewed on: https://gerrit.libreoffice.org/8846 Change-Id: I02a3af5e9d8ef3746c4d6bec0a07a24e01cc12a4
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo76741.docxbin0 -> 18895 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx25
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx5
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableHandler.cxx18
4 files changed, 46 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo76741.docx b/sw/qa/extras/ooxmlexport/data/fdo76741.docx
new file mode 100644
index 000000000000..abe9985a14df
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo76741.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index d13bb70314fb..413e4fc422ef 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2360,11 +2360,34 @@ DECLARE_OOXMLEXPORT_TEST(testSegFaultWhileSave, "test_segfault_while_save.docx")
DECLARE_OOXMLEXPORT_TEST(fdo69656, "Table_cell_auto_width_fdo69656.docx")
{
+ // Changed the UT to check "dxa" instead of "auto"
+ // For this particular issue file few cells have width type "auto"
+ // LO supports VARIABLE and FIXED width type.
+ // If type is VARIABLE LO calculates width as percent of PageSize
+ // Else if the width is fixed it uses the width value.
+ // After changes for fdo76741 the fixed width is exported as "dxa" for DOCX
+
// Check for the width type of table and its cells.
xmlDocPtr pXmlDoc = parseExport();
if (!pXmlDoc)
return;
- assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblW","type","auto");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblW","type","dxa");
+}
+
+DECLARE_OOXMLEXPORT_TEST(testFdo76741, "fdo76741.docx")
+{
+
+ // There are two issue related to table in the saved(exported) file
+ // - the table alignment in saved file is "left" instead of "center"
+ // - the table width type in properties is "auto" instead of "dxa"
+
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+
+ if (!pXmlDoc)
+ return;
+ assertXPath(pXmlDoc, "//w:jc", "val", "center");
+ assertXPath(pXmlDoc, "//w:tblW", "w", "10081");
+ assertXPath(pXmlDoc, "//w:tblW", "type", "dxa");
}
DECLARE_OOXMLEXPORT_TEST(testFdo73541,"fdo73541.docx")
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index fdb323c25eb1..c05aa512587d 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -2382,6 +2382,11 @@ void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner * pTableT
nPageSize /= 100;
}
}
+ else
+ {
+ // As the table width is not relative, the TablePageSize equals its width
+ nPageSize = nTblSz;
+ }
rPageSize = nPageSize;
rRelBoxSize = bRelBoxSize;
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 336514b78438..0292c58fa12e 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -307,6 +307,20 @@ bool lcl_extractTableBorderProperty(PropertyMapPtr pTableProperties, const Prope
}
+bool lcl_extractHoriOrient(uno::Sequence<beans::PropertyValue>& rFrameProperties, sal_Int32& nHoriOrient)
+{
+ // Shifts the frame left by the given value.
+ for (sal_Int32 i = 0; i < rFrameProperties.getLength(); ++i)
+ {
+ if (rFrameProperties[i].Name == "HoriOrient")
+ {
+ nHoriOrient = rFrameProperties[i].Value.get<sal_Int32>();
+ return true;
+ }
+ }
+ return false;
+}
+
void lcl_DecrementHoriOrientPosition(uno::Sequence<beans::PropertyValue>& rFrameProperties, sal_Int32 nAmount)
{
// Shifts the frame left by the given value.
@@ -543,7 +557,9 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo
}
sal_Int32 nHoriOrient = text::HoriOrientation::LEFT_AND_WIDTH;
- m_aTableProperties->getValue( TablePropertyMap::HORI_ORIENT, nHoriOrient ) ;
+ // Fetch Horizontal Orientation in rFrameProperties if not set in m_aTableProperties
+ if ( !m_aTableProperties->getValue( TablePropertyMap::HORI_ORIENT, nHoriOrient ) )
+ lcl_extractHoriOrient( rFrameProperties, nHoriOrient );
m_aTableProperties->Insert( PROP_HORI_ORIENT, uno::makeAny( sal_Int16(nHoriOrient) ) );
//fill default value - if not available
const PropertyMap::const_iterator aRepeatIter =