sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 8 ++++ sw/source/filter/ww8/docxtablestyleexport.cxx | 37 +++++++++++++++++++++-- writerfilter/source/dmapper/CellColorHandler.cxx | 7 +++- writerfilter/source/dmapper/DomainMapper.cxx | 11 ++++++ 4 files changed, 59 insertions(+), 4 deletions(-)
New commits: commit 4bfa4a69a89337f1839a310a2fe83caf82e37df5 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Nov 4 17:09:06 2013 +0100 DOCX filter: handle CT_Ind_rightChars and CT_PPrBase_snapToGrid Also, add InteropGrabBag support to bCs, themeFill, themeFillShade and w:ind's right attribute. Change-Id: I0d6ad0ef062218e71d7c71f99c56dd680b6930de diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ed0b000..91dd026 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1349,6 +1349,14 @@ DECLARE_OOXML_TEST(testQuicktables, "quicktables.docx") assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:rPr/w:rFonts", "cstheme", "majorBidi"); assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:rPr/w:color", "themeTint", "80"); CPPUNIT_ASSERT(getXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:color", "themeShade").equalsIgnoreAsciiCase("BF")); + + // Calendar4. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:pPr/w:snapToGrid", "val", "0"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:rPr/w:bCs", 1); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tcPr/w:shd", "themeFill", "accent1"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tcPr/w:shd", "themeFillShade", "80"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='firstCol']/w:pPr/w:ind", "rightChars", "0"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='firstCol']/w:pPr/w:ind", "right", "144"); } DECLARE_OOXML_TEST(testSmartart, "smartart.docx") diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx index 8e468f0..8a1510d 100644 --- a/sw/source/filter/ww8/docxtablestyleexport.cxx +++ b/sw/source/filter/ww8/docxtablestyleexport.cxx @@ -158,6 +158,10 @@ void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be pAttributeList->add(FSNS(XML_w, XML_color), msfilter::util::ConvertColor(rShd[i].Value.get<sal_Int32>(), /*bAutoColor =*/ true)); else if (rShd[i].Name == "fill") pAttributeList->add(FSNS(XML_w, XML_fill), msfilter::util::ConvertColor(rShd[i].Value.get<sal_Int32>(), /*bAutoColor =*/ true)); + else if (rShd[i].Name == "themeFill") + pAttributeList->add(FSNS(XML_w, XML_themeFill), OUStringToOString(rShd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr()); + else if (rShd[i].Name == "themeFillShade") + pAttributeList->add(FSNS(XML_w, XML_themeFillShade), OUStringToOString(rShd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr()); } sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList); pSerializer->singleElementNS(XML_w, XML_shd, xAttributeList); @@ -255,6 +259,24 @@ void lcl_TableStylePSpacing(sax_fastparser::FSHelperPtr pSerializer, uno::Sequen pSerializer->singleElementNS(XML_w, XML_spacing, xAttributeList); } +/// Export of w:ind in a table style's pPr. +void lcl_TableStylePInd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rInd) +{ + if (!rInd.hasElements()) + return; + + sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList(); + for (sal_Int32 i = 0; i < rInd.getLength(); ++i) + { + if (rInd[i].Name == "rightChars") + pAttributeList->add(FSNS(XML_w, XML_rightChars), OUStringToOString(rInd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr()); + else if (rInd[i].Name == "right") + pAttributeList->add(FSNS(XML_w, XML_right), OUStringToOString(rInd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr()); + } + sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList); + pSerializer->singleElementNS(XML_w, XML_ind, xAttributeList); +} + /// Export of w:tblInd in a table style. void lcl_TableStyleTblInd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTblInd) { @@ -293,7 +315,7 @@ void lcl_TableStyleRPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be pSerializer->startElementNS(XML_w, XML_rPr, FSEND); uno::Sequence<beans::PropertyValue> aRFonts, aLang, aColor; - OUString aB, aI, aSz, aSzCs, aCaps, aSmallCaps, aSpacing; + OUString aB, aBCs, aI, aSz, aSzCs, aCaps, aSmallCaps, aSpacing; for (sal_Int32 i = 0; i < rRPr.getLength(); ++i) { if (rRPr[i].Name == "rFonts") @@ -302,6 +324,8 @@ void lcl_TableStyleRPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be aLang = rRPr[i].Value.get< uno::Sequence<beans::PropertyValue> >(); else if (rRPr[i].Name == "b") aB = rRPr[i].Value.get<OUString>(); + else if (rRPr[i].Name == "bCs") + aBCs = rRPr[i].Value.get<OUString>(); else if (rRPr[i].Name == "i") aI = rRPr[i].Value.get<OUString>(); else if (rRPr[i].Name == "color") @@ -320,6 +344,7 @@ void lcl_TableStyleRPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be lcl_TableStyleRRFonts(pSerializer, aRFonts); lcl_TableStyleRLang(pSerializer, aLang); lcl_handleBoolean(aB, XML_b, pSerializer); + lcl_handleBoolean(aBCs, XML_bCs, pSerializer); lcl_handleBoolean(aI, XML_i, pSerializer); lcl_handleBoolean(aCaps, XML_caps, pSerializer); lcl_handleBoolean(aSmallCaps, XML_smallCaps, pSerializer); @@ -348,20 +373,26 @@ void lcl_TableStylePPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be pSerializer->startElementNS(XML_w, XML_pPr, FSEND); - uno::Sequence<beans::PropertyValue> aSpacing; + uno::Sequence<beans::PropertyValue> aSpacing, aInd; bool bWordWrap = false; - OUString aJc; + OUString aJc, aSnapToGrid; for (sal_Int32 i = 0; i < rPPr.getLength(); ++i) { if (rPPr[i].Name == "spacing") aSpacing = rPPr[i].Value.get< uno::Sequence<beans::PropertyValue> >(); + else if (rPPr[i].Name == "ind") + aInd = rPPr[i].Value.get< uno::Sequence<beans::PropertyValue> >(); else if (rPPr[i].Name == "wordWrap") bWordWrap = true; else if (rPPr[i].Name == "jc") aJc = rPPr[i].Value.get<OUString>(); + else if (rPPr[i].Name == "snapToGrid") + aSnapToGrid = rPPr[i].Value.get<OUString>(); } if (bWordWrap) pSerializer->singleElementNS(XML_w, XML_wordWrap, FSEND); + lcl_TableStylePInd(pSerializer, aInd); + lcl_handleBoolean(aSnapToGrid, XML_snapToGrid, pSerializer); lcl_TableStylePSpacing(pSerializer, aSpacing); if (!aJc.isEmpty()) pSerializer->singleElementNS(XML_w, XML_jc, diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx index 09f020f..8aac72d 100644 --- a/writerfilter/source/dmapper/CellColorHandler.cxx +++ b/writerfilter/source/dmapper/CellColorHandler.cxx @@ -20,6 +20,7 @@ #include <PropertyMap.hxx> #include <doctok/resourceids.hxx> #include <ConversionHelper.hxx> +#include <TDefTableHandler.hxx> #include <ooxml/resourceids.hxx> #include <com/sun/star/drawing/ShadingPattern.hpp> #include <sal/macros.h> @@ -129,8 +130,12 @@ void CellColorHandler::lcl_attribute(Id rName, Value & rVal) m_nColor = nIntValue; break; case NS_ooxml::LN_CT_Shd_themeFill: - case NS_ooxml::LN_CT_Shd_themeFillTint: + createGrabBag("themeFill", uno::makeAny(TDefTableHandler::getThemeColorTypeString(nIntValue))); + break; case NS_ooxml::LN_CT_Shd_themeFillShade: + createGrabBag("themeFillShade", uno::makeAny(OUString::number(nIntValue, 16))); + break; + case NS_ooxml::LN_CT_Shd_themeFillTint: // ignored break; default: diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 9a6488f..4f9d233 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -1082,6 +1082,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) m_pImpl->GetTopContext()->Insert( PROP_PARA_RIGHT_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) )); } + m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "right", OUString::number(nIntValue)); break; case NS_ooxml::LN_CT_Ind_hanging: if (m_pImpl->GetTopContext()) @@ -1096,6 +1097,9 @@ void DomainMapper::lcl_attribute(Id nName, Value & val) m_pImpl->GetTopContext()->Insert( PROP_PARA_FIRST_LINE_INDENT, uno::makeAny( ConversionHelper::convertTwipToMM100(nIntValue ) )); break; + case NS_ooxml::LN_CT_Ind_rightChars: + m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "rightChars", OUString::number(nIntValue)); + break; case NS_ooxml::LN_CT_EastAsianLayout_id: break; @@ -2172,6 +2176,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_WEIGHT), aBold); if (nSprmId == NS_sprm::LN_CFBold) m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "b", OUString::number(nIntValue)); + else if (nSprmId == NS_sprm::LN_CFBoldBi) + m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "bCs", OUString::number(nIntValue)); } break; case 61: /*sprmCFItalic*/ @@ -3033,6 +3039,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lang", m_pImpl->m_aSubInteropGrabBag); else if (nSprmId == NS_ooxml::LN_EG_RPrBase_color) m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "color", m_pImpl->m_aSubInteropGrabBag); + else if (nSprmId == NS_ooxml::LN_CT_PPrBase_ind) + m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "ind", m_pImpl->m_aSubInteropGrabBag); break; case NS_ooxml::LN_CT_PPrBase_wordWrap: m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "wordWrap", ""); @@ -3178,6 +3186,9 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType } break; + case NS_ooxml::LN_CT_PPrBase_snapToGrid: + m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "snapToGrid", OUString::number(nIntValue)); + break; case NS_ooxml::LN_CT_PPrBase_pStyle: { mbIsBIDI = false; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits