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

Tamás Zolnai tamas.zolnai at collabora.com
Wed Aug 23 20:18:27 UTC 2017


 oox/source/export/vmlexport.cxx                              |    5 +
 sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx                    |   34 +++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx                 |   20 +++++-
 sw/source/filter/ww8/docxattributeoutput.hxx                 |    4 -
 5 files changed, 57 insertions(+), 6 deletions(-)

New commits:
commit b129421764ae78a1422812169fce8eb4914a6b22
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Wed Aug 23 20:09:35 2017 +0200

    DOCX: Fix an other test case of ActiveX control export
    
    When LO control is anchored to the end of the run, it
    is exported into a new run.
    
    Change-Id: I9269fd1b34924780aad61c452d1e2094dc8e4aad
    Reviewed-on: https://gerrit.libreoffice.org/41472
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index f45edde6cc86..c4c3f3679861 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1311,6 +1311,7 @@ OString VMLExport::AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri, sal_Int
     m_eVOri = eVOri;
     m_eHRel = eHRel;
     m_eVRel = eVRel;
+    m_bInline = false;
     EscherEx::AddSdrObject(rObj, bOOxmlExport);
     return m_sShapeId;
 }
@@ -1318,6 +1319,10 @@ OString VMLExport::AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri, sal_Int
 OString VMLExport::AddInlineSdrObject( const SdrObject& rObj, const bool bOOxmlExport )
 {
     m_pSdrObject = &rObj;
+    m_eHOri = -1;
+    m_eVOri = -1;
+    m_eHRel = -1;
+    m_eVRel = -1;
     m_bInline = true;
     EscherEx::AddSdrObject(rObj, bOOxmlExport);
     return m_sShapeId;
diff --git a/sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt b/sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt
new file mode 100755
index 000000000000..9008cb90a530
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 0fac9847dd6e..4e961079b829 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -959,6 +959,40 @@ DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark-shapetype.docx")
     CPPUNIT_ASSERT_EQUAL(xPropertySet1->getPropertyValue("TextAutoGrowHeight"), xPropertySet2->getPropertyValue("TextAutoGrowHeight"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testActiveXControlAtRunEnd, "activex_control_at_run_end.odt")
+{
+    // Two issues were here:
+    //  1) second shape was not export (it is anchored to the end of the run)
+    //  2) inline property was inherited to the second shape by mistake
+
+    // First checkbox is the inlined one
+    uno::Reference<drawing::XControlShape> xControlShape(getShape(1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xControlShape.is());
+
+    // Check whether we have the right control
+    uno::Reference<beans::XPropertySet> xPropertySet(xControlShape->getControl(), uno::UNO_QUERY);
+    uno::Reference<lang::XServiceInfo> xServiceInfo(xPropertySet, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService( "com.sun.star.form.component.CheckBox")));
+    CPPUNIT_ASSERT_EQUAL(OUString("Inline Checkbox"), getProperty<OUString>(xPropertySet, "Label"));
+
+    // Check anchor type
+    uno::Reference<beans::XPropertySet> xPropertySet2(xControlShape, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
+
+    // Second check box anchored to character
+    xControlShape.set(getShape(2), uno::UNO_QUERY);
+
+    // Check whether we have the right control
+    xPropertySet.set(xControlShape->getControl(), uno::UNO_QUERY);
+    xServiceInfo.set(xPropertySet, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(true, bool(xServiceInfo->supportsService("com.sun.star.form.component.CheckBox")));
+    CPPUNIT_ASSERT_EQUAL(OUString("Floating Checkbox"), getProperty<OUString>(xPropertySet, "Label"));
+
+    // Check anchor type
+    xPropertySet2.set(xControlShape, uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty<text::TextContentAnchorType>(xPropertySet2,"AnchorType"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 5d9bf2b040be..1332baf8f628 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1320,6 +1320,8 @@ void DocxAttributeOutput::EndRun()
         WritePostponedFormControl(*it);
     m_aPostponedFormControls.clear();
 
+    WritePostponedActiveXControl(false);
+
     WritePendingPlaceholder();
 
     m_pRedlineData = nullptr;
@@ -2045,7 +2047,7 @@ void DocxAttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
 
     WritePostponedOLE();
 
-    WritePostponedActiveXControl();
+    WritePostponedActiveXControl(true);
 
     // merge the properties _before_ the run text (strictly speaking, just
     // after the start of the run)
@@ -4785,18 +4787,18 @@ void DocxAttributeOutput::WritePostponedFormControl(const SdrObject* pObject)
     }
 }
 
-void DocxAttributeOutput::WritePostponedActiveXControl()
+void DocxAttributeOutput::WritePostponedActiveXControl(bool bInsideRun)
 {
     for( std::vector<PostponedDrawing>::const_iterator it = m_aPostponedActiveXControls.begin();
          it != m_aPostponedActiveXControls.end(); ++it )
     {
-        WriteActiveXControl(it->object, *(it->frame));
+        WriteActiveXControl(it->object, *(it->frame), bInsideRun);
     }
     m_aPostponedActiveXControls.clear();
 }
 
 
-void DocxAttributeOutput::WriteActiveXControl(const SdrObject* pObject, const SwFrameFormat& rFrameFormat)
+void DocxAttributeOutput::WriteActiveXControl(const SdrObject* pObject, const SwFrameFormat& rFrameFormat, bool bInsideRun)
 {
     SdrUnoObj *pFormObj = const_cast<SdrUnoObj*>(dynamic_cast< const SdrUnoObj*>(pObject));
     if (!pFormObj)
@@ -4808,6 +4810,11 @@ void DocxAttributeOutput::WriteActiveXControl(const SdrObject* pObject, const Sw
 
     const bool bAnchoredInline = rFrameFormat.GetAnchor().GetAnchorId() == static_cast<RndStdIds>(css::text::TextContentAnchorType_AS_CHARACTER);
 
+    if(!bInsideRun)
+    {
+        m_pSerializer->startElementNS(XML_w, XML_r, FSEND);
+    }
+
     // w:pict for floating embedded control and w:object for inline embedded control
     if(bAnchoredInline)
         m_pSerializer->startElementNS(XML_w, XML_object, FSEND);
@@ -4852,6 +4859,11 @@ void DocxAttributeOutput::WriteActiveXControl(const SdrObject* pObject, const Sw
         m_pSerializer->endElementNS(XML_w, XML_object);
     else
         m_pSerializer->endElementNS(XML_w, XML_pict);
+
+    if(!bInsideRun)
+    {
+        m_pSerializer->endElementNS(XML_w, XML_r);
+    }
 }
 
 bool DocxAttributeOutput::ExportAsActiveXControl(const SdrObject* pObject) const
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 0d716e7129fd..1a32aec81824 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -417,7 +417,7 @@ private:
     bool PostponeOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat );
     void WriteOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* rFlyFrameFormat );
 
-    void WriteActiveXControl(const SdrObject* pObject, const SwFrameFormat& rFrameFormat);
+    void WriteActiveXControl(const SdrObject* pObject, const SwFrameFormat& rFrameFormat, bool bInsideRun);
     bool ExportAsActiveXControl(const SdrObject* pObject) const;
 
     /// checks whether the current component is a diagram
@@ -700,7 +700,7 @@ private:
     void WritePostponedGraphic();
     void WritePostponedMath(const SwOLENode* pObject);
     void WritePostponedFormControl(const SdrObject* pObject);
-    void WritePostponedActiveXControl();
+    void WritePostponedActiveXControl(bool bInsideRun);
     void WritePostponedDiagram();
     void WritePostponedChart();
     void WritePostponedOLE();


More information about the Libreoffice-commits mailing list