summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2013-10-29 11:38:17 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2013-10-29 11:45:40 +0100
commitef439702fa80ed8730d885aeded60dbf0bc5d264 (patch)
treecb1f65797c6d89db6519d788f5de847ea8213b27 /sw
parenta14d3e0a344ad43825574e8ba7b3b0ba04e8bf80 (diff)
DOCX export: handle table style's pPr / rPr from InteropGrabBag
Change-Id: I6dfb29db030212e55a207f39e79a1cf01d482e85
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx4
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx101
2 files changed, 104 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 9db8db856392..ffe9c62b438b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1466,6 +1466,10 @@ void Test::testCalendar1()
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:rsid", "val", "00903003");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblPr/w:tblStyleColBandSize", "val", "1");
assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tcPr/w:shd", "val", "clear");
+
+ // Table style lost its paragraph / run properties.
+ assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:pPr/w:spacing", "lineRule", "auto");
+ assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:rPr/w:lang", "eastAsia", "ja-JP");
}
void Test::testSmartart()
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 089f7351ec80..9fb6f67f8bd8 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2737,6 +2737,58 @@ void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be
pSerializer->singleElementNS(XML_w, XML_shd, xAttributeList);
}
+/// Export of w:lang in a table style.
+void lcl_TableStyleRLang(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rLang)
+{
+ if (!rLang.hasElements())
+ return;
+
+ sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+ for (sal_Int32 i = 0; i < rLang.getLength(); ++i)
+ {
+ if (rLang[i].Name == "eastAsia")
+ pAttributeList->add(FSNS(XML_w, XML_eastAsia), OUStringToOString(rLang[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ }
+ XFastAttributeListRef xAttributeList(pAttributeList);
+ pSerializer->singleElementNS(XML_w, XML_lang, xAttributeList);
+}
+
+/// Export of w:rFonts in a table style.
+void lcl_TableStyleRRFonts(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rRFonts)
+{
+ if (!rRFonts.hasElements())
+ return;
+
+ sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+ for (sal_Int32 i = 0; i < rRFonts.getLength(); ++i)
+ {
+ if (rRFonts[i].Name == "eastAsiaTheme")
+ pAttributeList->add(FSNS(XML_w, XML_eastAsiaTheme), OUStringToOString(rRFonts[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ }
+ XFastAttributeListRef xAttributeList(pAttributeList);
+ pSerializer->singleElementNS(XML_w, XML_rFonts, xAttributeList);
+}
+
+/// Export of w:spacing in a table style.
+void lcl_TableStylePSpacing(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rSpacing)
+{
+ if (!rSpacing.hasElements())
+ return;
+
+ sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+ for (sal_Int32 i = 0; i < rSpacing.getLength(); ++i)
+ {
+ if (rSpacing[i].Name == "after")
+ pAttributeList->add(FSNS(XML_w, XML_after), OUStringToOString(rSpacing[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ else if (rSpacing[i].Name == "line")
+ pAttributeList->add(FSNS(XML_w, XML_line), OUStringToOString(rSpacing[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ else if (rSpacing[i].Name == "lineRule")
+ pAttributeList->add(FSNS(XML_w, XML_lineRule), OUStringToOString(rSpacing[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
+ }
+ XFastAttributeListRef xAttributeList(pAttributeList);
+ pSerializer->singleElementNS(XML_w, XML_spacing, xAttributeList);
+}
+
/// Export of w:tblInd in a table style.
void lcl_TableStyleTblInd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTblInd)
{
@@ -2755,6 +2807,47 @@ void lcl_TableStyleTblInd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence
pSerializer->singleElementNS(XML_w, XML_tblInd, xAttributeList);
}
+/// Export of w:rPr in a table style.
+void lcl_TableStyleRPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rRPr)
+{
+ if (!rRPr.hasElements())
+ return;
+
+ pSerializer->startElementNS(XML_w, XML_rPr, FSEND);
+
+ uno::Sequence<beans::PropertyValue> aRFonts, aLang;
+ for (sal_Int32 i = 0; i < rRPr.getLength(); ++i)
+ {
+ if (rRPr[i].Name == "rFonts")
+ aRFonts = rRPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
+ else if (rRPr[i].Name == "lang")
+ aLang = rRPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
+ }
+ lcl_TableStyleRRFonts(pSerializer, aRFonts);
+ lcl_TableStyleRLang(pSerializer, aLang);
+
+ pSerializer->endElementNS(XML_w, XML_rPr);
+}
+
+/// Export of w:pPr in a table style.
+void lcl_TableStylePPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rPPr)
+{
+ if (!rPPr.hasElements())
+ return;
+
+ pSerializer->startElementNS(XML_w, XML_pPr, FSEND);
+
+ uno::Sequence<beans::PropertyValue> aSpacing;
+ for (sal_Int32 i = 0; i < rPPr.getLength(); ++i)
+ {
+ if (rPPr[i].Name == "spacing")
+ aSpacing = rPPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
+ }
+ lcl_TableStylePSpacing(pSerializer, aSpacing);
+
+ pSerializer->endElementNS(XML_w, XML_pPr);
+}
+
/// Export of w:tblPr in a table style.
void lcl_TableStyleTblPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTblPr)
{
@@ -2814,7 +2907,7 @@ void DocxAttributeOutput::TableStyle(uno::Sequence<beans::PropertyValue>& rStyle
bool bDefault = false, bCustomStyle = false, bQFormat = false, bSemiHidden = false, bUnhideWhenUsed = false;
OUString aStyleId, aName, aBasedOn;
sal_Int32 nUiPriority = 0, nRsid = 0;
- uno::Sequence<beans::PropertyValue> aTblPr, aTcPr;
+ uno::Sequence<beans::PropertyValue> aPPr, aRPr, aTblPr, aTcPr;
for (sal_Int32 i = 0; i < rStyle.getLength(); ++i)
{
if (rStyle[i].Name == "default")
@@ -2837,6 +2930,10 @@ void DocxAttributeOutput::TableStyle(uno::Sequence<beans::PropertyValue>& rStyle
bUnhideWhenUsed = true;
else if (rStyle[i].Name == "rsid")
nRsid = rStyle[i].Value.get<sal_Int32>();
+ else if (rStyle[i].Name == "pPr")
+ aPPr = rStyle[i].Value.get< uno::Sequence<beans::PropertyValue> >();
+ else if (rStyle[i].Name == "rPr")
+ aRPr = rStyle[i].Value.get< uno::Sequence<beans::PropertyValue> >();
else if (rStyle[i].Name == "tblPr")
aTblPr = rStyle[i].Value.get< uno::Sequence<beans::PropertyValue> >();
else if (rStyle[i].Name == "tcPr")
@@ -2883,6 +2980,8 @@ void DocxAttributeOutput::TableStyle(uno::Sequence<beans::PropertyValue>& rStyle
FSEND);
}
+ lcl_TableStylePPr(m_pSerializer, aPPr);
+ lcl_TableStyleRPr(m_pSerializer, aRPr);
lcl_TableStyleTblPr(m_pSerializer, aTblPr);
lcl_TableStyleTcPr(m_pSerializer, aTcPr);