[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa sw/source

Mike Kaganski mike.kaganski at collabora.com
Fri Nov 24 18:06:20 UTC 2017


 sw/qa/extras/ooxmlexport/data/mailmerge.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx    |   27 +++++++++++++++++++++++++++
 sw/qa/extras/ww8export/data/mailmerge.doc    |binary
 sw/qa/extras/ww8export/ww8export2.cxx        |   27 +++++++++++++++++++++++++++
 sw/source/filter/ww8/rtfattributeoutput.cxx  |    7 ++-----
 sw/source/filter/ww8/ww8atr.cxx              |    6 ++++++
 6 files changed, 62 insertions(+), 5 deletions(-)

New commits:
commit b8b75225a4b0af7bb841cd5205adc2ad2d13b705
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Fri Nov 24 00:18:09 2017 +0300

    tdf#67207: export MERGEDIELD to DOCX and DOC
    
    Also removed a hack for i119803, because proper solution is
    implemented.
    
    This does not export data source information yet.
    
    Unit tests for DOC and DOCX are included. RTF export is already
    covered in testFdo80905.
    
    Change-Id: Id4f6d53344edf474add7e885e8ae6f36618e569f
    Reviewed-on: https://gerrit.libreoffice.org/45193
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/45243
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/mailmerge.docx b/sw/qa/extras/ooxmlexport/data/mailmerge.docx
new file mode 100644
index 000000000000..7e209a1b4dc9
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/mailmerge.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index a7b36683f943..08de896708f8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -11,6 +11,7 @@
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
+#include <com/sun/star/text/XDependentTextField.hpp>
 #include <com/sun/star/text/XPageCursor.hpp>
 #include <com/sun/star/text/XTextColumns.hpp>
 #include <com/sun/star/text/XTextFrame.hpp>
@@ -574,6 +575,32 @@ DECLARE_OOXMLEXPORT_TEST(testTdf111964, "tdf111964.docx")
     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[4]/w:t", sWSReference);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.docx")
+{
+    uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField");
+    CPPUNIT_ASSERT(xTextField.is());
+    uno::Reference<lang::XServiceInfo> xServiceInfo(xTextField, uno::UNO_QUERY_THROW);
+    uno::Reference<text::XDependentTextField> xDependent(xTextField, uno::UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.Database"));
+    OUString sValue;
+    xTextField->getPropertyValue("Content") >>= sValue;
+    CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"«Name»"), sValue);
+
+    uno::Reference<beans::XPropertySet> xFiledMaster = xDependent->getTextFieldMaster();
+    uno::Reference<lang::XServiceInfo> xFiledMasterServiceInfo(xFiledMaster, uno::UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT(xFiledMasterServiceInfo->supportsService("com.sun.star.text.fieldmaster.Database"));
+
+    // Defined properties: DataBaseName, Name, DataTableName, DataColumnName, DependentTextFields, DataCommandType, InstanceName, DataBaseURL
+    CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("Name") >>= sValue);
+    CPPUNIT_ASSERT_EQUAL(OUString("Name"), sValue);
+    CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("DataColumnName") >>= sValue);
+    CPPUNIT_ASSERT_EQUAL(OUString("Name"), sValue);
+    CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("InstanceName") >>= sValue);
+    CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.text.fieldmaster.DataBase.Name"), sValue);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ww8export/data/mailmerge.doc b/sw/qa/extras/ww8export/data/mailmerge.doc
new file mode 100644
index 000000000000..6ed882769ebb
Binary files /dev/null and b/sw/qa/extras/ww8export/data/mailmerge.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx b/sw/qa/extras/ww8export/ww8export2.cxx
index 2819fa3569dd..f4761cc6b381 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -12,6 +12,7 @@
 #include <com/sun/star/graphic/XGraphic.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/text/XDependentTextField.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
@@ -161,6 +162,32 @@ DECLARE_WW8EXPORT_TEST( testActiveXCheckbox, "checkbox_control.odt" )
     CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.doc")
+{
+    uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField");
+    CPPUNIT_ASSERT(xTextField.is());
+    uno::Reference<lang::XServiceInfo> xServiceInfo(xTextField, uno::UNO_QUERY_THROW);
+    uno::Reference<text::XDependentTextField> xDependent(xTextField, uno::UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.Database"));
+    OUString sValue;
+    xTextField->getPropertyValue("Content") >>= sValue;
+    CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"«Name»"), sValue);
+
+    uno::Reference<beans::XPropertySet> xFiledMaster = xDependent->getTextFieldMaster();
+    uno::Reference<lang::XServiceInfo> xFiledMasterServiceInfo(xFiledMaster, uno::UNO_QUERY_THROW);
+
+    CPPUNIT_ASSERT(xFiledMasterServiceInfo->supportsService("com.sun.star.text.fieldmaster.Database"));
+
+    // Defined properties: DataBaseName, Name, DataTableName, DataColumnName, DependentTextFields, DataCommandType, InstanceName, DataBaseURL
+    CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("Name") >>= sValue);
+    CPPUNIT_ASSERT_EQUAL(OUString("Name"), sValue);
+    CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("DataColumnName") >>= sValue);
+    CPPUNIT_ASSERT_EQUAL(OUString("Name"), sValue);
+    CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("InstanceName") >>= sValue);
+    CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.text.fieldmaster.DataBase.Name"), sValue);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 4305865397d3..63cad8d8076d 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -3405,12 +3405,9 @@ void RtfAttributeOutput::WriteExpand(const SwField* pField)
     OUString sCmd;        // for optional Parameters
     switch (pField->GetTyp()->Which())
     {
-    //#i119803# Export user field and DB field for RTF filter
-    case RES_DBFLD:
-        sCmd = FieldString(ww::eMERGEFIELD);
-        SAL_FALLTHROUGH;
+    //#i119803# Export user field for RTF filter
     case RES_USERFLD:
-        sCmd += pField->GetTyp()->GetName();
+        sCmd = pField->GetTyp()->GetName();
         m_rExport.OutputField(pField, ww::eNONE, sCmd);
         break;
     default:
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 3f01f95fc36d..f8d35a0edae1 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2532,6 +2532,12 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
             GetExport().OutputField(pField, ww::eFILENAME, sStr);
         }
         break;
+    case RES_DBFLD:
+        {
+            OUString sStr = FieldString(ww::eMERGEFIELD) + pField->GetPar1() + " ";
+            GetExport().OutputField(pField, ww::eMERGEFIELD, sStr);
+        }
+        break;
     case RES_DBNAMEFLD:
         {
             SwDBData aData = GetExport().m_pDoc->GetDBData();


More information about the Libreoffice-commits mailing list