sw/qa/extras/rtftok/data/fdo47036.rtf | 61 ++++++++ sw/qa/extras/rtftok/rtftok.cxx | 22 +++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 170 +++++++++++++++++-------- writerfilter/source/rtftok/rtfdocumentimpl.hxx | 32 +++- 4 files changed, 224 insertions(+), 61 deletions(-)
New commits: commit 0d9132c5046e15540abc20e45d64080708626441 Author: Miklos Vajna <vmik...@suse.cz> Date: Sat Mar 24 13:04:54 2012 +0100 fdo#47036 fix RTF import of shapes inside text frames at the start of the doc diff --git a/sw/qa/extras/rtftok/data/fdo47036.rtf b/sw/qa/extras/rtftok/data/fdo47036.rtf new file mode 100644 index 0000000..0b5602f --- /dev/null +++ b/sw/qa/extras/rtftok/data/fdo47036.rtf @@ -0,0 +1,61 @@ +{\rtf1 +\paperw11904\paperh16836\margl864\margr288\margt360\margb360\gutter0\ltrsect +\widowctrl\ftnbj\aenddoc\donotembedsysfont0\donotembedlingdata1\grfdocevents0\validatexml0\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\showxmlerrors0\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120 +\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale100\nolnhtadjtbl\rsidroot15426039 \fet0 +\ilfomacatclnup0\ltrpar \sectd \ltrsect\sbknone\linex0\sectdefaultcl\sftnbj +\pard\plain \ltrpar\qc \li0\ri0\nowidctlpar +\tx360\tx720\tx1080\tx1440\tx1800\tx2160\tx2520\tx2880\tx3240\tx3600\tx3960\tx4320\tx4680\tx5040\tx5400\tx5760\tx6120\tx6480\tx6840\tx7200\tx7560\tx7920\tx8280\tx8640\tx9000\tx9360\tx9720\pvpg\phpg\posx939 +\posy2714\absh-450\absw10080\wrapdefault\faauto\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 +{\rtlch\fcs1 \af0 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid1775824 +{\shp +{\*\shpinst\shpleft1074\shptop528\shpright11487\shpbottom1945\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz3\shplid1029 +{\sp +{\sn shapeType} +{\sv 75} +} +{\sp +{\sn fFlipH} +{\sv 0} +} +{\sp +{\sn fFlipV} +{\sv 0} +} +{\sp +{\sn pib} +{\sv +{\pict\picscalex92\picscaley92\piccropl0\piccropr0\piccropt0\piccropb0 +\picw20032\pich2725\picwgoal11357\pichgoal1545\pngblip\bliptag-1891142031 +{\*\blipuid 8f477671d3377e167ce61bb2e9de72f7} +47494638396110001000d5ff00000000ffffffc0c0c0555f00ffffaafcfcfcf6f6f6eaeaeae6e6e6e4e4e4e3e3e3c2c2c2c1c1c1bcbcbcb5b5b5b3b3b3b0b0b0adadada5a5a5a2a2a2a1a1a19f9f9f9494948a8a8a8888888686867b7b7b6c6c6c5c5c5c4e4e4e4b4b4b4747474646463d3d3d3c3c3c2e2e2e2525251b1b1b18181810101009090906060603030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021f90401000002002c0000000010001000000684408170482c0a06c8a4728924389f506833b281302a8e6b164b18103024c52111504cca67332102e0042e9a40d9319f8300a343c1200f54e47f7e2a00001e0b0a7d0d728a010d838400261a7c0d94947784252700127e9d159f6c8411140019080ea7a9a85f842122281612b1b3b25d6b1f29291d0fbbbdbc5d5e51c34e4cc64a46c94341003b +} +} +} +{\sp +{\sn posrelh} +{\sv 1} +} +{\sp +{\sn posrelv} +{\sv 1} +} +{\sp +{\sn fLayoutInCell} +{\sv 0} +} +{\sp +{\sn fBehindDocument} +{\sv 1} +} +{\sp +{\sn fLayoutInCell} +{\sv 0} +} +} +} +} +{\rtlch\fcs1 \ab\af1\afs33 \ltrch\fcs0 +\b\f1\fs33\cf1\insrsid15426039 Booking Advice} +{\rtlch\fcs1 \af1 \ltrch\fcs0 \f1\insrsid15426039 +\par } +} diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx index f4a0c4d..a47ca36 100644 --- a/sw/qa/extras/rtftok/rtftok.cxx +++ b/sw/qa/extras/rtftok/rtftok.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/table/BorderLineStyle.hpp> #include <com/sun/star/text/RelOrientation.hpp> #include <com/sun/star/text/SizeType.hpp> +#include <com/sun/star/text/TextContentAnchorType.hpp> #include <com/sun/star/text/XPageCursor.hpp> #include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> @@ -69,6 +70,7 @@ public: void testFdo43965(); void testN751020(); void testFdo47326(); + void testFdo47036(); CPPUNIT_TEST_SUITE(RtfModelTest); #if !defined(MACOSX) && !defined(WNT) @@ -84,6 +86,7 @@ public: CPPUNIT_TEST(testFdo43965); CPPUNIT_TEST(testN751020); CPPUNIT_TEST(testFdo47326); + CPPUNIT_TEST(testFdo47036); #endif CPPUNIT_TEST_SUITE_END(); @@ -398,6 +401,25 @@ void RtfModelTest::testFdo47326() CPPUNIT_ASSERT_EQUAL(19, getLength()); } +void RtfModelTest::testFdo47036() +{ + load(OUString(RTL_CONSTASCII_USTRINGPARAM("fdo47036.rtf"))); + + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + int nAtCharacter = 0; + for (int i = 0; i < xDraws->getCount(); ++i) + { + uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(i), uno::UNO_QUERY); + text::TextContentAnchorType eValue; + xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AnchorType"))) >>= eValue; + if (eValue == text::TextContentAnchorType_AT_CHARACTER) + nAtCharacter++; + } + // The image at the document start was ignored. + CPPUNIT_ASSERT_EQUAL(1, nAtCharacter); +} + CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index c7b70de..5daec32 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -3233,6 +3233,12 @@ int RTFDocumentImpl::popState() Mapper().startShape(xShape); Mapper().endShape(); } + else if (m_aStates.top().nDestinationState == DESTINATION_SHAPE && m_aStates.top().aFrame.inFrame()) + { + m_aStates.top().resetFrame(); + parBreak(); + m_bNeedPap = true; + } // See if we need to end a track change RTFValue::Pointer_t pTrackchange = m_aStates.top().aCharacterSprms.find(NS_ooxml::LN_trackchange); @@ -3460,6 +3466,11 @@ RTFFrame::RTFFrame(RTFParserState* pParserState) void RTFFrame::setSprm(Id nId, Id nValue) { + if (m_pParserState->m_pDocumentImpl->getFirstRun()) + { + m_pParserState->m_pDocumentImpl->checkFirstRun(); + m_pParserState->m_pDocumentImpl->setNeedPar(false); + } switch (nId) { case NS_sprm::LN_PDxaWidth: commit de0f33126d5dd92e2ea8b728dcb9dc7cd3b8995c Author: Miklos Vajna <vmik...@suse.cz> Date: Sat Mar 24 10:07:40 2012 +0100 rtftok: various refactoring To allow frame keywords at the start of the document, we need to: - a single setter method for all frame properties - make the parser state know about its document - make the frame know about its parser state diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index d378694..c7b70de 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -243,7 +243,7 @@ RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x m_xFrame(xFrame), m_xStatusIndicator(xStatusIndicator), m_nGroup(0), - m_aDefaultState(), + m_aDefaultState(this), m_bSkipUnknown(false), m_aFontEncodings(), m_aFontIndexes(), @@ -389,6 +389,16 @@ void RTFDocumentImpl::checkFirstRun() } } +bool RTFDocumentImpl::getFirstRun() +{ + return m_bFirstRun; +} + +void RTFDocumentImpl::setNeedPar(bool bNeedPar) +{ + m_bNeedPar = bNeedPar; +} + void RTFDocumentImpl::checkNeedPap() { if (m_bNeedPap) @@ -780,12 +790,12 @@ int RTFDocumentImpl::resolveChars(char ch) return 0; } -bool RTFDocumentImpl::inFrame() +bool RTFFrame::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; + return nW > 0 + || nH > 0 + || nX > 0 + || nY > 0; } void RTFDocumentImpl::text(OUString& rString) @@ -1073,7 +1083,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) m_aStates.top().nDestinationState = DESTINATION_LEVELNUMBERS; break; case RTF_SHPPICT: - m_aStates.top().aFrame = RTFFrame(); + m_aStates.top().resetFrame(); m_aStates.top().nDestinationState = DESTINATION_SHPPICT; break; case RTF_PICT: @@ -1344,7 +1354,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(); + m_bWasInFrame = m_aStates.top().aFrame.inFrame(); if (!m_bWasInFrame) m_bNeedPar = false; if (m_bHasPage) @@ -1730,7 +1740,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_aStates.top().resetFrame(); m_pCurrentBuffer = 0; break; case RTF_SECTD: @@ -1978,25 +1988,25 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTF_PNGBLIP: m_aStates.top().aPicture.nStyle = BMPSTYLE_PNG; break; - case RTF_POSYT: m_aStates.top().aFrame.nVertAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_top; break; - case RTF_POSYB: m_aStates.top().aFrame.nVertAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_bottom; break; - case RTF_POSYC: m_aStates.top().aFrame.nVertAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_center; break; - case RTF_POSYIN: m_aStates.top().aFrame.nVertAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_inside; break; - case RTF_POSYOUT: m_aStates.top().aFrame.nVertAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_outside; break; - case RTF_POSYIL: m_aStates.top().aFrame.nVertAlign = NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_inline; break; - - case RTF_PHMRG: m_aStates.top().aFrame.nHoriAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_margin; break; - case RTF_PVMRG: m_aStates.top().aFrame.nVertAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_margin; break; - case RTF_PHPG: m_aStates.top().aFrame.nHoriAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_page; break; - case RTF_PVPG: m_aStates.top().aFrame.nVertAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_page; break; - case RTF_PHCOL: m_aStates.top().aFrame.nHoriAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_text; break; - case RTF_PVPARA: m_aStates.top().aFrame.nVertAnchor = NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_text; break; - - case RTF_POSXC: m_aStates.top().aFrame.nHoriAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_center; break; - case RTF_POSXI: m_aStates.top().aFrame.nHoriAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_inside; break; - case RTF_POSXO: m_aStates.top().aFrame.nHoriAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_outside; break; - case RTF_POSXL: m_aStates.top().aFrame.nHoriAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_left; break; - case RTF_POSXR: m_aStates.top().aFrame.nHoriAlign = NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_right; break; + case RTF_POSYT: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_top); break; + case RTF_POSYB: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_bottom); break; + case RTF_POSYC: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_center); break; + case RTF_POSYIN: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_inside); break; + case RTF_POSYOUT: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_outside); break; + case RTF_POSYIL: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_inline); break; + + case RTF_PHMRG: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_margin); break; + case RTF_PVMRG: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_margin); break; + case RTF_PHPG: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_page); break; + case RTF_PVPG: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_page); break; + case RTF_PHCOL: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_text); break; + case RTF_PVPARA: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_text); break; + + case RTF_POSXC: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_center); break; + case RTF_POSXI: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_inside); break; + case RTF_POSXO: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_outside); break; + case RTF_POSXL: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_left); break; + case RTF_POSXR: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_right); break; case RTF_DPLINE: { @@ -2132,21 +2142,21 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) return 0; // Frame size / position. - sal_Int32 *pSprm = 0; + Id nId = 0; switch (nKeyword) { - case RTF_ABSW: pSprm = &m_aStates.top().aFrame.nW; break; - case RTF_ABSH: pSprm = &m_aStates.top().aFrame.nH; break; - case RTF_POSX: pSprm = &m_aStates.top().aFrame.nX; m_aStates.top().aFrame.nHoriAlign = 0; break; - case RTF_POSY: pSprm = &m_aStates.top().aFrame.nY; m_aStates.top().aFrame.nVertAlign = 0; break; + case RTF_ABSW: nId = NS_sprm::LN_PDxaWidth; break; + case RTF_ABSH: nId = NS_sprm::LN_PWHeightAbs; break; + case RTF_POSX: nId = NS_ooxml::LN_CT_FramePr_x; m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, 0); break; + case RTF_POSY: nId = NS_ooxml::LN_CT_FramePr_y; m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, 0); break; default: break; } - if (pSprm) + if (nId > 0) { m_bNeedPap = true; // Don't try to support text frames inside tables for now. if (m_pCurrentBuffer != &m_aTableBuffer) - *pSprm = nParam; + m_aStates.top().aFrame.setSprm(nId, nParam); return 0; } @@ -2635,26 +2645,27 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam) lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_endnotePr, NS_ooxml::LN_EG_FtnEdnNumProps_numStart, pIntValue); break; case RTF_DFRMTXTX: - m_aStates.top().aFrame.nHoriPadding = nParam; + m_aStates.top().aFrame.setSprm(NS_sprm::LN_PDxaFromText, nParam); break; case RTF_DFRMTXTY: - m_aStates.top().aFrame.nVertPadding = nParam; + m_aStates.top().aFrame.setSprm(NS_sprm::LN_PDyaFromText, nParam); break; case RTF_DXFRTEXT: - m_aStates.top().aFrame.nVertPadding = m_aStates.top().aFrame.nHoriPadding = nParam; + m_aStates.top().aFrame.setSprm(NS_sprm::LN_PDxaFromText, nParam); + m_aStates.top().aFrame.setSprm(NS_sprm::LN_PDyaFromText, nParam); break; case RTF_FLYVERT: { RTFVertOrient aVertOrient(nParam); - m_aStates.top().aFrame.nVertAlign = aVertOrient.GetAlign(); - m_aStates.top().aFrame.nVertAnchor = aVertOrient.GetAnchor(); + m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, aVertOrient.GetAlign()); + m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor, aVertOrient.GetAnchor()); } break; case RTF_FLYHORZ: { RTFHoriOrient aHoriOrient(nParam); - m_aStates.top().aFrame.nHoriAlign = aHoriOrient.GetAlign(); - m_aStates.top().aFrame.nHoriAnchor = aHoriOrient.GetAnchor(); + m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, aHoriOrient.GetAlign()); + m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor, aHoriOrient.GetAnchor()); } break; case RTF_FLYANCHOR: @@ -2792,7 +2803,7 @@ int RTFDocumentImpl::pushState() checkUnicode(); m_nGroupStartPos = Strm().Tell(); - RTFParserState aState; + RTFParserState aState(this); if (m_aStates.empty()) aState = m_aDefaultState; else @@ -2879,7 +2890,6 @@ int RTFDocumentImpl::popState() bool bPopShapeProperties = false; bool bPopPictureProperties = false; bool bFaltEnd = false; - RTFFrame aFrame; bool bPopFrame = false; RTFParserState aState(m_aStates.top()); @@ -3206,10 +3216,7 @@ int RTFDocumentImpl::popState() } else if (m_aStates.top().nDestinationState == DESTINATION_FLYMAINCONTENT || m_aStates.top().nDestinationState == DESTINATION_SHPPICT) - { - aFrame = m_aStates.top().aFrame; bPopFrame = true; - } else if (m_aStates.top().nDestinationState == DESTINATION_DRAWINGOBJECT && m_aStates.top().aDrawingObject.xShape.is()) { RTFDrawingObject& rDrawing = m_aStates.top().aDrawingObject; @@ -3282,7 +3289,7 @@ int RTFDocumentImpl::popState() else if (bFaltEnd) m_aStates.top().aTableSprms = aSprms; else if (bPopFrame) - m_aStates.top().aFrame = aFrame; + m_aStates.top().aFrame = aState.aFrame; if (bPopPictureProperties) { m_aStates.top().aPicture = aPicture; @@ -3365,8 +3372,9 @@ void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex) } } -RTFParserState::RTFParserState() - : nInternalState(INTERNAL_NORMAL), +RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl) + : m_pDocumentImpl(pDocumentImpl), + nInternalState(INTERNAL_NORMAL), nDestinationState(DESTINATION_NORMAL), nBorderState(BORDER_NONE), aTableSprms(), @@ -3394,7 +3402,7 @@ RTFParserState::RTFParserState() aPicture(), aShape(), aDrawingObject(), - aFrame(), + aFrame(this), nCellX(0), nCells(0), bIsCjk(false), @@ -3406,6 +3414,11 @@ RTFParserState::RTFParserState() { } +void RTFParserState::resetFrame() +{ + aFrame = RTFFrame(this); +} + RTFColorTableEntry::RTFColorTableEntry() : nRed(0), nGreen(0), @@ -3429,8 +3442,9 @@ RTFPicture::RTFPicture() { } -RTFFrame::RTFFrame() - : nX(0), +RTFFrame::RTFFrame(RTFParserState* pParserState) + : m_pParserState(pParserState), + nX(0), nY(0), nW(0), nH(0), @@ -3444,6 +3458,45 @@ RTFFrame::RTFFrame() { } +void RTFFrame::setSprm(Id nId, Id nValue) +{ + switch (nId) + { + case NS_sprm::LN_PDxaWidth: + nW = nValue; + break; + case NS_sprm::LN_PWHeightAbs: + nH = nValue; + break; + case NS_ooxml::LN_CT_FramePr_x: + nX = nValue; + break; + case NS_ooxml::LN_CT_FramePr_y: + nY = nValue; + break; + case NS_sprm::LN_PDxaFromText: + nHoriPadding = nValue; + break; + case NS_sprm::LN_PDyaFromText: + nVertPadding = nValue; + break; + case NS_ooxml::LN_CT_FramePr_xAlign: + nHoriAlign = nValue; + break; + case NS_ooxml::LN_CT_FramePr_hAnchor: + nHoriAnchor = nValue; + break; + case NS_ooxml::LN_CT_FramePr_yAlign: + nVertAlign = nValue; + break; + case NS_ooxml::LN_CT_FramePr_vAnchor: + nVertAnchor = nValue; + break; + default: + break; + } +} + RTFSprms RTFFrame::getSprms() { RTFSprms sprms; diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 3644375..bd2a701 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -204,26 +204,40 @@ namespace writerfilter { RTFBmpStyles nStyle; }; + class RTFParserState; + /// Stores the properties of a frame class RTFFrame { - public: - RTFFrame(); + private: + RTFParserState* m_pParserState; sal_Int32 nX, nY, nW, nH; sal_Int32 nHoriPadding, nVertPadding; sal_Int32 nHoriAlign, nHoriAnchor, nVertAlign, nVertAnchor; + public: + RTFFrame(RTFParserState* pParserState); sal_Int16 nAnchorType; /// Convert the stored properties to Sprms RTFSprms getSprms(); + /// Store a property + void setSprm(Id nId, Id nValue); bool hasProperties(); + /// If we got tokens indicating we're in a frame. + bool inFrame(); }; + class RTFDocumentImpl; + /// State of the parser, which gets saved / restored when changing groups. class RTFParserState { public: - RTFParserState(); + RTFParserState(RTFDocumentImpl* pDocumentImpl); + /// Resets aFrame. + void resetFrame(); + + RTFDocumentImpl* m_pDocumentImpl; RTFInternalState nInternalState; RTFDesitnationState nDestinationState; RTFBorderState nBorderState; @@ -343,6 +357,13 @@ namespace writerfilter { int dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam); int dispatchValue(RTFKeyword nKeyword, int nParam); + /// If this is the first run of the document, starts the initial paragraph. + void checkFirstRun(); + /// If the initial paragraph is started. + bool getFirstRun(); + /// If we need to add a dummy paragraph before a section break. + void setNeedPar(bool bNeedPar); + private: SvStream& Strm(); sal_uInt32 getColorTable(sal_uInt32 nIndex); @@ -357,13 +378,9 @@ namespace writerfilter { void text(rtl::OUString& rString); void parBreak(); void tableBreak(); - /// If this is the first run of the document, starts the initial paragraph. - void checkFirstRun(); void checkNeedPap(); void sectBreak(bool bFinal); void replayBuffer(RTFBuffer_t& rBuffer); - /// If we got tokens indicating we're in a frame. - bool inFrame(); /// If we have some unicode or hex characters to send. void checkUnicode(bool bUnicode = true, bool bHex = true); @@ -395,7 +412,6 @@ namespace writerfilter { bool m_bNeedPap; /// If we need to emit a CR at the end of substream. bool m_bNeedCr; - /// If we need to add a dummy paragraph before a section break. bool m_bNeedPar; /// The list table and list override table combined. RTFSprms m_aListTableSprms; _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits