summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-08-05 10:21:23 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-08-05 10:54:18 +0200
commit1b9353bae0e25d460555828ab33c8afe45b75a6d (patch)
tree51bb1a60c7c4cde74a6375f96354b7a4e1a9e4a7 /sw
parenta9bae49661f817236f0aa168dd2f054b6bca0b2b (diff)
DOCX export: handle all attributes of CT_TblLook
Change-Id: Ibe72d60be302158001fbf6e197f30945fe8fbed9
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx10
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx47
2 files changed, 57 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 62195cc4f913..d595af3371a2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1309,6 +1309,16 @@ DECLARE_OOXMLEXPORT_TEST(testCalendar1, "calendar1.docx")
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tcPr/w:vAlign", "val", "bottom");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='lastRow']/w:tcPr/w:tcBorders/w:tr2bl", "val", "nil");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='band2Horz']/w:tcPr/w:tcBorders/w:top", "themeColor", "text1");
+
+ // w:tblLook element and its attributes were missing.
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "firstRow", "1");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "lastRow", "0");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "lastColumn", "0");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "firstColumn", "1");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "noHBand", "0");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "noVBand", "1");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "val", "04a0");
}
DECLARE_OOXMLEXPORT_TEST(testCalendar2, "calendar2.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index c66a6eaa2132..bf005881e7dc 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2950,6 +2950,21 @@ void DocxAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*
{
}
+/// Does the same as comphelper::string::padToLength(), but extends the start, not the end.
+OString lcl_padStartToLength(OString aString, sal_Int32 nLen, sal_Char cFill)
+{
+ if (nLen > aString.getLength())
+ {
+ sal_Int32 nDiff = nLen - aString.getLength();
+ OStringBuffer aBuffer;
+ comphelper::string::padToLength(aBuffer, nDiff, cFill);
+ aBuffer.append(aString);
+ return aBuffer.makeStringAndClear();
+ }
+ else
+ return aString;
+}
+
void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
{
bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
@@ -3057,6 +3072,36 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
m_aTableStyleConf[ BOX_LINE_LEFT ] = aGrabBagElement->second.get<table::BorderLine2>();
else if( aGrabBagElement->first == "TableStyleRightBorder" )
m_aTableStyleConf[ BOX_LINE_RIGHT ] = aGrabBagElement->second.get<table::BorderLine2>();
+ else if (aGrabBagElement->first == "TableStyleLook")
+ {
+ FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
+ uno::Sequence<beans::PropertyValue> aAttributeList = aGrabBagElement->second.get< uno::Sequence<beans::PropertyValue> >();
+
+ for (sal_Int32 i = 0; i < aAttributeList.getLength(); ++i)
+ {
+ if (aAttributeList[i].Name == "val")
+ pAttributeList->add(FSNS(XML_w, XML_val), lcl_padStartToLength(OString::number(aAttributeList[i].Value.get<sal_Int32>(), 16), 4, '0'));
+ else
+ {
+ static DocxStringTokenMap const aTokens[] =
+ {
+ {"firstRow", XML_firstRow},
+ {"lastRow", XML_lastRow},
+ {"firstColumn", XML_firstColumn},
+ {"lastColumn", XML_lastColumn},
+ {"noHBand", XML_noHBand},
+ {"noVBand", XML_noVBand},
+ {0, 0}
+ };
+
+ if (sal_Int32 nToken = DocxStringGetToken(aTokens, aAttributeList[i].Name))
+ pAttributeList->add(FSNS(XML_w, nToken), (aAttributeList[i].Value.get<sal_Int32>() ? "1" : "0"));
+ }
+ }
+
+ XFastAttributeListRef xAttributeList(pAttributeList);
+ m_pSerializer->singleElementNS(XML_w, XML_tblLook, xAttributeList);
+ }
else if (aGrabBagElement->first == "TablePosition" )
{
FastAttributeList *attrListTablePos = m_pSerializer->createAttrList( );
@@ -3114,6 +3159,8 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
m_pSerializer->singleElementNS( XML_w, XML_tblpPr, xAttrListTablePosRef);
attrListTablePos = NULL;
}
+ else
+ SAL_WARN("sw.ww8", "DocxAttributeOutput::TableDefinition: unhandled property: " << aGrabBagElement->first);
}
// Output the table alignement