oox/source/shape/WpsContext.cxx | 108 ++++++++++++------------- oox/source/shape/WpsContext.hxx | 8 + sw/qa/extras/rtfimport/data/fdo65090.rtf | 6 + sw/qa/extras/rtfimport/rtfimport.cxx | 10 ++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 12 ++ 5 files changed, 90 insertions(+), 54 deletions(-)
New commits: commit 6eb02ac8a77f9f89f256b190281029f6cbd60d95 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sat Dec 28 09:55:33 2013 +0100 fdo#65090 RTF filter: import RTF_CLMGF and RTF_CLMRG These describe an explicit horizontal merge, that is not something Word itself creates, but it turns out the Calc RTF export does. Change-Id: I1b6ec10bb8e8bd40e24791ccc96f2f066dd0d5d5 diff --git a/sw/qa/extras/rtfimport/data/fdo65090.rtf b/sw/qa/extras/rtfimport/data/fdo65090.rtf new file mode 100644 index 0000000..8a3eabd --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo65090.rtf @@ -0,0 +1,6 @@ +{\rtf\ansi +{ +\trowd\trgaph30\trleft-30\trrh242\clmgf\clvertalc\cellx1280\clmrg\clvertalb\cellx2560\clvertalb\cellx3840\pard\plain\intbl +\qc a\cell\cell\ql b\cell\row +} +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 4a9978e..2764730 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1379,6 +1379,16 @@ DECLARE_RTFIMPORT_TEST(testCp1000016, "hello.rtf") CPPUNIT_ASSERT_EQUAL(false, bFound); } +DECLARE_RTFIMPORT_TEST(testFdo65090, "fdo65090.rtf") +{ + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY); + // The first row had 3 cells, instead of a horizontally merged one and a normal one (2 -> 1 separator). + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 810844f..2e56c62 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2449,6 +2449,18 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) m_aStates.top().nBorderState = BORDER_CHARACTER; } break; + case RTF_CLMGF: + { + RTFValue::Pointer_t pValue(new RTFValue(NS_ooxml::LN_Value_ST_Merge_restart)); + m_aStates.top().aTableCellSprms.set(NS_ooxml::LN_CT_TcPrBase_hMerge, pValue); + } + break; + case RTF_CLMRG: + { + RTFValue::Pointer_t pValue(new RTFValue(NS_ooxml::LN_Value_ST_Merge_continue)); + m_aStates.top().aTableCellSprms.set(NS_ooxml::LN_CT_TcPrBase_hMerge, pValue); + } + break; case RTF_CLVMGF: { RTFValue::Pointer_t pValue(new RTFValue(NS_ooxml::LN_Value_ST_Merge_restart)); commit c7662eea858d4c1edc7f7600fa102cedc386417f Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Sat Dec 28 09:57:01 2013 +0100 oox: whitespace fixes in WpsContext Change-Id: Idcd4409a02a5b0dc5f7b67d2a482bf4fe30f579c diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx index c5d233e..44fc1e6 100644 --- a/oox/source/shape/WpsContext.cxx +++ b/oox/source/shape/WpsContext.cxx @@ -14,11 +14,14 @@ using namespace com::sun::star; -namespace oox { namespace shape { +namespace oox +{ +namespace shape +{ WpsContext::WpsContext(ContextHandler2Helper& rParent, uno::Reference<drawing::XShape> xShape) : ContextHandler2(rParent), - mxShape(xShape) + mxShape(xShape) { mpShape.reset(new oox::drawingml::Shape("com.sun.star.drawing.CustomShape")); mpShape->setWps(true); @@ -37,64 +40,65 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken { switch (getBaseToken(nElementToken)) { - case XML_wsp: - break; - case XML_cNvCnPr: - break; - case XML_cNvSpPr: - break; - case XML_spPr: - return new oox::drawingml::ShapePropertiesContext(*this, *mpShape); - break; - case XML_style: - return new oox::drawingml::ShapeStyleContext(*this, *mpShape); - break; - case XML_bodyPr: - if (mxShape.is()) + case XML_wsp: + break; + case XML_cNvCnPr: + break; + case XML_cNvSpPr: + break; + case XML_spPr: + return new oox::drawingml::ShapePropertiesContext(*this, *mpShape); + break; + case XML_style: + return new oox::drawingml::ShapeStyleContext(*this, *mpShape); + break; + case XML_bodyPr: + if (mxShape.is()) + { + OptValue<OUString> oVert = rAttribs.getString(XML_vert); + if (oVert.has() && oVert.get() == "vert270") { - OptValue<OUString> oVert = rAttribs.getString(XML_vert); - if (oVert.has() && oVert.get() == "vert270") + // No support for this in core, work around by char rotation, as we do so for table cells already. + uno::Reference<text::XText> xText(mxShape, uno::UNO_QUERY); + uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor(); + xTextCursor->gotoStart(false); + xTextCursor->gotoEnd(true); + uno::Reference<beans::XPropertyState> xPropertyState(xTextCursor, uno::UNO_QUERY); + beans::PropertyState aState = xPropertyState->getPropertyState("CharRotation"); + if (aState == beans::PropertyState_DEFAULT_VALUE) { - // No support for this in core, work around by char rotation, as we do so for table cells already. - uno::Reference<text::XText> xText(mxShape, uno::UNO_QUERY); - uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursor(); - xTextCursor->gotoStart(false); - xTextCursor->gotoEnd(true); - uno::Reference<beans::XPropertyState> xPropertyState(xTextCursor, uno::UNO_QUERY); - beans::PropertyState aState = xPropertyState->getPropertyState("CharRotation"); - if (aState == beans::PropertyState_DEFAULT_VALUE) - { - uno::Reference<beans::XPropertySet> xPropertySet(xTextCursor, uno::UNO_QUERY); - xPropertySet->setPropertyValue("CharRotation", uno::makeAny(sal_Int16(900))); - } + uno::Reference<beans::XPropertySet> xPropertySet(xTextCursor, uno::UNO_QUERY); + xPropertySet->setPropertyValue("CharRotation", uno::makeAny(sal_Int16(900))); } + } - // Handle inset attributes for Writer textframes. - sal_Int32 aInsets[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns }; - boost::optional<sal_Int32> oInsets[4]; - for (size_t i = 0; i < SAL_N_ELEMENTS(aInsets); ++i) - { - OptValue<OUString> oValue = rAttribs.getString(aInsets[i]); - if (oValue.has()) - oInsets[i] = oox::drawingml::GetCoordinate(oValue.get()); - } - OUString aProps[] = { OUString("LeftBorderDistance"), OUString("TopBorderDistance"), OUString("RightBorderDistance"), OUString("BottomBorderDistance") }; - uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY); - for (size_t i = 0; i < SAL_N_ELEMENTS(aProps); ++i) - if (oInsets[i]) - xPropertySet->setPropertyValue(aProps[i], uno::makeAny(*oInsets[i])); + // Handle inset attributes for Writer textframes. + sal_Int32 aInsets[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns }; + boost::optional<sal_Int32> oInsets[4]; + for (size_t i = 0; i < SAL_N_ELEMENTS(aInsets); ++i) + { + OptValue<OUString> oValue = rAttribs.getString(aInsets[i]); + if (oValue.has()) + oInsets[i] = oox::drawingml::GetCoordinate(oValue.get()); } - break; - case XML_txbx: - mpShape->setServiceName("com.sun.star.text.TextFrame"); - break; - default: - SAL_WARN("oox", "WpsContext::createFastChildContext: unhandled element:" << getBaseToken(nElementToken)); - break; + OUString aProps[] = { OUString("LeftBorderDistance"), OUString("TopBorderDistance"), OUString("RightBorderDistance"), OUString("BottomBorderDistance") }; + uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY); + for (size_t i = 0; i < SAL_N_ELEMENTS(aProps); ++i) + if (oInsets[i]) + xPropertySet->setPropertyValue(aProps[i], uno::makeAny(*oInsets[i])); + } + break; + case XML_txbx: + mpShape->setServiceName("com.sun.star.text.TextFrame"); + break; + default: + SAL_WARN("oox", "WpsContext::createFastChildContext: unhandled element:" << getBaseToken(nElementToken)); + break; } return 0; } -} } +} +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/WpsContext.hxx b/oox/source/shape/WpsContext.hxx index b7f97f8..aafc77a 100644 --- a/oox/source/shape/WpsContext.hxx +++ b/oox/source/shape/WpsContext.hxx @@ -13,7 +13,10 @@ #include "oox/core/contexthandler2.hxx" #include "oox/drawingml/shape.hxx" -namespace oox { namespace shape { +namespace oox +{ +namespace shape +{ /// Wps is the drawingML equivalent of v:shape. class WpsContext : public oox::core::ContextHandler2 @@ -32,7 +35,8 @@ protected: }; -} } +} +} #endif _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits