[Libreoffice-commits] core.git: 4 commits - sw/qa sw/source writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Nov 5 15:48:16 CET 2013


 sw/qa/extras/ooxmlexport/ooxmlexport.cxx         |    9 
 sw/source/filter/ww8/docxtablestyleexport.cxx    |  297 ++++++++++++-----------
 writerfilter/source/dmapper/BorderHandler.cxx    |    2 
 writerfilter/source/dmapper/CellColorHandler.cxx |    6 
 writerfilter/source/dmapper/DomainMapper.cxx     |    3 
 writerfilter/source/dmapper/TDefTableHandler.cxx |    2 
 6 files changed, 176 insertions(+), 143 deletions(-)

New commits:
commit dc30cdbc8d5e7772281511188ba2d2a7c4c8af51
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 5 15:03:33 2013 +0100

    Avoid local methods in DocxTableStyleExport
    
    We already have DocxTableStyleExport::Impl, use that instead of passing
    around the serializer with no good reason.
    
    Change-Id: I8cc47c34201219c4102c5edb21bcc1455da48ff4

diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx
index 752a155..61eea42 100644
--- a/sw/source/filter/ww8/docxtablestyleexport.cxx
+++ b/sw/source/filter/ww8/docxtablestyleexport.cxx
@@ -25,12 +25,47 @@
 using namespace com::sun::star;
 using namespace oox;
 
+/// Methods in this class handle values in a table style.
 struct DocxTableStyleExport::Impl
 {
     SwDoc* m_pDoc;
     sax_fastparser::FSHelperPtr m_pSerializer;
 
     void TableStyle(uno::Sequence<beans::PropertyValue>& rStyle);
+
+    /// Handles a boolean value.
+    void handleBoolean(OUString aValue, sal_Int32 nToken);
+
+    /// Export of w:pPr.
+    void tableStylePPr(uno::Sequence<beans::PropertyValue>& rPPr);
+    /// Export of w:tblStylePr.
+    void tableStyleTblStylePr(uno::Sequence<beans::PropertyValue>& rTblStylePr);
+    /// Export of w:rPr.
+    void tableStyleRPr(uno::Sequence<beans::PropertyValue>& rRPr);
+    /// Export of w:rFonts.
+    void tableStyleRRFonts(uno::Sequence<beans::PropertyValue>& rRFonts);
+    /// Export of w:lang.
+    void tableStyleRLang(uno::Sequence<beans::PropertyValue>& rLang);
+    /// Export of w:ind in a pPr.
+    void tableStylePInd(uno::Sequence<beans::PropertyValue>& rInd);
+    /// Export of w:spacing.
+    void tableStylePSpacing(uno::Sequence<beans::PropertyValue>& rSpacing);
+    /// Export of w:tblPr.
+    void tableStyleTblPr(uno::Sequence<beans::PropertyValue>& rTblPr);
+    /// Export of w:tcPr.
+    void tableStyleTcPr(uno::Sequence<beans::PropertyValue>& rTcPr);
+    /// Export of w:tcBorders (and w:tblBorders).
+    void tableStyleTcBorders(uno::Sequence<beans::PropertyValue>& rTcBorders, sal_Int32 nToken = XML_tcBorders);
+    /// Export of w:tblInd.
+    void tableStyleTblInd(uno::Sequence<beans::PropertyValue>& rTblInd);
+    /// Export of w:tblCellMar (and w:tcMar).
+    void tableStyleTblCellMar(uno::Sequence<beans::PropertyValue>& rTblCellMar, sal_Int32 nType = XML_tblCellMar);
+    /// Export of a given table cell border type.
+    void tableStyleTcBorder(sal_Int32 nToken, const uno::Sequence<beans::PropertyValue>& rTcBorder);
+    /// Export of w:shd.
+    void tableStyleShd(uno::Sequence<beans::PropertyValue>& rShd);
+    /// Export of w:color.
+    void tableStyleRColor(uno::Sequence<beans::PropertyValue>& rColor);
 };
 
 void DocxTableStyleExport::TableStyles()
@@ -59,96 +94,92 @@ void DocxTableStyleExport::TableStyles()
     }
 }
 
