sw/qa/extras/rtfimport/rtfimport.cxx | 15 ++++++++------- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 5 +++++ writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 ++ writerfilter/source/rtftok/rtfsdrimport.cxx | 25 ++++++++++++++++++++----- 4 files changed, 35 insertions(+), 12 deletions(-)
New commits: commit 92e74798a753b5eb595a5964cc8efe70e3a6e56b Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Apr 10 13:07:54 2013 +0200 RTF import of new-style frames: fix txflTextFlow shape property Change-Id: If6febeaea00b384ea36d470264c04dfb4c7afd24 diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index f856099..15f54f4 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -136,6 +136,7 @@ void RTFSdrImport::resolve(RTFShape& rShape) uno::Any aLineColor = uno::makeAny(COL_BLACK); // Default line width is 0.75 pt (26 mm100) in Word, 0 in Writer. uno::Any aLineWidth = uno::makeAny(sal_Int32(26)); + text::WritingMode eWritingMode = text::WritingMode_LR_TB; for (std::vector< std::pair<OUString, OUString> >::iterator i = rShape.aProperties.begin(); i != rShape.aProperties.end(); ++i) @@ -206,10 +207,7 @@ void RTFSdrImport::resolve(RTFShape& rShape) else if (i->first == "txflTextFlow" && xPropertySet.is()) { if (i->second.toInt32() == 1) - { - aAny <<= text::WritingMode_TB_RL; - xPropertySet->setPropertyValue("TextWritingMode", aAny); - } + eWritingMode = text::WritingMode_TB_RL; } else if (i->first == "fLine" && xPropertySet.is()) resolveFLine(xPropertySet, i->second.toInt32()); @@ -373,6 +371,11 @@ void RTFSdrImport::resolve(RTFShape& rShape) xPropertySet->setPropertyValue("LineWidth", aLineWidth); if (rShape.oZ) resolveDhgt(xPropertySet, *rShape.oZ); + if (bTextFrame) + // Writer textframes implement text::WritingMode2, which is a different data type. + xPropertySet->setPropertyValue("WritingMode", uno::makeAny(sal_Int16(eWritingMode))); + else + xPropertySet->setPropertyValue("TextWritingMode", uno::makeAny(eWritingMode)); } if (nType == ESCHER_ShpInst_PictureFrame) // picture frame commit 9a8306a18998b42b387eb83128c82abbcfdd87a3 Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Apr 10 12:22:03 2013 +0200 RTF import of new-style frames: fix name Change-Id: Ifa8e79fb9c4b9ad5a0bf64466cefad91b6bbeb0c diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 3cb4038..f856099 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -26,6 +26,7 @@ * instead of those above. */ +#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/LineStyle.hpp> @@ -171,7 +172,15 @@ void RTFSdrImport::resolve(RTFShape& rShape) xPropertySet->setPropertyValue("FillColor", aAny); } else if ( i->first == "wzName" ) - xPropertySet->setPropertyValue("Name", uno::makeAny(i->second)); + { + if (bTextFrame) + { + uno::Reference<container::XNamed> xNamed(xShape, uno::UNO_QUERY); + xNamed->setName(i->second); + } + else + xPropertySet->setPropertyValue("Name", uno::makeAny(i->second)); + } else if ( i->first == "wzDescription" ) xPropertySet->setPropertyValue("Description", uno::makeAny(i->second)); else if ( i->first == "pib" ) commit 91a151085a9e8e77e30c0e21740f211fd5eedd95 Author: Miklos Vajna <vmik...@suse.cz> Date: Wed Apr 10 11:55:22 2013 +0200 restore disabled rtfimport tests There were two problems here: - Writer textframes don't have an AnchorPosition property, use compareRegionStarts() instead - turns out DOC/DOCX import doesn't create Write textframes when the shape has no text, doing so in the RTF import fixes the other two testcase as well. Change-Id: Ib2b4a0b7f8317d300fd532daea22568e33eceb53 diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index dc776d9..89c96f4 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> #include <com/sun/star/text/XTextFieldsSupplier.hpp> #include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextRangeCompare.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/text/XTextViewCursorSupplier.hpp> @@ -401,10 +402,14 @@ void Test::testFdo45187() uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); // There should be two shapes. CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount()); -#if 0 + // They should be anchored to different paragraphs. - CPPUNIT_ASSERT(getProperty<awt::Point>(xDraws->getByIndex(0), "AnchorPosition").Y != getProperty<awt::Point>(xDraws->getByIndex(1), "AnchorPosition").Y); -#endif + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xAnchor0 = uno::Reference<text::XTextContent>(xDraws->getByIndex(0), uno::UNO_QUERY)->getAnchor(); + uno::Reference<text::XTextRange> xAnchor1 = uno::Reference<text::XTextContent>(xDraws->getByIndex(1), uno::UNO_QUERY)->getAnchor(); + // Was 0 ("starts at the same position"), should be 1 ("starts before") + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xTextRangeCompare->compareRegionStarts(xAnchor0, xAnchor1)); } void Test::testFdo46662() @@ -752,11 +757,9 @@ void Test::testFdo52066() * xray ThisComponent.DrawPage(0).Size.Height */ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); -#if 0 uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(19)), xShape->getSize().Height); -#endif } void Test::testFdo48033_53594() @@ -1167,7 +1170,6 @@ void Test::testFdo59638() void Test::testFdo60722() { -#if 0 // The problem was that the larger shape was over the smaller one, and not the other way around. uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); @@ -1183,7 +1185,6 @@ void Test::testFdo60722() xShape.set(xDraws->getByIndex(2), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_uInt32(26), getProperty<sal_uInt32>(xShape, "LineWidth")); CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty<sal_uInt32>(xShape, "LineColor")); -#endif } void Test::testFdo61909() diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index b458bff..1df9d61 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -612,6 +612,11 @@ RTFParserState& RTFDocumentImpl::getDefaultState() return m_pSuperstream->getDefaultState(); } +RTFBuffer_t RTFDocumentImpl::getShapetextBuffer() +{ + return m_aShapetextBuffer; +} + void RTFDocumentImpl::resolve(Stream & rMapper) { m_pMapperStream = &rMapper; diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 16e1493..8ebf601 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -478,6 +478,8 @@ namespace writerfilter { rtl_TextEncoding getEncoding(sal_uInt32 nFontIndex); /// Get the default parser state. RTFParserState& getDefaultState(); + /// Get the shape text buffer; + RTFBuffer_t getShapetextBuffer(); private: SvStream& Strm(); diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 6d296a4..3cb4038 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -149,6 +149,7 @@ void RTFSdrImport::resolve(RTFShape& rShape) break; case ESCHER_ShpInst_Rectangle: case ESCHER_ShpInst_TextBox: + if (!m_rImport.getShapetextBuffer().empty()) { createShape("com.sun.star.text.TextFrame", xShape, xPropertySet); bTextFrame = true; @@ -156,6 +157,8 @@ void RTFSdrImport::resolve(RTFShape& rShape) for (size_t j = 0; j < aDefaults.size(); ++j) xPropertySet->setPropertyValue(aDefaults[j].Name, aDefaults[j].Value); } + else + bCustom = true; break; default: bCustom = true; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits