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

Miklos Vajna vmiklos at collabora.co.uk
Tue Aug 5 01:54:55 PDT 2014


 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   10 +++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   47 +++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

New commits:
commit 1b9353bae0e25d460555828ab33c8afe45b75a6d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Aug 5 10:21:23 2014 +0200

    DOCX export: handle all attributes of CT_TblLook
    
    Change-Id: Ibe72d60be302158001fbf6e197f30945fe8fbed9

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 62195cc..d595af3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -1309,6 +1309,16 @@ DECLARE_OOXMLEXPORT_TEST(testCalendar1, "calendar1.docx")
     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");
+
+    // w:tblLook element and its attributes were missing.
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "firstRow", "1");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "lastRow", "0");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "lastColumn", "0");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "firstColumn", "1");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "noHBand", "0");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "noVBand", "1");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "val", "04a0");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testCalendar2, "calendar2.docx")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index c66a6ea..bf00588 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2950,6 +2950,21 @@ void DocxAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*
 {
 }
 
+/// Does the same as comphelper::string::padToLength(), but extends the start, not the end.
+OString lcl_padStartToLength(OString aString, sal_Int32 nLen, sal_Char cFill)
+{
+    if (nLen > aString.getLength())
+    {
+        sal_Int32 nDiff = nLen - aString.getLength();
+        OStringBuffer aBuffer;
+        comphelper::string::padToLength(aBuffer, nDiff, cFill);
+        aBuffer.append(aString);
+        return aBuffer.makeStringAndClear();
+    }
+    else
+        return aString;
+}
+
 void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
 {
     bool bEcma = GetExport().GetFilter().getVersion( ) == oox::core::ECMA_DIALECT;
@@ -3057,6 +3072,36 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
             m_aTableStyleConf[ BOX_LINE_LEFT ] = aGrabBagElement->second.get<table::BorderLine2>();
         else if( aGrabBagElement->first == "TableStyleRightBorder" )
             m_aTableStyleConf[ BOX_LINE_RIGHT ] = aGrabBagElement->second.get<table::BorderLine2>();
+        else if (aGrabBagElement->first == "TableStyleLook")
+        {
+            FastAttributeList* pAttributeList = m_pSerializer->createAttrList();
+            uno::Sequence<beans::PropertyValue> aAttributeList = aGrabBagElement->second.get< uno::Sequence<beans::PropertyValue> >();
+
+            for (sal_Int32 i = 0; i < aAttributeList.getLength(); ++i)
+            {
+                if (aAttributeList[i].Name == "val")
+                    pAttributeList->add(FSNS(XML_w, XML_val), lcl_padStartToLength(OString::number(aAttributeList[i].Value.get<sal_Int32>(), 16), 4, '0'));
+                else
+                {
+                    static DocxStringTokenMap const aTokens[] =
+                    {
+                        {"firstRow", XML_firstRow},
+                        {"lastRow", XML_lastRow},
+                        {"firstColumn", XML_firstColumn},
+                        {"lastColumn", XML_lastColumn},
+                        {"noHBand", XML_noHBand},
+                        {"noVBand", XML_noVBand},
+                        {0, 0}
+                    };
+
+                    if (sal_Int32 nToken = DocxStringGetToken(aTokens, aAttributeList[i].Name))
+                        pAttributeList->add(FSNS(XML_w, nToken), (aAttributeList[i].Value.get<sal_Int32>() ? "1" : "0"));
+                }
+            }
+
+            XFastAttributeListRef xAttributeList(pAttributeList);
+            m_pSerializer->singleElementNS(XML_w, XML_tblLook, xAttributeList);
+        }
         else if (aGrabBagElement->first == "TablePosition" )
         {
             FastAttributeList *attrListTablePos = m_pSerializer->createAttrList( );
@@ -3114,6 +3159,8 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
             m_pSerializer->singleElementNS( XML_w, XML_tblpPr, xAttrListTablePosRef);
             attrListTablePos = NULL;
         }
+        else
+            SAL_WARN("sw.ww8", "DocxAttributeOutput::TableDefinition: unhandled property: " << aGrabBagElement->first);
     }
 
     // Output the table alignement


More information about the Libreoffice-commits mailing list