-DocxStringTokenMap const aTblCellMarTokens[] = {
-    {"left", XML_left},
-    {"right", XML_right},
-    {"start", XML_start},
-    {"end", XML_end},
-    {"top", XML_top},
-    {"bottom", XML_bottom},
-    {0, 0}
-};
-
-/// Export of w:tblCellMar in a table style.
-void lcl_TableStyleTblCellMar(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTblCellMar, sal_Int32 nType = XML_tblCellMar)
+void DocxTableStyleExport::Impl::tableStyleTblCellMar(uno::Sequence<beans::PropertyValue>& rTblCellMar, sal_Int32 nType)
 {
+    static DocxStringTokenMap const aTblCellMarTokens[] = {
+        {"left", XML_left},
+        {"right", XML_right},
+        {"start", XML_start},
+        {"end", XML_end},
+        {"top", XML_top},
+        {"bottom", XML_bottom},
+        {0, 0}
+    };
+
     if (!rTblCellMar.hasElements())
         return;
 
-    pSerializer->startElementNS(XML_w, nType, FSEND);
+    m_pSerializer->startElementNS(XML_w, nType, FSEND);
     for (sal_Int32 i = 0; i < rTblCellMar.getLength(); ++i)
     {
         if (sal_Int32 nToken = DocxStringGetToken(aTblCellMarTokens, rTblCellMar[i].Name))
         {
             comphelper::SequenceAsHashMap aMap(rTblCellMar[i].Value.get< uno::Sequence<beans::PropertyValue> >());
-            pSerializer->singleElementNS(XML_w, nToken,
+            m_pSerializer->singleElementNS(XML_w, nToken,
                     FSNS(XML_w, XML_w), OString::number(aMap["w"].get<sal_Int32>()),
                     FSNS(XML_w, XML_type), OUStringToOString(aMap["type"].get<OUString>(), RTL_TEXTENCODING_UTF8).getStr(),
                     FSEND);
         }
     }
-    pSerializer->endElementNS(XML_w, nType);
+    m_pSerializer->endElementNS(XML_w, nType);
 }
 
-static DocxStringTokenMap const aTcBorderTokens[] = {
-    {"val", XML_val},
-    {"sz", XML_sz},
-    {"color", XML_color},
-    {"space", XML_space},
-    {"themeColor", XML_themeColor},
-    {"themeTint", XML_themeTint},
-    {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)
+void DocxTableStyleExport::Impl::tableStyleTcBorder(sal_Int32 nToken, const uno::Sequence<beans::PropertyValue>& rTcBorder)
 {
+    static DocxStringTokenMap const aTcBorderTokens[] = {
+        {"val", XML_val},
+        {"sz", XML_sz},
+        {"color", XML_color},
+        {"space", XML_space},
+        {"themeColor", XML_themeColor},
+        {"themeTint", XML_themeTint},
+        {0, 0}
+    };
+
     if (!rTcBorder.hasElements())
         return;
 
-    sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+    sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
     for (sal_Int32 i = 0; i < rTcBorder.getLength(); ++i)
         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);
+    m_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 (and w:tblBorders) in a table style.
-void lcl_TableStyleTcBorders(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTcBorders, sal_Int32 nToken = XML_tcBorders)
+void DocxTableStyleExport::Impl::tableStyleTcBorders(uno::Sequence<beans::PropertyValue>& rTcBorders, sal_Int32 nToken)
 {
+    static 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}
+    };
+
     if (!rTcBorders.hasElements())
         return;
 
-    pSerializer->startElementNS(XML_w, nToken, FSEND);
+    m_pSerializer->startElementNS(XML_w, nToken, FSEND);
     for (sal_Int32 i = 0; i < rTcBorders.getLength(); ++i)
         if (sal_Int32 nSubToken = DocxStringGetToken(aTcBordersTokens, rTcBorders[i].Name))
-            lcl_TableStyleTcBorder(pSerializer, nSubToken, rTcBorders[i].Value.get< uno::Sequence<beans::PropertyValue> >());
-    pSerializer->endElementNS(XML_w, nToken);
+            tableStyleTcBorder(nSubToken, rTcBorders[i].Value.get< uno::Sequence<beans::PropertyValue> >());
+    m_pSerializer->endElementNS(XML_w, nToken);
 }
 
