From 6d67b812403e1c22ee09b70dddf6b2ac13e73b58 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 24 Jul 2013 16:15:51 +0200 Subject: fdo#60990 VML export: handle paragraph/run properties of shape text (cherry picked from commits 1753c4f9f1713ca4a9a1ac3a145269c850eef6fb, 0ffed545adbb8a27a024d4d6a74dcaa8a87ba66a and 94b3ec0597ee21b933d02496402ff0f3a416e6a3) Change-Id: Iaeb7f9826308ea94a036cb4bfa87bf65f0cfe22f Reviewed-on: https://gerrit.libreoffice.org/5094 Reviewed-by: Fridrich Strba Tested-by: Fridrich Strba --- sw/qa/extras/ooxmlexport/data/fdo60990.odt | Bin 0 -> 10945 bytes sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 15 +++++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 16 ++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/fdo60990.odt diff --git a/sw/qa/extras/ooxmlexport/data/fdo60990.odt b/sw/qa/extras/ooxmlexport/data/fdo60990.odt new file mode 100644 index 000000000000..c855f327a90c Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo60990.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 4a58bf1b7b08..2ed291fbe183 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -72,6 +72,7 @@ public: void testI120928(); void testN822175(); void testFdo58577(); + void testFdo60990(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -121,6 +122,7 @@ void Test::run() {"i120928.docx", &Test::testI120928}, {"n822175.odt", &Test::testN822175}, {"fdo58577.odt", &Test::testFdo58577}, + {"fdo60990.odt", &Test::testFdo60990}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -694,6 +696,19 @@ void Test::testFdo58577() CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); } +void Test::testFdo60990() +{ + // The shape had no background, no paragraph adjust and no font color. + uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + uno::Reference xShape(xDraws->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00CFE7F5), getProperty(xShape, "BackColor")); + uno::Reference xText = uno::Reference(xShape, uno::UNO_QUERY)->getText(); + uno::Reference xParagraph = getParagraphOfText(1, xText); + CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast(getProperty(xParagraph, "ParaAdjust"))); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF00), getProperty(getRun(xParagraph, 1), "CharColor")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 153580cda321..08d79f02118b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2635,7 +2635,7 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj) sal_Int32 nPara = rEditObj.GetParagraphCount(); - m_pSerializer->startElementNS( XML_w, XML_textbox, FSEND ); + m_pSerializer->startElementNS( XML_v, XML_textbox, FSEND ); m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND ); for (sal_Int32 n = 0; n < nPara; ++n) { @@ -2647,12 +2647,24 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj) xub_StrLen nEnd = aStr.Len(); m_pSerializer->startElementNS( XML_w, XML_p, FSEND ); + + // Write paragraph properties. + m_pSerializer->startElementNS(XML_w, XML_pPr, FSEND); + aAttrIter.OutParaAttr(false); + m_pSerializer->endElementNS(XML_w, XML_pPr); + do { xub_StrLen nNextAttr = aAttrIter.WhereNext(); if( nNextAttr > nEnd ) nNextAttr = nEnd; m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + + // Write run properties. + m_pSerializer->startElementNS(XML_w, XML_rPr, FSEND); + aAttrIter.OutAttr(nAktPos); + m_pSerializer->endElementNS(XML_w, XML_rPr); + bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos ); if( !bTxtAtr ) { @@ -2669,7 +2681,7 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj) m_pSerializer->endElementNS( XML_w, XML_p ); } m_pSerializer->endElementNS( XML_w, XML_txbxContent ); - m_pSerializer->endElementNS( XML_w, XML_textbox ); + m_pSerializer->endElementNS( XML_v, XML_textbox ); } oox::drawingml::DrawingML& DocxAttributeOutput::GetDrawingML() -- cgit v1.2.3