summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-10-31 12:14:40 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-10-31 13:02:55 +0100
commit62f67d64b4c98cdfe20cad824cf11f343d3f8d7f (patch)
tree9fdedae5ea01f8af600007f3cc11a946a86cd7f8 /sw
parent8b8ef8d6331d84638bc253cb7d06faf37e0cc1b3 (diff)
writerfilter: implement TDefTableHandler::getInteropGrabBag
This allows to roundtrip table cell borders in conditional table style definitions for DOCX. Change-Id: Ibc0da9996e98e89864c001294695328c15c1549c
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx1
-rw-r--r--sw/source/filter/ww8/docxtablestyleexport.cxx48
2 files changed, 48 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 502873316e50..1e46c83b64b9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1476,6 +1476,7 @@ void Test::testCalendar1()
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:rFonts", "hAnsiTheme", "minorHAnsi");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tblPr", 1);
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");
}
void Test::testSmartart()
diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx
index 634368a2edb1..9aaad80ad22e 100644
--- a/sw/source/filter/ww8/docxtablestyleexport.cxx
+++ b/sw/source/filter/ww8/docxtablestyleexport.cxx
@@ -91,6 +91,49 @@ void lcl_TableStyleTblCellMar(sax_fastparser::FSHelperPtr pSerializer, uno::Sequ
pSerializer->endElementNS(XML_w, XML_tblCellMar);
}
+/// Export of a given table cell border type in a table style.
+void lcl_TableStyleTcBorder(sax_fastparser::FSHelperPtr pSerializer, sal_Int32 nToken, const uno::Sequence<beans::PropertyValue>& rTcBorder)
+{
+ if (!rTcBorder.hasElements())
+ return;
+
+ sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+ for (sal_Int32 i = 0; i < rTcBorder.getLength(); ++i)
+ {
+ if (rTcBorder[i].Name == "val")
+ pAttributeList->add(FSNS(XML_w, XML_val), OUStringToOString(rTcBorder[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ }
+ sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
+ pSerializer->singleElementNS(XML_w, nToken, xAttributeList);
+}
+
+DocxStringTokenMap const aTcBordersTokens[] = {
+ {"left", XML_left},
+ {"right", XML_right},
+ {"start", XML_start},
+ {"end", XML_end},
+ {"top", XML_top},
+ {"bottom", XML_bottom},
+ {"insideH", XML_insideH},
+ {"insideV", XML_insideV},
+ {"tl2br", XML_tl2br},
+ {"tr2bl", XML_tr2bl},
+ {0, 0}
+};
+
+/// Export of w:tcBorders in a table style.
+void lcl_TableStyleTcBorders(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTcBorders)
+{
+ if (!rTcBorders.hasElements())
+ return;
+
+ pSerializer->startElementNS(XML_w, XML_tcBorders, FSEND);
+ for (sal_Int32 i = 0; i < rTcBorders.getLength(); ++i)
+ if (sal_Int32 nToken = DocxStringGetToken(aTcBordersTokens, rTcBorders[i].Name))
+ lcl_TableStyleTcBorder(pSerializer, nToken, rTcBorders[i].Value.get< uno::Sequence<beans::PropertyValue> >());
+ pSerializer->endElementNS(XML_w, XML_tcBorders);
+}
+
/// Export of w:shd in a table style.
void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rShd)
{
@@ -325,15 +368,18 @@ void lcl_TableStyleTcPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<b
pSerializer->startElementNS(XML_w, XML_tcPr, FSEND);
- uno::Sequence<beans::PropertyValue> aShd;
+ uno::Sequence<beans::PropertyValue> aShd, aTcBorders;
OUString aVAlign;
for (sal_Int32 i = 0; i < rTcPr.getLength(); ++i)
{
if (rTcPr[i].Name == "shd")
aShd = rTcPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
+ else if (rTcPr[i].Name == "tcBorders")
+ aTcBorders = rTcPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
else if (rTcPr[i].Name == "vAlign")
aVAlign = rTcPr[i].Value.get<OUString>();
}
+ lcl_TableStyleTcBorders(pSerializer, aTcBorders);
lcl_TableStyleShd(pSerializer, aShd);
if (!aVAlign.isEmpty())
pSerializer->singleElementNS(XML_w, XML_vAlign,