From dddba7cb21e052179ae1bd3eb7da97d1f992b57b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 12 Aug 2011 17:41:38 +0200 Subject: bugus null pointer check --- writerfilter/source/rtftok/rtfsdrimport.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 212eecda84da..71482c901ad2 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -63,7 +63,7 @@ RTFSdrImport::RTFSdrImport(RTFDocumentImpl& rDocument, : m_rImport(rDocument) { uno::Reference xDrawings(xDstDoc, uno::UNO_QUERY); - if (m_xDrawPage.is() && xDrawings.is()) + if (xDrawings.is()) m_xDrawPage.set(xDrawings->getDrawPage(), uno::UNO_QUERY); } -- cgit From eecb1bb4efc8f82e4b32720d8878000214f4db5f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 12 Aug 2011 18:33:52 +0200 Subject: no special handling of text box shapes, we already have a drawpage set --- writerfilter/source/rtftok/rtfsdrimport.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 71482c901ad2..46664f54684f 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -274,7 +274,7 @@ void RTFSdrImport::resolve(RTFShape& rShape) OUStringToOString( i->second, RTL_TEXTENCODING_UTF8 ).getStr()); } - if (nType == 75 || nType == 202) // picture frame or text box + if (nType == 75) // picture frame { if (bPib) m_rImport.resolvePict(false); -- cgit From 08a968d1004ec77b6b3c4da5d70f0b39e938e73d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 15 Aug 2011 12:20:19 +0200 Subject: unused code: picture size is set in the extent attributes --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index d24fded13ce9..6b8c3a5361be 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -566,15 +566,6 @@ int RTFDocumentImpl::resolvePict(bool bInline) uno::Reference xGraphic = xGraphicProvider->queryGraphic(aMediaProperties); xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Bitmap")), uno::Any(xGraphic)); - // Set size - awt::Size aSize; - for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes->begin(); i != m_aStates.top().aCharacterAttributes->end(); ++i) - if (i->first == NS_rtf::LN_XEXT) - aSize.Width = i->second->getInt(); - else if (i->first == NS_rtf::LN_YEXT) - aSize.Height = i->second->getInt(); - xShape->setSize(aSize); - RTFValue::Pointer_t pShapeValue(new RTFValue(xShape)); m_aObjectAttributes->push_back(make_pair(NS_ooxml::LN_shape, pShapeValue)); return 0; -- cgit From db55a6392840145f2c7a677fc34ca88273d86411 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 15 Aug 2011 12:54:01 +0200 Subject: implement RTF_PICWGOAL and RTF_PICHGOAL --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 54 +++++++++++++++----------- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 13 ++++++- 2 files changed, 42 insertions(+), 25 deletions(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 6b8c3a5361be..2cb8e4a44f5c 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -594,9 +594,17 @@ int RTFDocumentImpl::resolvePict(bool bInline) RTFValue::Pointer_t pGraphicValue(new RTFValue(aGraphicAttributes, aGraphicSprms)); // extent sprm RTFSprms aExtentAttributes; - for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes->begin(); i != m_aStates.top().aCharacterAttributes->end(); ++i) - if (i->first == NS_rtf::LN_XEXT || i->first == NS_rtf::LN_YEXT) - aExtentAttributes->push_back(make_pair(i->first, i->second)); + int nXExt, nYExt; + nXExt = (m_aStates.top().aPicture.nGoalWidth ? m_aStates.top().aPicture.nGoalWidth : m_aStates.top().aPicture.nWidth); + nYExt = (m_aStates.top().aPicture.nGoalHeight ? m_aStates.top().aPicture.nGoalHeight : m_aStates.top().aPicture.nHeight); + if (m_aStates.top().aPicture.nScaleX != 100) + nXExt = (((long)m_aStates.top().aPicture.nScaleX) * ( nXExt - ( m_aStates.top().aPicture.nCropL + m_aStates.top().aPicture.nCropR ))) / 100L; + if (m_aStates.top().aPicture.nScaleY != 100) + nYExt = (((long)m_aStates.top().aPicture.nScaleY) * ( nYExt - ( m_aStates.top().aPicture.nCropT + m_aStates.top().aPicture.nCropB ))) / 100L; + RTFValue::Pointer_t pXExtValue(new RTFValue(nXExt)); + RTFValue::Pointer_t pYExtValue(new RTFValue(nYExt)); + aExtentAttributes->push_back(make_pair(NS_rtf::LN_XEXT, pXExtValue)); + aExtentAttributes->push_back(make_pair(NS_rtf::LN_YEXT, pYExtValue)); RTFValue::Pointer_t pExtentValue(new RTFValue(aExtentAttributes)); // docpr sprm RTFSprms aDocprAttributes; @@ -1844,20 +1852,6 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) return 0; } - // Trivial character attributes. - switch (nKeyword) - { - case RTF_PICW: nSprm = NS_rtf::LN_XEXT; if (m_aStates.top().nPictureScaleX) nParam = m_aStates.top().nPictureScaleX * nParam; break; - case RTF_PICH: nSprm = NS_rtf::LN_YEXT; if (m_aStates.top().nPictureScaleY) nParam = m_aStates.top().nPictureScaleY * nParam; break; - default: break; - } - if (nSprm > 0) - { - RTFValue::Pointer_t pValue(new RTFValue(nParam)); - m_aStates.top().aCharacterAttributes->push_back(make_pair(nSprm, pValue)); - return 0; - } - // Info group. switch (nKeyword) { @@ -2091,10 +2085,22 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) // Ignore these for now, the exporter always emits them with a zero parameter. break; case RTF_PICSCALEX: - m_aStates.top().nPictureScaleX = 0.01 * nParam; + m_aStates.top().aPicture.nScaleX = nParam; break; case RTF_PICSCALEY: - m_aStates.top().nPictureScaleY = 0.01 * nParam; + m_aStates.top().aPicture.nScaleY = nParam; + break; + case RTF_PICW: + m_aStates.top().aPicture.nWidth = nParam; + break; + case RTF_PICH: + m_aStates.top().aPicture.nHeight = nParam; + break; + case RTF_PICWGOAL: + m_aStates.top().aPicture.nGoalWidth = TWIP_TO_MM100(nParam); + break; + case RTF_PICHGOAL: + m_aStates.top().aPicture.nGoalHeight = TWIP_TO_MM100(nParam); break; case RTF_SHPWRK: { @@ -2525,6 +2531,7 @@ int RTFDocumentImpl::popState() bool bListOverrideEntryEnd = false; bool bLevelTextEnd = false; RTFShape aShape; + RTFPicture aPicture; bool bPopShapeProperties = false; bool bPopPictureProperties = false; bool bFaltEnd = false; @@ -2642,6 +2649,7 @@ int RTFDocumentImpl::popState() || m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTY) { aShape = m_aStates.top().aShape; + aPicture = m_aStates.top().aPicture; aAttributes = m_aStates.top().aCharacterAttributes; if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYNAME) aShape.aProperties.push_back(make_pair(m_aStates.top().aDestinationText.makeStringAndClear(), OUString())); @@ -2669,7 +2677,7 @@ int RTFDocumentImpl::popState() else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYVALUEPICT) { bPopPictureProperties = true; - aAttributes = m_aStates.top().aCharacterAttributes; + aPicture = m_aStates.top().aPicture; aDestinationText = m_aStates.top().aDestinationText; } else if (m_aStates.top().nDestinationState == DESTINATION_SHAPETEXT) @@ -2890,13 +2898,14 @@ int RTFDocumentImpl::popState() else if (bPopShapeProperties) { m_aStates.top().aShape = aShape; + m_aStates.top().aPicture = aPicture; m_aStates.top().aCharacterAttributes = aAttributes; } else if (bFaltEnd) m_aStates.top().aTableSprms = aSprms; if (bPopPictureProperties) { - m_aStates.top().aCharacterAttributes = aAttributes; + m_aStates.top().aPicture = aPicture; m_aStates.top().aDestinationText = aDestinationText; } if (m_pCurrentBuffer == &m_aSuperBuffer) @@ -2982,8 +2991,7 @@ RTFParserState::RTFParserState() nListLevelNum(0), aListLevelEntries(), aLevelNumbers(), - nPictureScaleX(0), - nPictureScaleY(0), + aPicture(), aShape(), nCellX(0), nCells(0), diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 463b6058ca80..b0c4668a8fdc 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -177,6 +177,16 @@ namespace writerfilter { int nBottom; }; + /// Stores the properties of a picture. + class RTFPicture + { + public: + sal_uInt16 nWidth, nHeight; + sal_uInt16 nGoalWidth, nGoalHeight; + sal_uInt16 nScaleX, nScaleY; + short nCropT, nCropB, nCropL, nCropR; + }; + /// State of the parser, which gets saved / restored when changing groups. class RTFParserState { @@ -229,8 +239,7 @@ namespace writerfilter { /// List of character positions in leveltext to replace. std::vector aLevelNumbers; - float nPictureScaleX; - float nPictureScaleY; + RTFPicture aPicture; RTFShape aShape; /// Current cellx value. -- cgit From 997cd18a65c9b21a3a76a47e2c247b002e95e0e9 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 15 Aug 2011 13:09:12 +0200 Subject: send crop values to dmapper --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 2cb8e4a44f5c..8078ceb81d00 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2102,6 +2102,10 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) case RTF_PICHGOAL: m_aStates.top().aPicture.nGoalHeight = TWIP_TO_MM100(nParam); break; + case RTF_PICCROPL: m_aStates.top().aPicture.nCropL = TWIP_TO_MM100(nParam); break; + case RTF_PICCROPR: m_aStates.top().aPicture.nCropR = TWIP_TO_MM100(nParam); break; + case RTF_PICCROPT: m_aStates.top().aPicture.nCropT = TWIP_TO_MM100(nParam); break; + case RTF_PICCROPB: m_aStates.top().aPicture.nCropB = TWIP_TO_MM100(nParam); break; case RTF_SHPWRK: { int nValue = 0; -- cgit From 2f6dab766808e9e0382382d7f781d3892539556b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 17 Aug 2011 18:24:33 +0200 Subject: dmapper: textframes have to be inserted before text can be appended to them --- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index dc487b55e721..f4d2c2038985 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1412,6 +1412,7 @@ void DomainMapper_Impl::PopAnnotation() void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape > xShape ) { + uno::Reference xTextAppend = m_aTextAppendStack.top().xTextAppend; m_bIsInShape = true; try { @@ -1433,6 +1434,12 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_OPAQUE ), uno::makeAny( true ) ); + if (xSInfo->supportsService(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextFrame")))) + { + uno::Reference xTextContent(xShape, uno::UNO_QUERY_THROW); + uno::Reference xTextRange(xTextAppend->createTextCursorByRange(xTextAppend->getEnd()), uno::UNO_QUERY_THROW); + xTextAppend->insertTextContent(xTextRange, xTextContent, sal_False); + } } catch ( const uno::Exception& e ) { -- cgit From 174b65ec87676078da23952e3fe61ab1366fcfb8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 17 Aug 2011 20:20:12 +0200 Subject: initial textframe support --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 56 +++++++++++++++++++++++++- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 10 +++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 8078ceb81d00..e0c864ce0eda 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -32,6 +32,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -288,7 +292,8 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference const& x m_nCurrentFontIndex(0), m_aStyleTableEntries(), m_nCurrentStyleIndex(0), - m_bEq(false) + m_bEq(false), + m_bIsInFrame(false) { OSL_ASSERT(xInputStream.is()); m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, sal_True); @@ -422,6 +427,13 @@ void RTFDocumentImpl::parBreak() Mapper().endCharacterGroup(); Mapper().endParagraphGroup(); + if (m_bIsInFrame) + { + m_bIsInFrame = false; + Mapper().endShape(); + Mapper().endParagraphGroup(); + } + // If we are not in a table, then the next table row will be the first one. RTFValue::Pointer_t pValue = m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PFInTable); if (!pValue.get()) @@ -798,6 +810,35 @@ void RTFDocumentImpl::text(OUString& rString) checkFirstRun(); if (m_bNeedPap) { + // Check if this is a frame. + if (m_aStates.top().aFrame.nW > 0 + || m_aStates.top().aFrame.nH > 0 + || m_aStates.top().aFrame.nX > 0 + || m_aStates.top().aFrame.nY > 0) + { + uno::Reference xTextFrame; + xTextFrame.set(getModelFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))), uno::UNO_QUERY); + uno::Reference xShape(xTextFrame, uno::UNO_QUERY); + uno::Reference xPropertySet(xTextFrame, uno::UNO_QUERY); + + // RTF allows frames larger than the text content by default + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SizeType")), uno::Any(text::SizeType::MIN)); + + xShape->setSize(awt::Size(m_aStates.top().aFrame.nW, m_aStates.top().aFrame.nH)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(text::HoriOrientation::NONE)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), uno::Any(text::VertOrientation::NONE)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nY))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LeftMargin")), uno::Any(sal_Int32(0))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(0))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::Any(sal_Int32(0))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::Any(sal_Int32(0))); + + Mapper().startShape(xShape); + Mapper().startParagraphGroup(); + m_bIsInFrame = true; + } + if (!m_pCurrentBuffer) Mapper().props(pParagraphProperties); else @@ -2337,6 +2378,18 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) case RTF_AFTNSTART: lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_endnotePr, NS_ooxml::LN_EG_FtnEdnNumProps_numStart, pIntValue); break; + case RTF_ABSW: + m_aStates.top().aFrame.nW = TWIP_TO_MM100(nParam); + break; + case RTF_ABSH: + m_aStates.top().aFrame.nH = TWIP_TO_MM100(nParam); + break; + case RTF_POSX: + m_aStates.top().aFrame.nX = TWIP_TO_MM100(nParam); + break; + case RTF_POSY: + m_aStates.top().aFrame.nY = TWIP_TO_MM100(nParam); + break; default: #if OSL_DEBUG_LEVEL > 1 OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword)); @@ -2997,6 +3050,7 @@ RTFParserState::RTFParserState() aLevelNumbers(), aPicture(), aShape(), + aFrame(), nCellX(0), nCells(0), bIsCjk(false), diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index b0c4668a8fdc..fda42800a866 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -187,6 +187,13 @@ namespace writerfilter { short nCropT, nCropB, nCropL, nCropR; }; + /// Stores the properties of a frame + class RTFFrame + { + public: + int nX, nY, nW, nH; + }; + /// State of the parser, which gets saved / restored when changing groups. class RTFParserState { @@ -241,6 +248,7 @@ namespace writerfilter { RTFPicture aPicture; RTFShape aShape; + RTFFrame aFrame; /// Current cellx value. int nCellX; @@ -402,6 +410,8 @@ namespace writerfilter { RTFReferenceTable::Entries_t m_aStyleTableEntries; int m_nCurrentStyleIndex; bool m_bEq; + /// If we are in a frame. + bool m_bIsInFrame; }; } // namespace rtftok -- cgit From b7633fa4b2ff9fd54a608dcdbf72c3372ee0fdd9 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 17 Aug 2011 21:12:17 +0200 Subject: Implement textframe margins --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 18 ++++++++++++++---- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index e0c864ce0eda..4f85e69cfc51 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -829,10 +829,10 @@ void RTFDocumentImpl::text(OUString& rString) xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX))); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), uno::Any(text::VertOrientation::NONE)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nY))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LeftMargin")), uno::Any(sal_Int32(0))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(0))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::Any(sal_Int32(0))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::Any(sal_Int32(0))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LeftMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nLeftMargin))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nRightMargin))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nTopMargin))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nBottomMargin))); Mapper().startShape(xShape); Mapper().startParagraphGroup(); @@ -2390,6 +2390,16 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) case RTF_POSY: m_aStates.top().aFrame.nY = TWIP_TO_MM100(nParam); break; + case RTF_DFRMTXTX: + m_aStates.top().aFrame.nLeftMargin = m_aStates.top().aFrame.nRightMargin = TWIP_TO_MM100(nParam); + break; + case RTF_DFRMTXTY: + m_aStates.top().aFrame.nTopMargin = m_aStates.top().aFrame.nBottomMargin = TWIP_TO_MM100(nParam); + break; + case RTF_DXFRTEXT: + m_aStates.top().aFrame.nLeftMargin = m_aStates.top().aFrame.nRightMargin = + m_aStates.top().aFrame.nTopMargin = m_aStates.top().aFrame.nBottomMargin = TWIP_TO_MM100(nParam); + break; default: #if OSL_DEBUG_LEVEL > 1 OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword)); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index fda42800a866..5c683b20cc90 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -192,6 +192,7 @@ namespace writerfilter { { public: int nX, nY, nW, nH; + int nLeftMargin, nRightMargin, nTopMargin, nBottomMargin; }; /// State of the parser, which gets saved / restored when changing groups. -- cgit From fd0a8ca9574493f2d52ef1de5104ffdd6226369b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 17 Aug 2011 23:54:17 +0200 Subject: Support multiple paragraphs inside a single frame --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 33 ++++++++++++++++---------- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 3 ++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 4f85e69cfc51..7db3b1abbe1e 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -293,7 +293,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference const& x m_aStyleTableEntries(), m_nCurrentStyleIndex(0), m_bEq(false), - m_bIsInFrame(false) + m_bWasInFrame(false) { OSL_ASSERT(xInputStream.is()); m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, sal_True); @@ -427,13 +427,6 @@ void RTFDocumentImpl::parBreak() Mapper().endCharacterGroup(); Mapper().endParagraphGroup(); - if (m_bIsInFrame) - { - m_bIsInFrame = false; - Mapper().endShape(); - Mapper().endParagraphGroup(); - } - // If we are not in a table, then the next table row will be the first one. RTFValue::Pointer_t pValue = m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PFInTable); if (!pValue.get()) @@ -709,6 +702,14 @@ int RTFDocumentImpl::resolveChars(char ch) return 0; } +bool RTFDocumentImpl::inFrame() +{ + return m_aStates.top().aFrame.nW > 0 + || m_aStates.top().aFrame.nH > 0 + || m_aStates.top().aFrame.nX > 0 + || m_aStates.top().aFrame.nY > 0; +} + void RTFDocumentImpl::text(OUString& rString) { bool bRet = true; @@ -811,10 +812,7 @@ void RTFDocumentImpl::text(OUString& rString) if (m_bNeedPap) { // Check if this is a frame. - if (m_aStates.top().aFrame.nW > 0 - || m_aStates.top().aFrame.nH > 0 - || m_aStates.top().aFrame.nX > 0 - || m_aStates.top().aFrame.nY > 0) + if (inFrame() && !m_bWasInFrame) { uno::Reference xTextFrame; xTextFrame.set(getModelFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))), uno::UNO_QUERY); @@ -836,7 +834,14 @@ void RTFDocumentImpl::text(OUString& rString) Mapper().startShape(xShape); Mapper().startParagraphGroup(); - m_bIsInFrame = true; + } + else if (!inFrame() && m_bWasInFrame) + { + Mapper().endParagraphGroup(); + Mapper().endShape(); + Mapper().endParagraphGroup(); + Mapper().startParagraphGroup(); + m_bWasInFrame = false; } if (!m_pCurrentBuffer) @@ -1268,6 +1273,7 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) } // but don't emit properties yet, since they may change till the first text token arrives m_bNeedPap = true; + m_bWasInFrame = inFrame(); } break; case RTF_SECT: @@ -1598,6 +1604,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTF_PARD: m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms; m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes; + m_aStates.top().aFrame = RTFFrame(); m_pCurrentBuffer = 0; break; case RTF_SECTD: diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 5c683b20cc90..c3595f69595b 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -335,6 +335,7 @@ namespace writerfilter { void checkFirstRun(); void sectBreak(bool bFinal); void replayBuffer(RTFBuffer_t& rBuffer); + bool inFrame(); uno::Reference const& m_xContext; uno::Reference const& m_xInputStream; @@ -412,7 +413,7 @@ namespace writerfilter { int m_nCurrentStyleIndex; bool m_bEq; /// If we are in a frame. - bool m_bIsInFrame; + bool m_bWasInFrame; }; } // namespace rtftok -- cgit From 2f2c6b05cb2d36db394831a1399cf359bd224a71 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 00:07:36 +0200 Subject: Support empty paragraphs in text frames --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 71 ++++++++++++++------------ writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1 + 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 7db3b1abbe1e..f3e9b9d4ac50 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -710,6 +710,42 @@ bool RTFDocumentImpl::inFrame() || m_aStates.top().aFrame.nY > 0; } +void RTFDocumentImpl::checkChangedFrame() +{ + // Check if this is a frame. + if (inFrame() && !m_bWasInFrame) + { + uno::Reference xTextFrame; + xTextFrame.set(getModelFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))), uno::UNO_QUERY); + uno::Reference xShape(xTextFrame, uno::UNO_QUERY); + uno::Reference xPropertySet(xTextFrame, uno::UNO_QUERY); + + // RTF allows frames larger than the text content by default + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SizeType")), uno::Any(text::SizeType::MIN)); + + xShape->setSize(awt::Size(m_aStates.top().aFrame.nW, m_aStates.top().aFrame.nH)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(text::HoriOrientation::NONE)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), uno::Any(text::VertOrientation::NONE)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nY))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LeftMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nLeftMargin))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nRightMargin))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nTopMargin))); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nBottomMargin))); + + Mapper().startShape(xShape); + Mapper().startParagraphGroup(); + } + else if (!inFrame() && m_bWasInFrame) + { + Mapper().endParagraphGroup(); + Mapper().endShape(); + Mapper().endParagraphGroup(); + Mapper().startParagraphGroup(); + m_bWasInFrame = false; + } +} + void RTFDocumentImpl::text(OUString& rString) { bool bRet = true; @@ -811,38 +847,7 @@ void RTFDocumentImpl::text(OUString& rString) checkFirstRun(); if (m_bNeedPap) { - // Check if this is a frame. - if (inFrame() && !m_bWasInFrame) - { - uno::Reference xTextFrame; - xTextFrame.set(getModelFactory()->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))), uno::UNO_QUERY); - uno::Reference xShape(xTextFrame, uno::UNO_QUERY); - uno::Reference xPropertySet(xTextFrame, uno::UNO_QUERY); - - // RTF allows frames larger than the text content by default - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SizeType")), uno::Any(text::SizeType::MIN)); - - xShape->setSize(awt::Size(m_aStates.top().aFrame.nW, m_aStates.top().aFrame.nH)); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(text::HoriOrientation::NONE)); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), uno::Any(text::VertOrientation::NONE)); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nY))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LeftMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nLeftMargin))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nRightMargin))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nTopMargin))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nBottomMargin))); - - Mapper().startShape(xShape); - Mapper().startParagraphGroup(); - } - else if (!inFrame() && m_bWasInFrame) - { - Mapper().endParagraphGroup(); - Mapper().endShape(); - Mapper().endParagraphGroup(); - Mapper().startParagraphGroup(); - m_bWasInFrame = false; - } + checkChangedFrame(); if (!m_pCurrentBuffer) Mapper().props(pParagraphProperties); @@ -1264,6 +1269,8 @@ int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword) break; case RTF_PAR: { + if (m_bNeedPap) + checkChangedFrame(); if (!m_pCurrentBuffer) parBreak(); else if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index c3595f69595b..bb3faec417af 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -336,6 +336,7 @@ namespace writerfilter { void sectBreak(bool bFinal); void replayBuffer(RTFBuffer_t& rBuffer); bool inFrame(); + void checkChangedFrame(); uno::Reference const& m_xContext; uno::Reference const& m_xInputStream; -- cgit From 32ebb1e83072688cfc6056304ae73dcd57d5421e Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 00:34:42 +0200 Subject: Add data structures to import LO-specific fly frame RTF extensions --- writerfilter/source/rtftok/rtffly.hxx | 123 ++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 writerfilter/source/rtftok/rtffly.hxx diff --git a/writerfilter/source/rtftok/rtffly.hxx b/writerfilter/source/rtftok/rtffly.hxx new file mode 100644 index 000000000000..d5e52399d36f --- /dev/null +++ b/writerfilter/source/rtftok/rtffly.hxx @@ -0,0 +1,123 @@ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * Miklos Vajna + * Portions created by the Initial Developer are Copyright (C) 2011 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#ifndef _RTFFLY_HXX_ +#define _RTFFLY_HXX_ + +namespace writerfilter { + namespace rtftok { + /// Stores the vertical orientation properties of an RTF fly frame. + class RTFVertOrient + { + public: + RTFVertOrient(sal_uInt16 nValue) + { + Value.nVal = nValue; + } + + RTFVertOrient(sal_uInt16 nOrient, sal_uInt16 nRelOrient) + { + Value.Flags.nOrient = nOrient; + Value.Flags.nRelOrient = nRelOrient; + } + + sal_uInt16 GetOrient() const + { + return Value.Flags.nOrient; + } + + sal_uInt16 GetRelation() const + { + return Value.Flags.nRelOrient; + } + + sal_uInt16 GetValue() const + { + return Value.nVal; + } + + private: + union + { + struct + { + sal_uInt16 nOrient : 4; + sal_uInt16 nRelOrient : 1; + } Flags; + sal_uInt16 nVal; + } Value; + }; + + /// Stores the horizontal orientation properties of an RTF fly frame. + class RTFHoriOrient + { + public: + RTFHoriOrient(sal_uInt16 nValue) + { + Value.nVal = nValue; + } + + RTFHoriOrient(sal_uInt16 nOrient, sal_uInt16 nRelOrient) + { + Value.Flags.nOrient = nOrient; + Value.Flags.nRelOrient = nRelOrient; + Value.Flags.nRelAnchor = 0; + } + + sal_uInt16 GetOrient() const + { + return Value.Flags.nOrient; + } + + sal_uInt16 GetRelation() const + { + return Value.Flags.nRelOrient; + } + + sal_uInt16 GetValue() const + { + return Value.nVal; + } + + private: + union + { + struct + { + sal_uInt16 nOrient : 4; + sal_uInt16 nRelAnchor : 4; + sal_uInt16 nRelOrient : 1; + } Flags; + sal_uInt16 nVal; + } Value; + }; + } // namespace rtftok +} // namespace writerfilter + +#endif // _RTFFLY_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit From a5d694abef5b889f4f9e8645e1f7f713c25a72fd Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 00:38:48 +0200 Subject: enter RTF_FLYMAINCNT --- writerfilter/source/rtftok/rtfcontrolwords.cxx | 1 + writerfilter/source/rtftok/rtfcontrolwords.hxx | 3 ++- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 4 ++++ writerfilter/source/rtftok/rtfdocumentimpl.hxx | 3 ++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx index 0d7f0c049187..dfdec0750fba 100644 --- a/writerfilter/source/rtftok/rtfcontrolwords.cxx +++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx @@ -1844,6 +1844,7 @@ RTFSymbol aRTFControlWords[] = { {"zwj", CONTROL_SYMBOL, RTF_ZWJ}, {"zwnbo", CONTROL_SYMBOL, RTF_ZWNBO}, {"zwnj", CONTROL_SYMBOL, RTF_ZWNJ}, + {"flymaincnt", CONTROL_DESTINATION, RTF_FLYMAINCNT}, }; int nRTFControlWords = SAL_N_ELEMENTS(aRTFControlWords); diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx index 55e17e3e29ea..b3ca6e2a76e6 100644 --- a/writerfilter/source/rtftok/rtfcontrolwords.hxx +++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx @@ -1843,7 +1843,8 @@ enum RTFKeyword RTF_ZWBO, RTF_ZWJ, RTF_ZWNBO, - RTF_ZWNJ + RTF_ZWNJ, + RTF_FLYMAINCNT }; /// Types of an RTF Control Word diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index f3e9b9d4ac50..4f62fed2a8cc 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -58,6 +58,7 @@ #include #include #include +#include #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L)) @@ -1212,6 +1213,9 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) case RTF_FALT: m_aStates.top().nDestinationState = DESTINATION_FALT; break; + case RTF_FLYMAINCNT: + m_aStates.top().nDestinationState = DESTINATION_FLYMAINCONTENT; + break; case RTF_LISTTEXT: // Should be ignored by any reader that understands Word 97 through Word 2007 numbering. case RTF_NONESTTABLES: diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index bb3faec417af..5ebc3a74608d 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -112,7 +112,8 @@ namespace writerfilter { DESTINATION_RESULT, DESTINATION_ANNOTATIONDATE, DESTINATION_ANNOTATIONAUTHOR, - DESTINATION_FALT + DESTINATION_FALT, + DESTINATION_FLYMAINCONTENT }; enum RTFBorderState -- cgit From 6c8d683a4b23c812cf7484ad483bed3fc2e8797f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 00:56:43 +0200 Subject: implement RTF_FLYVERT and RTF_FLYHORZ --- writerfilter/source/rtftok/rtfcontrolwords.cxx | 2 ++ writerfilter/source/rtftok/rtfcontrolwords.hxx | 4 +++- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 20 ++++++++++++++++++-- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 5 +++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx index dfdec0750fba..00a11a5b753e 100644 --- a/writerfilter/source/rtftok/rtfcontrolwords.cxx +++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx @@ -1845,6 +1845,8 @@ RTFSymbol aRTFControlWords[] = { {"zwnbo", CONTROL_SYMBOL, RTF_ZWNBO}, {"zwnj", CONTROL_SYMBOL, RTF_ZWNJ}, {"flymaincnt", CONTROL_DESTINATION, RTF_FLYMAINCNT}, + {"flyvert", CONTROL_VALUE, RTF_FLYVERT}, + {"flyhorz", CONTROL_VALUE, RTF_FLYHORZ}, }; int nRTFControlWords = SAL_N_ELEMENTS(aRTFControlWords); diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx index b3ca6e2a76e6..2c1a05b3c9da 100644 --- a/writerfilter/source/rtftok/rtfcontrolwords.hxx +++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx @@ -1844,7 +1844,9 @@ enum RTFKeyword RTF_ZWJ, RTF_ZWNBO, RTF_ZWNJ, - RTF_FLYMAINCNT + RTF_FLYMAINCNT, + RTF_FLYVERT, + RTF_FLYHORZ }; /// Types of an RTF Control Word diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 4f62fed2a8cc..b99db4dafb68 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -725,9 +725,11 @@ void RTFDocumentImpl::checkChangedFrame() xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SizeType")), uno::Any(text::SizeType::MIN)); xShape->setSize(awt::Size(m_aStates.top().aFrame.nW, m_aStates.top().aFrame.nH)); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(text::HoriOrientation::NONE)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(m_aStates.top().aFrame.nHoriOrient)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation")), uno::Any(m_aStates.top().aFrame.nHoriOrientRelation)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX))); - xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), uno::Any(text::VertOrientation::NONE)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), uno::Any(m_aStates.top().aFrame.nVertOrient)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientRelation")), uno::Any(m_aStates.top().aFrame.nVertOrientRelation)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nY))); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LeftMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nLeftMargin))); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("RightMargin")), uno::Any(sal_Int32(m_aStates.top().aFrame.nRightMargin))); @@ -2418,6 +2420,20 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().aFrame.nLeftMargin = m_aStates.top().aFrame.nRightMargin = m_aStates.top().aFrame.nTopMargin = m_aStates.top().aFrame.nBottomMargin = TWIP_TO_MM100(nParam); break; + case RTF_FLYVERT: + { + RTFVertOrient aVertOrient(nParam); + m_aStates.top().aFrame.nVertOrient = aVertOrient.GetOrient(); + m_aStates.top().aFrame.nVertOrientRelation = aVertOrient.GetRelation(); + } + break; + case RTF_FLYHORZ: + { + RTFHoriOrient aHoriOrient(nParam); + m_aStates.top().aFrame.nHoriOrient = aHoriOrient.GetOrient(); + m_aStates.top().aFrame.nHoriOrientRelation = aHoriOrient.GetRelation(); + } + break; default: #if OSL_DEBUG_LEVEL > 1 OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword)); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 5ebc3a74608d..4fecf1a2fd14 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -192,8 +192,9 @@ namespace writerfilter { class RTFFrame { public: - int nX, nY, nW, nH; - int nLeftMargin, nRightMargin, nTopMargin, nBottomMargin; + sal_Int32 nX, nY, nW, nH; + sal_Int32 nLeftMargin, nRightMargin, nTopMargin, nBottomMargin; + sal_Int16 nHoriOrient, nHoriOrientRelation, nVertOrient, nVertOrientRelation; }; /// State of the parser, which gets saved / restored when changing groups. -- cgit From 2e67f17fb3aedb41edb72abf87b40bd5ab746296 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 01:01:57 +0200 Subject: fly props are needed outside their destination --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index b99db4dafb68..abf2a87b2234 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -2636,6 +2636,8 @@ int RTFDocumentImpl::popState() bool bPopShapeProperties = false; bool bPopPictureProperties = false; bool bFaltEnd = false; + RTFFrame aFrame; + bool bPopFrame = false; if (m_aStates.top().nDestinationState == DESTINATION_FONTTABLE) { @@ -2951,6 +2953,11 @@ int RTFDocumentImpl::popState() aSprms = m_aStates.top().aTableSprms; bFaltEnd = true; } + else if (m_aStates.top().nDestinationState == DESTINATION_FLYMAINCONTENT) + { + aFrame = m_aStates.top().aFrame; + bPopFrame = true; + } // See if we need to end a track change RTFValue::Pointer_t pTrackchange = m_aStates.top().aCharacterSprms.find(NS_ooxml::LN_trackchange); @@ -3004,6 +3011,8 @@ int RTFDocumentImpl::popState() } else if (bFaltEnd) m_aStates.top().aTableSprms = aSprms; + else if (bPopFrame) + m_aStates.top().aFrame = aFrame; if (bPopPictureProperties) { m_aStates.top().aPicture = aPicture; -- cgit From 0b415dac18c23052b5dcf0f76445d7bb4f6fbe01 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 01:03:51 +0200 Subject: these ctors are unused --- writerfilter/source/rtftok/rtffly.hxx | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/writerfilter/source/rtftok/rtffly.hxx b/writerfilter/source/rtftok/rtffly.hxx index d5e52399d36f..a03dc8236dd5 100644 --- a/writerfilter/source/rtftok/rtffly.hxx +++ b/writerfilter/source/rtftok/rtffly.hxx @@ -39,12 +39,6 @@ namespace writerfilter { Value.nVal = nValue; } - RTFVertOrient(sal_uInt16 nOrient, sal_uInt16 nRelOrient) - { - Value.Flags.nOrient = nOrient; - Value.Flags.nRelOrient = nRelOrient; - } - sal_uInt16 GetOrient() const { return Value.Flags.nOrient; @@ -81,13 +75,6 @@ namespace writerfilter { Value.nVal = nValue; } - RTFHoriOrient(sal_uInt16 nOrient, sal_uInt16 nRelOrient) - { - Value.Flags.nOrient = nOrient; - Value.Flags.nRelOrient = nRelOrient; - Value.Flags.nRelAnchor = 0; - } - sal_uInt16 GetOrient() const { return Value.Flags.nOrient; -- cgit From e4c1f2a7abcca5f8398f90ce05820456954543e9 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 01:53:16 +0200 Subject: dmapper: don't reset anchor type of text frames --- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index f4d2c2038985..0d2e31102e00 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1430,7 +1430,6 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape uno::Reference< lang::XServiceInfo > xSInfo( xShape, uno::UNO_QUERY_THROW ); bool bIsGraphic = xSInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) ) ); - xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_ANCHOR_TYPE ), bIsGraphic ? uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) : uno::makeAny( text::TextContentAnchorType_AT_PARAGRAPH ) ); xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_OPAQUE ), uno::makeAny( true ) ); @@ -1440,6 +1439,10 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape uno::Reference xTextRange(xTextAppend->createTextCursorByRange(xTextAppend->getEnd()), uno::UNO_QUERY_THROW); xTextAppend->insertTextContent(xTextRange, xTextContent, sal_False); } + else + { + xProps->setPropertyValue( rPropNameSupplier.GetName( PROP_ANCHOR_TYPE ), bIsGraphic ? uno::makeAny( text::TextContentAnchorType_AS_CHARACTER ) : uno::makeAny( text::TextContentAnchorType_AT_PARAGRAPH ) ); + } } catch ( const uno::Exception& e ) { -- cgit From d8ceaa2fb5f74526695ea5c3ca974e0808f1b343 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 01:54:39 +0200 Subject: implement RTF_FLYANCHOR --- writerfilter/source/rtftok/rtfcontrolwords.cxx | 1 + writerfilter/source/rtftok/rtfcontrolwords.hxx | 3 ++- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 4 ++++ writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/writerfilter/source/rtftok/rtfcontrolwords.cxx b/writerfilter/source/rtftok/rtfcontrolwords.cxx index 00a11a5b753e..aef56ab77962 100644 --- a/writerfilter/source/rtftok/rtfcontrolwords.cxx +++ b/writerfilter/source/rtftok/rtfcontrolwords.cxx @@ -1847,6 +1847,7 @@ RTFSymbol aRTFControlWords[] = { {"flymaincnt", CONTROL_DESTINATION, RTF_FLYMAINCNT}, {"flyvert", CONTROL_VALUE, RTF_FLYVERT}, {"flyhorz", CONTROL_VALUE, RTF_FLYHORZ}, + {"flyanchor", CONTROL_VALUE, RTF_FLYANCHOR}, }; int nRTFControlWords = SAL_N_ELEMENTS(aRTFControlWords); diff --git a/writerfilter/source/rtftok/rtfcontrolwords.hxx b/writerfilter/source/rtftok/rtfcontrolwords.hxx index 2c1a05b3c9da..9c355bb9bee5 100644 --- a/writerfilter/source/rtftok/rtfcontrolwords.hxx +++ b/writerfilter/source/rtftok/rtfcontrolwords.hxx @@ -1846,7 +1846,8 @@ enum RTFKeyword RTF_ZWNJ, RTF_FLYMAINCNT, RTF_FLYVERT, - RTF_FLYHORZ + RTF_FLYHORZ, + RTF_FLYANCHOR }; /// Types of an RTF Control Word diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index abf2a87b2234..b998d288e96b 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -725,6 +725,7 @@ void RTFDocumentImpl::checkChangedFrame() xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("SizeType")), uno::Any(text::SizeType::MIN)); xShape->setSize(awt::Size(m_aStates.top().aFrame.nW, m_aStates.top().aFrame.nH)); + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorType")), uno::Any(m_aStates.top().aFrame.nAnchorType)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(m_aStates.top().aFrame.nHoriOrient)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation")), uno::Any(m_aStates.top().aFrame.nHoriOrientRelation)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX))); @@ -2434,6 +2435,9 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().aFrame.nHoriOrientRelation = aHoriOrient.GetRelation(); } break; + case RTF_FLYANCHOR: + m_aStates.top().aFrame.nAnchorType = nParam; + break; default: #if OSL_DEBUG_LEVEL > 1 OSL_TRACE("%s: TODO handle value '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword)); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 4fecf1a2fd14..a89d3daa6d5c 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -195,6 +195,7 @@ namespace writerfilter { sal_Int32 nX, nY, nW, nH; sal_Int32 nLeftMargin, nRightMargin, nTopMargin, nBottomMargin; sal_Int16 nHoriOrient, nHoriOrientRelation, nVertOrient, nVertOrientRelation; + sal_Int16 nAnchorType; }; /// State of the parser, which gets saved / restored when changing groups. -- cgit From 5d2a624f466f4c81847b07a63ca2d26c39efc33f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 02:09:30 +0200 Subject: tokenize text::RelOrientation --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index b998d288e96b..df327c7d45a7 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -34,8 +34,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -1834,6 +1834,15 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTF_FORMSHADE: // Noop, this is the default in Writer. break; + case RTF_POSYT: + m_aStates.top().aFrame.nVertOrient = text::VertOrientation::TOP; + break; + case RTF_PHMRG: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::PAGE_PRINT_AREA; break; + case RTF_PVMRG: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::PAGE_PRINT_AREA; break; + case RTF_PHPG: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME; break; + case RTF_PVPG: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::PAGE_FRAME; break; + case RTF_PHCOL: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::FRAME; break; + case RTF_PVPARA: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::FRAME; break; default: #if OSL_DEBUG_LEVEL > 1 OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword)); -- cgit From 57f28d9900edc48cbe5239c2b8597f8f5c5c3edb Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 02:14:02 +0200 Subject: complete text::VertOrientation --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index df327c7d45a7..30fe732dd99a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1834,9 +1834,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTF_FORMSHADE: // Noop, this is the default in Writer. break; - case RTF_POSYT: - m_aStates.top().aFrame.nVertOrient = text::VertOrientation::TOP; - break; + case RTF_POSYT: m_aStates.top().aFrame.nVertOrient = text::VertOrientation::TOP; break; + case RTF_POSYB: m_aStates.top().aFrame.nVertOrient = text::VertOrientation::BOTTOM; break; + case RTF_POSYC: m_aStates.top().aFrame.nVertOrient = text::VertOrientation::CENTER; break; + case RTF_PHMRG: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::PAGE_PRINT_AREA; break; case RTF_PVMRG: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::PAGE_PRINT_AREA; break; case RTF_PHPG: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME; break; @@ -2418,6 +2419,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().aFrame.nX = TWIP_TO_MM100(nParam); break; case RTF_POSY: + m_aStates.top().aFrame.nVertOrient = text::VertOrientation::NONE; m_aStates.top().aFrame.nY = TWIP_TO_MM100(nParam); break; case RTF_DFRMTXTX: -- cgit From 7f3a3e02d723edf00e09dbb1d2020e0084545338 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 02:28:45 +0200 Subject: Tokenize text::HoriOrientation --- writerfilter/source/rtftok/rtfdocumentimpl.cxx | 10 ++++++++++ writerfilter/source/rtftok/rtfdocumentimpl.hxx | 1 + 2 files changed, 11 insertions(+) diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 30fe732dd99a..6f2a6a41ee88 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -726,6 +727,8 @@ void RTFDocumentImpl::checkChangedFrame() xShape->setSize(awt::Size(m_aStates.top().aFrame.nW, m_aStates.top().aFrame.nH)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorType")), uno::Any(m_aStates.top().aFrame.nAnchorType)); + if (m_aStates.top().aFrame.bPositionToggle) + xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("PositionToggle")), uno::Any(m_aStates.top().aFrame.bPositionToggle)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), uno::Any(m_aStates.top().aFrame.nHoriOrient)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation")), uno::Any(m_aStates.top().aFrame.nHoriOrientRelation)); xPropertySet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), uno::Any(sal_Int32(m_aStates.top().aFrame.nX))); @@ -1844,6 +1847,12 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTF_PVPG: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::PAGE_FRAME; break; case RTF_PHCOL: m_aStates.top().aFrame.nHoriOrientRelation = text::RelOrientation::FRAME; break; case RTF_PVPARA: m_aStates.top().aFrame.nVertOrientRelation = text::RelOrientation::FRAME; break; + + case RTF_POSXC: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::CENTER; break; + case RTF_POSXI: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::LEFT; m_aStates.top().aFrame.bPositionToggle = sal_True; break; + case RTF_POSXO: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::RIGHT; m_aStates.top().aFrame.bPositionToggle = sal_True; break; + case RTF_POSXL: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::LEFT; break; + case RTF_POSXR: m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::RIGHT; break; default: #if OSL_DEBUG_LEVEL > 1 OSL_TRACE("%s: TODO handle flag '%s'", OSL_THIS_FUNC, lcl_RtfToString(nKeyword)); @@ -2416,6 +2425,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) m_aStates.top().aFrame.nH = TWIP_TO_MM100(nParam); break; case RTF_POSX: + m_aStates.top().aFrame.nHoriOrient = text::HoriOrientation::NONE; m_aStates.top().aFrame.nX = TWIP_TO_MM100(nParam); break; case RTF_POSY: diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index a89d3daa6d5c..e5e25a5030f5 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -196,6 +196,7 @@ namespace writerfilter { sal_Int32 nLeftMargin, nRightMargin, nTopMargin, nBottomMargin; sal_Int16 nHoriOrient, nHoriOrientRelation, nVertOrient, nVertOrientRelation; sal_Int16 nAnchorType; + sal_Bool bPositionToggle; }; /// State of the parser, which gets saved / restored when changing groups. -- cgit From 13c00ce322e78eb4e0f50ab84ded19cd6aae1ded Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 18 Aug 2011 12:11:03 +0200 Subject: Enable the writerfilter-based RTF import in non-experimental mode Disable the unit tests in sw, as that would duplicate the unit test in writerfilter now. Do not remove the old filter yet, so this commit can be reverted later if needed. --- sw/qa/core/filters-test.cxx | 6 --- sw/source/filter/rtf/swparrtf.cxx | 6 +-- writerfilter/Library_writerfilter.mk | 1 - writerfilter/source/filter/RtfFilter.cxx | 63 ++++++++++++-------------------- 4 files changed, 24 insertions(+), 52 deletions(-) diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx index e9d2e4ac5633..c9616ec4be98 100644 --- a/sw/qa/core/filters-test.cxx +++ b/sw/qa/core/filters-test.cxx @@ -171,12 +171,6 @@ void FiltersTest::testCVEs() recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Staroffice XML (Writer)")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/xml/fail")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CXML")), false); - recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Rich Text Format")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/rtf/pass")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RTF")), true); - - recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Rich Text Format")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/rtf/fail")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RTF")), false); - - recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Rich Text Format")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/rtf/indeterminate")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RTF")), indeterminate); - recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/ww8/pass")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), true); recursiveScan(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/sw/qa/core/data/ww8/fail")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), false); diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 60e5d46e4502..9fe62ed49e33 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -103,7 +103,6 @@ #include #include #include -#include #include #include #include @@ -163,10 +162,7 @@ sal_uLong SwRTFReader::Read( SwDoc &rDoc, const String& /*rBaseURL*/, SwPaM& /*r extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportRTF() { - SvtMiscOptions aMiscOptions; - if (aMiscOptions.IsExperimentalMode()) - return new SwRTFReader(); - return new RtfReader(); + return new SwRTFReader(); } // Aufruf fuer die allg. Reader-Schnittstelle diff --git a/writerfilter/Library_writerfilter.mk b/writerfilter/Library_writerfilter.mk index 69ca17242a55..087ef262428d 100644 --- a/writerfilter/Library_writerfilter.mk +++ b/writerfilter/Library_writerfilter.mk @@ -60,7 +60,6 @@ $(eval $(call gb_Library_add_linked_libs,writerfilter,\ rtftok \ sal \ sot \ - svt \ tl \ utl \ $(gb_STDLIBS) \ diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx index af4589692436..764c8bbff111 100644 --- a/writerfilter/source/filter/RtfFilter.cxx +++ b/writerfilter/source/filter/RtfFilter.cxx @@ -36,7 +36,6 @@ #include #include #include -#include using namespace ::rtl; using namespace ::cppu; @@ -70,56 +69,40 @@ sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescri return xFltr->filter(aDescriptor); } - SvtMiscOptions aMiscOptions; - if (aMiscOptions.IsExperimentalMode() || !m_xDstDoc.is() ) + try { - try - { - MediaDescriptor aMediaDesc( aDescriptor ); + MediaDescriptor aMediaDesc( aDescriptor ); #ifdef DEBUG_IMPORT - OUString sURL = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() ); - ::std::string sURLc = OUStringToOString(sURL, RTL_TEXTENCODING_ASCII_US).getStr(); + OUString sURL = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() ); + ::std::string sURLc = OUStringToOString(sURL, RTL_TEXTENCODING_ASCII_US).getStr(); - writerfilter::TagLogger::Pointer_t dmapperLogger - (writerfilter::TagLogger::getInstance("DOMAINMAPPER")); - dmapperLogger->setFileName(sURLc); - dmapperLogger->startDocument(); + writerfilter::TagLogger::Pointer_t dmapperLogger + (writerfilter::TagLogger::getInstance("DOMAINMAPPER")); + dmapperLogger->setFileName(sURLc); + dmapperLogger->startDocument(); #endif - uno::Reference< io::XInputStream > xInputStream; + uno::Reference< io::XInputStream > xInputStream; - aMediaDesc.addInputStream(); - aMediaDesc[ MediaDescriptor::PROP_INPUTSTREAM() ] >>= xInputStream; + aMediaDesc.addInputStream(); + aMediaDesc[ MediaDescriptor::PROP_INPUTSTREAM() ] >>= xInputStream; - uno::Reference xFrame = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_FRAME(), - uno::Reference()); + uno::Reference xFrame = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_FRAME(), + uno::Reference()); - writerfilter::Stream::Pointer_t pStream( - new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, writerfilter::dmapper::DOCUMENT_RTF)); - writerfilter::rtftok::RTFDocument::Pointer_t const pDocument( - writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame)); - pDocument->resolve(*pStream); + writerfilter::Stream::Pointer_t pStream( + new writerfilter::dmapper::DomainMapper(m_xContext, xInputStream, m_xDstDoc, writerfilter::dmapper::DOCUMENT_RTF)); + writerfilter::rtftok::RTFDocument::Pointer_t const pDocument( + writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame)); + pDocument->resolve(*pStream); #ifdef DEBUG_IMPORT - dmapperLogger->endDocument(); + dmapperLogger->endDocument(); #endif - return sal_True; - } - catch( const uno::Exception& rEx) - { - return sal_False; - } + return sal_True; } - - // if not, then use the old importer - uno::Reference< lang::XMultiServiceFactory > xMSF(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW); - uno::Reference< uno::XInterface > xIfc( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.RtfImport" ))), uno::UNO_QUERY_THROW); - if (!xIfc.is()) - return sal_False; - uno::Reference< document::XImporter > xImprtr(xIfc, uno::UNO_QUERY_THROW); - uno::Reference< document::XFilter > xFltr(xIfc, uno::UNO_QUERY_THROW); - if (!xImprtr.is() || !xFltr.is()) + catch( const uno::Exception& rEx) + { return sal_False; - xImprtr->setTargetDocument(m_xDstDoc); - return xFltr->filter(aDescriptor); + } } void RtfFilter::cancel( ) throw (uno::RuntimeException) -- cgit