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

Miklos Vajna vmiklos at collabora.co.uk
Fri Feb 21 09:14:56 PST 2014


 sw/CppunitTest_sw_ooxmlexport.mk                |    1 
 sw/qa/extras/ooxmlexport/data/form-control.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx        |    8 +++++
 sw/source/filter/ww8/docxattributeoutput.cxx    |   36 ++++++++++++++++++++++--
 sw/source/filter/ww8/docxattributeoutput.hxx    |    2 +
 5 files changed, 45 insertions(+), 2 deletions(-)

New commits:
commit 1ec263e25d8606c70ac2089d5ceea22750d25daf
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Feb 21 17:19:23 2014 +0100

    DOCX export: initial support for the DateField form control
    
    Before we started to import the date SDT as a form control, we exported
    what is now the HelpText property on the control. So as an initial step,
    export that back as plain text, without any formatting.
    
    Change-Id: I569e6690b0c580d8073611b48d610f87974145b3

diff --git a/sw/CppunitTest_sw_ooxmlexport.mk b/sw/CppunitTest_sw_ooxmlexport.mk
index 6d09ca2..30643b2 100644
--- a/sw/CppunitTest_sw_ooxmlexport.mk
+++ b/sw/CppunitTest_sw_ooxmlexport.mk
@@ -58,6 +58,7 @@ $(eval $(call gb_CppunitTest_use_components,sw_ooxmlexport,\
 	drawinglayer/drawinglayer \
     embeddedobj/util/embobj \
     filter/source/config/cache/filterconfig1 \
+	forms/util/frm \
     framework/util/fwk \
     i18npool/util/i18npool \
     linguistic/source/lng \
diff --git a/sw/qa/extras/ooxmlexport/data/form-control.docx b/sw/qa/extras/ooxmlexport/data/form-control.docx
new file mode 100755
index 0000000..4f6305a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/form-control.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 025b27e..ceea5c2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2280,6 +2280,14 @@ DECLARE_OOXMLEXPORT_TEST(testDmlShapeTitle, "dml-shape-title.docx")
     CPPUNIT_ASSERT_EQUAL(OUString("Description"), getProperty<OUString>(getShape(1), "Description"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testFormControl, "form-control.docx")
+{
+    if (!m_bExported)
+        return;
+    // "[Date]" was missing.
+    getParagraph(1, "Foo [Date] bar.");
+}
+
 DECLARE_OOXMLEXPORT_TEST(testBehinddoc, "behinddoc.docx")
 {
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index ab71fd9..8087ca7 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -80,6 +80,8 @@
 #include <editeng/editobj.hxx>
 #include <svx/xfillit0.hxx>
 #include <svx/xflgrit.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/svdouno.hxx>
 #include <svl/grabbagitem.hxx>
 #include <sfx2/sfxbasemodel.hxx>
 #include <tools/datetimeutils.hxx>
@@ -696,6 +698,11 @@ void DocxAttributeOutput::EndRun()
     m_pSerializer->endElementNS( XML_w, XML_r );
 
     WritePostponedMath();
+
+    for (std::vector<const SdrObject*>::iterator it = m_aPostponedFormControls.begin(); it != m_aPostponedFormControls.end(); ++it)
+        WritePostponedFormControl(*it);
+    m_aPostponedFormControls.clear();
+
     WritePendingPlaceholder();
 
     // if there is some redlining in the document, output it
@@ -3311,6 +3318,26 @@ void DocxAttributeOutput::WritePostponedMath()
     m_postponedMath = NULL;
 }
 
+void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject)
+{
+    if (pObject && pObject->GetObjInventor() == FmFormInventor)
+    {
+        if (SdrUnoObj *pFormObj = PTR_CAST(SdrUnoObj,pObject))
+        {
+            uno::Reference<awt::XControlModel> xControlModel = pFormObj->GetUnoControlModel();
+            uno::Reference<lang::XServiceInfo> xInfo(xControlModel, uno::UNO_QUERY);
+            if (xInfo->supportsService("com.sun.star.form.component.DateField"))
+            {
+                uno::Reference<beans::XPropertySet> xPropertySet(xControlModel, uno::UNO_QUERY);
+                OUString aHelpText = xPropertySet->getPropertyValue("HelpText").get<OUString>();
+                m_pSerializer->startElementNS(XML_w, XML_r, FSEND);
+                RunText(aHelpText);
+                m_pSerializer->endElementNS(XML_w, XML_r);
+            }
+        }
+    }
+}
+
 /*
  * Write w:pict hierarchy  end element of w:rPr tag.
  */
@@ -3417,11 +3444,16 @@ void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Po
                 }
             }
             break;
+        case sw::Frame::eFormControl:
+            {
+                const SdrObject* pObject = rFrame.GetFrmFmt().FindRealSdrObject();
+                m_aPostponedFormControls.push_back(pObject);
+            }
+            break;
         default:
             OSL_TRACE( "TODO DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& rNdTopLeft ) - frame type '%s'\n",
                     rFrame.GetWriterType() == sw::Frame::eTxtBox? "eTxtBox":
-                    ( rFrame.GetWriterType() == sw::Frame::eOle? "eOle":
-                      ( rFrame.GetWriterType() == sw::Frame::eFormControl? "eFormControl": "???" ) ) );
+                    ( rFrame.GetWriterType() == sw::Frame::eOle? "eOle": "???" ) );
             break;
     }
 
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 47ce782..660776c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -665,6 +665,7 @@ private:
     void DoWriteAnnotationMarks( );
     void WritePostponedGraphic();
     void WritePostponedMath();
+    void WritePostponedFormControl(const SdrObject* pObject);
     void WritePostponedDiagram();
     void WritePostponedChart();
     void WritePostponedVMLDrawing();
@@ -785,6 +786,7 @@ private:
     const SwOLENode* m_postponedMath;
     const SdrObject* m_postponedChart;
     Size m_postponedChartSize;
+    std::vector<const SdrObject*> m_aPostponedFormControls;
     const SwField* pendingPlaceholder;
     /// Maps postit fields to ID's, used in commentRangeStart/End, commentReference and comment.xml.
     std::vector< std::pair<const SwPostItField*, sal_Int32> > m_postitFields;


More information about the Libreoffice-commits mailing list