-/// Export of w:shd in a table style.
-void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rShd)
+void DocxTableStyleExport::Impl::tableStyleShd(uno::Sequence<beans::PropertyValue>& rShd)
 {
     if (!rShd.hasElements())
         return;
 
-    sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+    sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
     for (sal_Int32 i = 0; i < rShd.getLength(); ++i)
     {
         if (rShd[i].Name == "val")
@@ -165,16 +196,15 @@ void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be
             pAttributeList->add(FSNS(XML_w, XML_themeFillTint), OUStringToOString(rShd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
     }
     sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
-    pSerializer->singleElementNS(XML_w, XML_shd, xAttributeList);
+    m_pSerializer->singleElementNS(XML_w, XML_shd, xAttributeList);
 }
 
-/// Export of w:color in a table style.
-void lcl_TableStyleRColor(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rColor)
+void DocxTableStyleExport::Impl::tableStyleRColor(uno::Sequence<beans::PropertyValue>& rColor)
 {
     if (!rColor.hasElements())
         return;
 
-    sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+    sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
     for (sal_Int32 i = 0; i < rColor.getLength(); ++i)
     {
         if (rColor[i].Name == "val")
@@ -187,16 +217,15 @@ void lcl_TableStyleRColor(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence
             pAttributeList->add(FSNS(XML_w, XML_themeShade), OUStringToOString(rColor[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
     }
     sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
-    pSerializer->singleElementNS(XML_w, XML_color, xAttributeList);
+    m_pSerializer->singleElementNS(XML_w, XML_color, xAttributeList);
 }
 
-/// Export of w:lang in a table style.
-void lcl_TableStyleRLang(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rLang)
+void DocxTableStyleExport::Impl::tableStyleRLang(uno::Sequence<beans::PropertyValue>& rLang)
 {
     if (!rLang.hasElements())
         return;
 
-    sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+    sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
     for (sal_Int32 i = 0; i < rLang.getLength(); ++i)
     {
         if (rLang[i].Name == "eastAsia")
@@ -207,16 +236,15 @@ void lcl_TableStyleRLang(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<
             pAttributeList->add(FSNS(XML_w, XML_bidi), OUStringToOString(rLang[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
     }
     sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
-    pSerializer->singleElementNS(XML_w, XML_lang, xAttributeList);
+    m_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)
+void DocxTableStyleExport::Impl::tableStyleRRFonts(uno::Sequence<beans::PropertyValue>& rRFonts)
 {
     if (!rRFonts.hasElements())
         return;
 
-    sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+    sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
     for (sal_Int32 i = 0; i < rRFonts.getLength(); ++i)
     {
         if (rRFonts[i].Name == "eastAsiaTheme")
@@ -229,16 +257,15 @@ void lcl_TableStyleRRFonts(sax_fastparser::FSHelperPtr pSerializer, uno::Sequenc
             pAttributeList->add(FSNS(XML_w, XML_hAnsiTheme), OUStringToOString(rRFonts[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
     }
     sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
-    pSerializer->singleElementNS(XML_w, XML_rFonts, xAttributeList);
+    m_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)
+void DocxTableStyleExport::Impl::tableStylePSpacing(uno::Sequence<beans::PropertyValue>& rSpacing)
 {
     if (!rSpacing.hasElements())
         return;
 
-    sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+    sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
     for (sal_Int32 i = 0; i < rSpacing.getLength(); ++i)
     {
         if (rSpacing[i].Name == "after")
@@ -259,16 +286,15 @@ void lcl_TableStylePSpacing(sax_fastparser::FSHelperPtr pSerializer, uno::Sequen
             pAttributeList->add(FSNS(XML_w, XML_afterAutospacing), OUStringToOString(rSpacing[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
     }
     sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
-    pSerializer->singleElementNS(XML_w, XML_spacing, xAttributeList);
+    m_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)
+void DocxTableStyleExport::Impl::tableStylePInd(uno::Sequence<beans::PropertyValue>& rInd)
 {
     if (!rInd.hasElements())
         return;
 
-    sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+    sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
     for (sal_Int32 i = 0; i < rInd.getLength(); ++i)
     {
         if (rInd[i].Name == "rightChars")
@@ -277,16 +303,15 @@ void lcl_TableStylePInd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<b
             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);
+    m_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)
+void DocxTableStyleExport::Impl::tableStyleTblInd(uno::Sequence<beans::PropertyValue>& rTblInd)
 {
     if (!rTblInd.hasElements())
         return;
 
-    sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+    sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
     for (sal_Int32 i = 0; i < rTblInd.getLength(); ++i)
     {
         if (rTblInd[i].Name == "w")
@@ -295,27 +320,26 @@ void lcl_TableStyleTblInd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence
             pAttributeList->add(FSNS(XML_w, XML_type), OUStringToOString(rTblInd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
     }
     sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
-    pSerializer->singleElementNS(XML_w, XML_tblInd, xAttributeList);
+    m_pSerializer->singleElementNS(XML_w, XML_tblInd, xAttributeList);
 }
 
-void lcl_handleBoolean(OUString aValue, sal_Int32 nToken, sax_fastparser::FSHelperPtr pSerializer)
+void DocxTableStyleExport::Impl::handleBoolean(OUString aValue, sal_Int32 nToken)
 {
     if (aValue.isEmpty())
         return;
-    sax_fastparser::FastAttributeList* pAttributeList = pSerializer->createAttrList();
+    sax_fastparser::FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
     if (aValue != "1")
         pAttributeList->add(FSNS(XML_w, XML_val), OUStringToOString(aValue, RTL_TEXTENCODING_UTF8).getStr());
     sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
-    pSerializer->singleElementNS(XML_w, nToken, xAttributeList);
+    m_pSerializer->singleElementNS(XML_w, nToken, xAttributeList);
 }
 
-/// Export of w:rPr in a table style.
-void lcl_TableStyleRPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rRPr)
+void DocxTableStyleExport::Impl::tableStyleRPr(uno::Sequence<beans::PropertyValue>& rRPr)
 {
     if (!rRPr.hasElements())
         return;
 
-    pSerializer->startElementNS(XML_w, XML_rPr, FSEND);
+    m_pSerializer->startElementNS(XML_w, XML_rPr, FSEND);
 
     uno::Sequence<beans::PropertyValue> aRFonts, aLang, aColor;
     OUString aB, aBCs, aI, aSz, aSzCs, aCaps, aSmallCaps, aSpacing;
@@ -344,37 +368,36 @@ void lcl_TableStyleRPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be
         else if (rRPr[i].Name == "spacing")
             aSpacing = rRPr[i].Value.get<OUString>();
     }
-    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);
-    lcl_TableStyleRColor(pSerializer, aColor);
+    tableStyleRRFonts(aRFonts);
+    tableStyleRLang(aLang);
+    handleBoolean(aB, XML_b);
+    handleBoolean(aBCs, XML_bCs);
+    handleBoolean(aI, XML_i);
+    handleBoolean(aCaps, XML_caps);
+    handleBoolean(aSmallCaps, XML_smallCaps);
+    tableStyleRColor(aColor);
     if (!aSpacing.isEmpty())
-        pSerializer->singleElementNS(XML_w, XML_spacing,
+        m_pSerializer->singleElementNS(XML_w, XML_spacing,
                 FSNS(XML_w, XML_val), OUStringToOString(aSpacing, RTL_TEXTENCODING_UTF8).getStr(),
                 FSEND);
     if (!aSz.isEmpty())
-        pSerializer->singleElementNS(XML_w, XML_sz,
+        m_pSerializer->singleElementNS(XML_w, XML_sz,
                 FSNS(XML_w, XML_val), OUStringToOString(aSz, RTL_TEXTENCODING_UTF8).getStr(),
                 FSEND);
     if (!aSzCs.isEmpty())
-        pSerializer->singleElementNS(XML_w, XML_szCs,
+        m_pSerializer->singleElementNS(XML_w, XML_szCs,
                 FSNS(XML_w, XML_val), OUStringToOString(aSzCs, RTL_TEXTENCODING_UTF8).getStr(),
                 FSEND);
 
-    pSerializer->endElementNS(XML_w, XML_rPr);
+    m_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)
+void DocxTableStyleExport::Impl::tableStylePPr(uno::Sequence<beans::PropertyValue>& rPPr)
 {
     if (!rPPr.hasElements())
         return;
 
-    pSerializer->startElementNS(XML_w, XML_pPr, FSEND);
+    m_pSerializer->startElementNS(XML_w, XML_pPr, FSEND);
 
     uno::Sequence<beans::PropertyValue> aSpacing, aInd;
     bool bWordWrap = false;
@@ -393,25 +416,24 @@ void lcl_TableStylePPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be
             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);
+        m_pSerializer->singleElementNS(XML_w, XML_wordWrap, FSEND);
+    tableStylePInd(aInd);
+    handleBoolean(aSnapToGrid, XML_snapToGrid);
+    tableStylePSpacing(aSpacing);
     if (!aJc.isEmpty())
-        pSerializer->singleElementNS(XML_w, XML_jc,
+        m_pSerializer->singleElementNS(XML_w, XML_jc,
                 FSNS(XML_w, XML_val), OUStringToOString(aJc, RTL_TEXTENCODING_UTF8).getStr(),
                 FSEND);
 
-    pSerializer->endElementNS(XML_w, XML_pPr);
+    m_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)
+void DocxTableStyleExport::Impl::tableStyleTblPr(uno::Sequence<beans::PropertyValue>& rTblPr)
 {
     if (!rTblPr.hasElements())
         return;
 
-    pSerializer->startElementNS(XML_w, XML_tblPr, FSEND);
+    m_pSerializer->startElementNS(XML_w, XML_tblPr, FSEND);
 
     uno::Sequence<beans::PropertyValue> aTblInd, aTblBorders, aTblCellMar;
     boost::optional<sal_Int32> oTblStyleRowBandSize, oTblStyleColBandSize;
@@ -429,27 +451,26 @@ void lcl_TableStyleTblPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<
             aTblCellMar = rTblPr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
     }
     if (oTblStyleRowBandSize)
-        pSerializer->singleElementNS(XML_w, XML_tblStyleRowBandSize,
+        m_pSerializer->singleElementNS(XML_w, XML_tblStyleRowBandSize,
                 FSNS(XML_w, XML_val), OString::number(oTblStyleRowBandSize.get()),
                 FSEND);
     if (oTblStyleColBandSize)
-        pSerializer->singleElementNS(XML_w, XML_tblStyleColBandSize,
+        m_pSerializer->singleElementNS(XML_w, XML_tblStyleColBandSize,
                 FSNS(XML_w, XML_val), OString::number(oTblStyleColBandSize.get()),
                 FSEND);
-    lcl_TableStyleTblInd(pSerializer, aTblInd);
-    lcl_TableStyleTcBorders(pSerializer, aTblBorders, XML_tblBorders);
-    lcl_TableStyleTblCellMar(pSerializer, aTblCellMar);
+    tableStyleTblInd(aTblInd);
+    tableStyleTcBorders(aTblBorders, XML_tblBorders);
+    tableStyleTblCellMar(aTblCellMar);
 
-    pSerializer->endElementNS(XML_w, XML_tblPr);
+    m_pSerializer->endElementNS(XML_w, XML_tblPr);
 }
 
-/// Export of w:tcPr in a table style.
-void lcl_TableStyleTcPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTcPr)
+void DocxTableStyleExport::Impl::tableStyleTcPr(uno::Sequence<beans::PropertyValue>& rTcPr)
 {
     if (!rTcPr.hasElements())
         return;
 
-    pSerializer->startElementNS(XML_w, XML_tcPr, FSEND);
+    m_pSerializer->startElementNS(XML_w, XML_tcPr, FSEND);
 
     uno::Sequence<beans::PropertyValue> aShd, aTcBorders, aTcMar;
     OUString aVAlign;
@@ -464,19 +485,18 @@ void lcl_TableStyleTcPr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<b
         else if (rTcPr[i].Name == "vAlign")
             aVAlign = rTcPr[i].Value.get<OUString>();
     }
-    lcl_TableStyleTcBorders(pSerializer, aTcBorders);
-    lcl_TableStyleTblCellMar(pSerializer, aTcMar, XML_tcMar);
-    lcl_TableStyleShd(pSerializer, aShd);
+    tableStyleTcBorders(aTcBorders);
+    tableStyleTblCellMar(aTcMar, XML_tcMar);
+    tableStyleShd(aShd);
     if (!aVAlign.isEmpty())
-        pSerializer->singleElementNS(XML_w, XML_vAlign,
+        m_pSerializer->singleElementNS(XML_w, XML_vAlign,
                 FSNS(XML_w, XML_val), OUStringToOString(aVAlign, RTL_TEXTENCODING_UTF8).getStr(),
                 FSEND);
 
-    pSerializer->endElementNS(XML_w, XML_tcPr);
+    m_pSerializer->endElementNS(XML_w, XML_tcPr);
 }
 
-/// Export of w:tblStylePr in a table style.
-void lcl_TableStyleTblStylePr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<beans::PropertyValue>& rTblStylePr)
+void DocxTableStyleExport::Impl::tableStyleTblStylePr(uno::Sequence<beans::PropertyValue>& rTblStylePr)
 {
     if (!rTblStylePr.hasElements())
         return;
@@ -497,22 +517,22 @@ void lcl_TableStyleTblStylePr(sax_fastparser::FSHelperPtr pSerializer, uno::Sequ
             aTcPr = rTblStylePr[i].Value.get< uno::Sequence<beans::PropertyValue> >();
     }
 
-    pSerializer->startElementNS(XML_w, XML_tblStylePr,
+    m_pSerializer->startElementNS(XML_w, XML_tblStylePr,
             FSNS(XML_w, XML_type), OUStringToOString(aType, RTL_TEXTENCODING_UTF8).getStr(),
             FSEND);
 
-    lcl_TableStylePPr(pSerializer, aPPr);
-    lcl_TableStyleRPr(pSerializer, aRPr);
+    tableStylePPr(aPPr);
+    tableStyleRPr(aRPr);
     if (aTblPr.hasElements())
-        lcl_TableStyleTblPr(pSerializer, aTblPr);
+        tableStyleTblPr(aTblPr);
     else
     {
         // Even if we have an empty container, write it out, as Word does.
-        pSerializer->singleElementNS(XML_w, XML_tblPr, FSEND);
+        m_pSerializer->singleElementNS(XML_w, XML_tblPr, FSEND);
     }
-    lcl_TableStyleTcPr(pSerializer, aTcPr);
+    tableStyleTcPr(aTcPr);
 
-    pSerializer->endElementNS(XML_w, XML_tblStylePr);
+    m_pSerializer->endElementNS(XML_w, XML_tblStylePr);
 }
 
 void DocxTableStyleExport::Impl::TableStyle(uno::Sequence<beans::PropertyValue>& rStyle)
@@ -596,12 +616,12 @@ void DocxTableStyleExport::Impl::TableStyle(uno::Sequence<beans::PropertyValue>&
                 FSEND);
     }
 
-    lcl_TableStylePPr(m_pSerializer, aPPr);
-    lcl_TableStyleRPr(m_pSerializer, aRPr);
-    lcl_TableStyleTblPr(m_pSerializer, aTblPr);
-    lcl_TableStyleTcPr(m_pSerializer, aTcPr);
+    tableStylePPr(aPPr);
+    tableStyleRPr(aRPr);
+    tableStyleTblPr(aTblPr);
+    tableStyleTcPr(aTcPr);
     for (size_t i = 0; i < aTblStylePrs.size(); ++i)
-        lcl_TableStyleTblStylePr(m_pSerializer, aTblStylePrs[i]);
+        tableStyleTblStylePr(aTblStylePrs[i]);
 
     m_pSerializer->endElementNS(XML_w, XML_style);
 }
commit 2c26e47cdcc9ece7927e130c7537369820be6f6a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 5 12:58:53 2013 +0100

    Avoid msfilter::util::ConvertColor in DocxTableStyleExport
    
    It's more consistent to do all the any to string conversion on the
    import side. Also, when we have the ConvertColor calls in a single
    place, audit grab-bag-related calls: those should always enable auto
    color conversion.
    
    Change-Id: I39ef74986617ee0ed629607e2a069047879b0422

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 5cfc8d6..f8b7904 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1364,6 +1364,9 @@ DECLARE_OOXML_TEST(testQuicktables, "quicktables.docx")
 
     // MediumList2-Accent1.
     CPPUNIT_ASSERT(getXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='MediumList2-Accent1']/w:tblStylePr[@w:type='band1Vert']/w:tcPr/w:shd", "themeFillTint").equalsIgnoreAsciiCase("3F"));
+
+    // MediumShading2-Accent5.
+    assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='MediumShading2-Accent5']/w:tblStylePr[@w:type='firstRow']/w:tcPr/w:tcBorders/w:top", "color", "auto");
 }
 
 DECLARE_OOXML_TEST(testSmartart, "smartart.docx")
diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx
index fbfad0f..752a155 100644
--- a/sw/source/filter/ww8/docxtablestyleexport.cxx
+++ b/sw/source/filter/ww8/docxtablestyleexport.cxx
@@ -15,7 +15,6 @@
 #include <oox/token/tokens.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <comphelper/string.hxx>
-#include <filter/msfilter/util.hxx>
 #include <rtl/strbuf.hxx>
 
 #include <com/sun/star/beans/PropertyValue.hpp>
@@ -155,9 +154,9 @@ void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be
         if (rShd[i].Name == "val")
             pAttributeList->add(FSNS(XML_w, XML_val), OUStringToOString(rShd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
         else if (rShd[i].Name == "color")
-            pAttributeList->add(FSNS(XML_w, XML_color), msfilter::util::ConvertColor(rShd[i].Value.get<sal_Int32>(), /*bAutoColor =*/ true));
+            pAttributeList->add(FSNS(XML_w, XML_color), OUStringToOString(rShd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
         else if (rShd[i].Name == "fill")
-            pAttributeList->add(FSNS(XML_w, XML_fill), msfilter::util::ConvertColor(rShd[i].Value.get<sal_Int32>(), /*bAutoColor =*/ true));
+            pAttributeList->add(FSNS(XML_w, XML_fill), OUStringToOString(rShd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
         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")
diff --git a/writerfilter/source/dmapper/BorderHandler.cxx b/writerfilter/source/dmapper/BorderHandler.cxx
index c010c13..ec35fce 100644
--- a/writerfilter/source/dmapper/BorderHandler.cxx
+++ b/writerfilter/source/dmapper/BorderHandler.cxx
@@ -83,7 +83,7 @@ void BorderHandler::lcl_attribute(Id rName, Value & rVal)
         case NS_ooxml::LN_CT_Border_color:
         case NS_rtf::LN_ICO:        // 0x2873
             m_nLineColor = nIntValue;
-            appendGrabBag("color", OStringToOUString(msfilter::util::ConvertColor(nIntValue), RTL_TEXTENCODING_UTF8));
+            appendGrabBag("color", OStringToOUString(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true), RTL_TEXTENCODING_UTF8));
         break;
         case NS_rtf::LN_DPTSPACE:   // border distance in points
             m_nLineDistance = ConversionHelper::convertTwipToMM100( nIntValue * 20 );
diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx
index eba99b9..da8c9cb 100644
--- a/writerfilter/source/dmapper/CellColorHandler.cxx
+++ b/writerfilter/source/dmapper/CellColorHandler.cxx
@@ -117,13 +117,13 @@ void CellColorHandler::lcl_attribute(Id rName, Value & rVal)
         }
         break;
         case NS_ooxml::LN_CT_Shd_fill:
-            createGrabBag("fill", uno::makeAny(nIntValue));
+            createGrabBag("fill", uno::makeAny(OStringToOUString(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true), RTL_TEXTENCODING_UTF8)));
             if( nIntValue == OOXML_COLOR_AUTO )
                 nIntValue = 0xffffff; //fill color auto means white
             m_nFillColor = nIntValue;
         break;
         case NS_ooxml::LN_CT_Shd_color:
-            createGrabBag("color", uno::makeAny(nIntValue));
+            createGrabBag("color", uno::makeAny(OStringToOUString(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true), RTL_TEXTENCODING_UTF8)));
             if( nIntValue == OOXML_COLOR_AUTO )
                 nIntValue = 0; //shading color auto means black
             //color of the shading
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 1a6eeab..d2474bb 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -916,7 +916,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
         case NS_ooxml::LN_CT_Color_val:
             if (m_pImpl->GetTopContext())
                 m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR, uno::makeAny( nIntValue ) );
-            m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", OStringToOUString(msfilter::util::ConvertColor(nIntValue), RTL_TEXTENCODING_UTF8));
+            m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", OStringToOUString(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true), RTL_TEXTENCODING_UTF8));
             break;
         case NS_ooxml::LN_CT_Underline_color:
             if (m_pImpl->GetTopContext())
diff --git a/writerfilter/source/dmapper/TDefTableHandler.cxx b/writerfilter/source/dmapper/TDefTableHandler.cxx
index 737ddef..fa71805 100644
--- a/writerfilter/source/dmapper/TDefTableHandler.cxx
+++ b/writerfilter/source/dmapper/TDefTableHandler.cxx
@@ -336,7 +336,7 @@ 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));
+            appendGrabBag("color", OStringToOUString(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true), RTL_TEXTENCODING_UTF8));
             m_nLineColor = nIntValue;
         break;
         case NS_rtf::LN_DPTSPACE:   // 0x2874
commit 1b76aebcb29aef751127472ba8df4377a9f49b49
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 5 12:08:38 2013 +0100

    DOCX filter: handle shd's "themeFillTint" attribute inside tblStylePr
    
    Change-Id: Ib2bc21e0fb5d874ed82ac826eeab209dcb9303eb

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index bbe1dc0..5cfc8d6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1361,6 +1361,9 @@ DECLARE_OOXML_TEST(testQuicktables, "quicktables.docx")
 
     // LightList.
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='LightList']/w:tblStylePr[@w:type='firstRow']/w:pPr/w:spacing", "before", "0");
+
+    // MediumList2-Accent1.
+    CPPUNIT_ASSERT(getXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='MediumList2-Accent1']/w:tblStylePr[@w:type='band1Vert']/w:tcPr/w:shd", "themeFillTint").equalsIgnoreAsciiCase("3F"));
 }
 
 DECLARE_OOXML_TEST(testSmartart, "smartart.docx")
diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx
index 8b94b0d..fbfad0f 100644
--- a/sw/source/filter/ww8/docxtablestyleexport.cxx
+++ b/sw/source/filter/ww8/docxtablestyleexport.cxx
@@ -162,6 +162,8 @@ void lcl_TableStyleShd(sax_fastparser::FSHelperPtr pSerializer, uno::Sequence<be
             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());
+        else if (rShd[i].Name == "themeFillTint")
+            pAttributeList->add(FSNS(XML_w, XML_themeFillTint), OUStringToOString(rShd[i].Value.get<OUString>(), RTL_TEXTENCODING_UTF8).getStr());
     }
     sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
     pSerializer->singleElementNS(XML_w, XML_shd, xAttributeList);
diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx
index 8aac72d..eba99b9 100644
--- a/writerfilter/source/dmapper/CellColorHandler.cxx
+++ b/writerfilter/source/dmapper/CellColorHandler.cxx
@@ -136,7 +136,7 @@ void CellColorHandler::lcl_attribute(Id rName, Value & rVal)
             createGrabBag("themeFillShade", uno::makeAny(OUString::number(nIntValue, 16)));
         break;
         case NS_ooxml::LN_CT_Shd_themeFillTint:
-            // ignored
+            createGrabBag("themeFillTint", uno::makeAny(OUString::number(nIntValue, 16)));
             break;
         default:
             OSL_FAIL( "unknown attribute");
commit e21068ff06803d07c8b0b785952eba4381add256
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 5 11:16:16 2013 +0100

    DOCX filter: handle spacing's "before" attribute inside tblStylePr
    
    Change-Id: I0617b6d3b9e6d81300f97b0b992081cd10ec2fdd

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index dcb106c..bbe1dc0 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1358,6 +1358,9 @@ DECLARE_OOXML_TEST(testQuicktables, "quicktables.docx")
     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");
     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='band2Horz']/w:tcPr/w:tcMar/w:bottom", "w", "86");
+
+    // LightList.
+    assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='LightList']/w:tblStylePr[@w:type='firstRow']/w:pPr/w:spacing", "before", "0");
 }
 
 DECLARE_OOXML_TEST(testSmartart, "smartart.docx")
diff --git a/sw/source/filter/ww8/docxtablestyleexport.cxx b/sw/source/filter/ww8/docxtablestyleexport.cxx
index 4cc4174..8b94b0d 100644
--- a/sw/source/filter/ww8/docxtablestyleexport.cxx
+++ b/sw/source/filter/ww8/docxtablestyleexport.cxx
@@ -242,6 +242,8 @@ void lcl_TableStylePSpacing(sax_fastparser::FSHelperPtr pSerializer, uno::Sequen
     {
         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 == "before")
+            pAttributeList->add(FSNS(XML_w, XML_before), 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")
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 4f9d233..1a6eeab 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -977,6 +977,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
                 m_pImpl->GetTopContext()->Insert(PROP_CHAR_FONT_NAME_COMPLEX, uno::makeAny( m_pImpl->GetThemeTable()->getFontNameForTheme(nIntValue) ));
         break;
         case NS_ooxml::LN_CT_Spacing_before:
+            m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "before", OUString::number(nIntValue));
             if (m_pImpl->GetTopContext())
                 // Don't overwrite NS_ooxml::LN_CT_Spacing_beforeAutospacing.
                 m_pImpl->GetTopContext()->Insert(PROP_PARA_TOP_MARGIN, uno::makeAny( ConversionHelper::convertTwipToMM100( nIntValue ) ), false);


More information about the Libreoffice-commits mailing list