Kaydet (Commit) b1294217 authored tarafından Tamás Zolnai's avatar Tamás Zolnai

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/41472Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst c66568d6
......@@ -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;
......
......@@ -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: */
......@@ -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
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment