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

DOCX filter: roundtrip more table cell border properties for table styles

Change-Id: Ia93bd2083b00f62770970a4efa783b6b19967acb
üst fc687458
......@@ -1320,6 +1320,7 @@ DECLARE_OOXML_TEST(testCalendar1, "calendar1.docx")
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");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='band2Horz']/w:tcPr/w:tcBorders/w:top", "themeColor", "text1");
}
DECLARE_OOXML_TEST(testSmartart, "smartart.docx")
......
......@@ -91,6 +91,15 @@ void lcl_TableStyleTblCellMar(sax_fastparser::FSHelperPtr pSerializer, uno::Sequ
pSerializer->endElementNS(XML_w, XML_tblCellMar);
}
static DocxStringTokenMap const aTcBorderTokens[] = {
{"val", XML_val},
{"sz", XML_sz},
{"color", XML_color},
{"space", XML_space},
{"themeColor", XML_themeColor},
{0, 0}
};
/// 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)
{
......@@ -99,10 +108,9 @@ void lcl_TableStyleTcBorder(sax_fastparser::FSHelperPtr pSerializer, sal_Int32 n
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());
}
if (sal_Int32 nAttrToken = DocxStringGetToken(aTcBorderTokens, rTcBorder[i].Name))
pAttributeList->add(FSNS(XML_w, nAttrToken), OUStringToOString(rTcBorder[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
pSerializer->singleElementNS(XML_w, nToken, xAttributeList);
}
......
......@@ -21,6 +21,7 @@
#include <ConversionHelper.hxx>
#include <ooxml/resourceids.hxx>
#include <doctok/resourceids.hxx>
#include <filter/msfilter/util.hxx>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/text/TableColumnSeparator.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
......@@ -249,6 +250,32 @@ OUString lcl_getBorderTypeString(sal_Int32 nType)
return OUString();
}
OUString lcl_getThemeColorTypeString(sal_Int32 nType)
{
switch (nType)
{
case NS_ooxml::LN_Value_St_ThemeColor_dark1: return OUString("dark1");
case NS_ooxml::LN_Value_St_ThemeColor_light1: return OUString("light1");
case NS_ooxml::LN_Value_St_ThemeColor_dark2: return OUString("dark2");
case NS_ooxml::LN_Value_St_ThemeColor_light2: return OUString("light2");
case NS_ooxml::LN_Value_St_ThemeColor_accent1: return OUString("accent1");
case NS_ooxml::LN_Value_St_ThemeColor_accent2: return OUString("accent2");
case NS_ooxml::LN_Value_St_ThemeColor_accent3: return OUString("accent3");
case NS_ooxml::LN_Value_St_ThemeColor_accent4: return OUString("accent4");
case NS_ooxml::LN_Value_St_ThemeColor_accent5: return OUString("accent5");
case NS_ooxml::LN_Value_St_ThemeColor_accent6: return OUString("accent6");
case NS_ooxml::LN_Value_St_ThemeColor_hyperlink: return OUString("hyperlink");
case NS_ooxml::LN_Value_St_ThemeColor_followedHyperlink: return OUString("followedHyperlink");
case NS_ooxml::LN_Value_St_ThemeColor_none: return OUString("none");
case NS_ooxml::LN_Value_St_ThemeColor_background1: return OUString("background1");
case NS_ooxml::LN_Value_St_ThemeColor_text1: return OUString("text1");
case NS_ooxml::LN_Value_St_ThemeColor_background2: return OUString("background2");
case NS_ooxml::LN_Value_St_ThemeColor_text2: return OUString("text2");
default: break;
}
return OUString();
}
void TDefTableHandler::lcl_attribute(Id rName, Value & rVal)
{
sal_Int32 nIntValue = rVal.getInt();
......@@ -301,6 +328,7 @@ void TDefTableHandler::lcl_attribute(Id rName, Value & rVal)
case NS_rtf::LN_DPTLINEWIDTH: // 0x2871
// width of a single line in 1/8 pt, max of 32 pt -> twip * 5 / 2.
m_nLineWidth = nIntValue * 5 / 2;
appendGrabBag("sz", OUString::number(nIntValue));
break;
case NS_rtf::LN_BRCTYPE: // 0x2872
m_nLineType = nIntValue;
......@@ -308,9 +336,11 @@ void TDefTableHandler::lcl_attribute(Id rName, Value & rVal)
break;
case NS_ooxml::LN_CT_Border_color:
case NS_rtf::LN_ICO: // 0x2873
appendGrabBag("color", OStringToOUString(msfilter::util::ConvertColor(nIntValue), RTL_TEXTENCODING_UTF8));
m_nLineColor = nIntValue;
break;
case NS_rtf::LN_DPTSPACE: // 0x2874
appendGrabBag("space", OUString::number(nIntValue));
m_nLineDistance = nIntValue;
break;
case NS_rtf::LN_FSHADOW: // 0x2875
......@@ -320,6 +350,8 @@ void TDefTableHandler::lcl_attribute(Id rName, Value & rVal)
// ignored
break;
case NS_ooxml::LN_CT_Border_themeColor:
appendGrabBag("themeColor", lcl_getThemeColorTypeString(nIntValue));
break;
case NS_ooxml::LN_CT_Border_themeTint:
case NS_ooxml::LN_CT_Border_themeShade:
// ignored
......
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