diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-08-23 20:09:35 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-08-23 22:16:02 +0200 |
commit | b129421764ae78a1422812169fce8eb4914a6b22 (patch) | |
tree | 4365061e70fb02dd05d045071f83440aca97600e /sw | |
parent | c66568d6b0bbcce26cbdc5a4e5f6e4c0ae748e45 (diff) |
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@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw')
-rwxr-xr-x | sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt | bin | 0 -> 9601 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 34 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 20 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.hxx | 4 |
4 files changed, 52 insertions, 6 deletions
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 Binary files differnew file mode 100755 index 000000000000..9008cb90a530 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/activex_control_at_run_end.odt 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(); |