diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-08-13 12:23:05 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-08-13 12:36:44 +0200 |
commit | ad72a47dbd16f65316432df71dffe3b9b835fcc7 (patch) | |
tree | f0fb19a68b96f9b5493aadef947e8f1dfc1dcc05 | |
parent | 462907d48f18c8dab4f705203c840dee3253d268 (diff) |
fdo#47495 fix RTF import of multiple shapes inside textframes
Change-Id: Iee8541ff9e88139648d45f08968476f2b1d4e1b3
-rw-r--r-- | sw/qa/extras/rtfimport/data/fdo47495.rtf | 164 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 9 | ||||
-rw-r--r-- | sw/qa/extras/swmodeltestbase.hxx | 15 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 5 |
4 files changed, 192 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo47495.rtf b/sw/qa/extras/rtfimport/data/fdo47495.rtf new file mode 100644 index 000000000000..d7a7ca6c87c5 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo47495.rtf @@ -0,0 +1,164 @@ +{\rtf1\adeflang1025\ansi\ansicpg1251\uc1\adeff31507\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi31507\deflang1049\deflangfe1049\themelang1049\themelangfe0\themelangcs0
+\pard \ltrpar\qc \li0\ri0\nowidctlpar\pvpg\phpg\posx632\posy2159\absh-139\absw10653\wrapdefault\faauto\rin0\lin0\itap0
+{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1024\langfe1024\noproof\insrsid2168934
+{\shp
+{\*\shpinst\shpleft420\shptop16200\shpright11460\shpbottom16200\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 20}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn lineWidth}
+{\sv 0}
+}
+{\sp
+{\sn fShadow}
+{\sv 0}
+}
+{\sp
+{\sn posrelh}
+{\sv 1}
+}
+{\sp
+{\sn posrelv}
+{\sv 1}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 0}
+}
+{\sp
+{\sn fBehindDocument}
+{\sv 1}
+}
+{\sp
+{\sn fPseudoInline}
+{\sv 0}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 0}
+}
+}
+{\shprslt
+{\*\do\dobxpage\dobypage\dodhgt0\dpline\dpptx0\dppty0\dpptx11040\dppty0\dpx420\dpy16200\dpxsize11040\dpysize0\dplinew0\dplinecor0\dplinecog0\dplinecob0}
+}
+}
+{\shp
+{\*\shpinst\shpleft476\shptop4742\shpright11298\shpbottom4952\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz1\shplid1027
+{\sp
+{\sn shapeType}
+{\sv 1}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn fFilled}
+{\sv 0}
+}
+{\sp
+{\sn lineWidth}
+{\sv 0}
+}
+{\sp
+{\sn fShadow}
+{\sv 0}
+}
+{\sp
+{\sn posrelh}
+{\sv 1}
+}
+{\sp
+{\sn posrelv}
+{\sv 1}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 0}
+}
+{\sp
+{\sn fBehindDocument}
+{\sv 1}
+}
+{\sp
+{\sn fPseudoInline}
+{\sv 0}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 0}
+}
+}
+{\shprslt
+{\*\do\dobxpage\dobypage\dodhgt1\dprect\dpx476\dpy4742\dpxsize10822\dpysize210
+\dpfillfgcr255\dpfillfgcg255\dpfillfgcb255\dpfillbgcr255\dpfillbgcg255\dpfillbgcb255\dpfillpat0\dplinew0\dplinecor0\dplinecog0\dplinecob0}
+}
+}
+{\shp
+{\*\shpinst\shpleft8626\shptop4742\shpright8626\shpbottom4953\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz2\shplid1028
+{\sp
+{\sn shapeType}
+{\sv 20}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn lineWidth}
+{\sv 0}
+}
+{\sp
+{\sn fShadow}
+{\sv 0}
+}
+{\sp
+{\sn posrelh}
+{\sv 1}
+}
+{\sp
+{\sn posrelv}
+{\sv 1}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 0}
+}
+{\sp
+{\sn fBehindDocument}
+{\sv 1}
+}
+{\sp
+{\sn fPseudoInline}
+{\sv 0}
+}
+{\sp
+{\sn fLayoutInCell}
+{\sv 0}
+}
+}
+{\shprslt
+{\*\do\dobxpage\dobypage\dodhgt2\dpline\dpptx0\dppty0\dpptx0\dppty211\dpx8626\dpy4742\dpxsize0\dpysize211\dplinew0\dplinecor0\dplinecog0\dplinecob0}
+}
+}
+}
+\pard \par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 92d306c85e04..e153f01b8ddc 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -103,6 +103,7 @@ public: void testFdo36089(); void testFdo49892(); void testFdo48446(); + void testFdo47495(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -148,6 +149,7 @@ public: CPPUNIT_TEST(testFdo36089); CPPUNIT_TEST(testFdo49892); CPPUNIT_TEST(testFdo48446); + CPPUNIT_TEST(testFdo47495); #endif CPPUNIT_TEST_SUITE_END(); @@ -896,6 +898,13 @@ void Test::testFdo48446() getParagraph(1, aExpected); } +void Test::testFdo47495() +{ + load("fdo47495.rtf"); + // Used to have 4 paragraphs, as a result the original bugdoc had 2 pages instead of 1. + CPPUNIT_ASSERT_EQUAL(2, getParagraphs()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/swmodeltestbase.hxx b/sw/qa/extras/swmodeltestbase.hxx index 9210fa8b1d22..11669fb834b7 100644 --- a/sw/qa/extras/swmodeltestbase.hxx +++ b/sw/qa/extras/swmodeltestbase.hxx @@ -162,6 +162,21 @@ protected: return data; } + /// Get number of paragraphs of the document. + int getParagraphs() + { + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + int nRet = 0; + while (xParaEnum->hasMoreElements()) + { + xParaEnum->nextElement(); + nRet++; + } + return nRet; + } + // Get paragraph (counted from 1), optionally check it contains the given text. uno::Reference< text::XTextRange > getParagraph( int number, OUString content = OUString() ) const { diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 2d66ed37b2d4..f27050a9915c 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -3621,6 +3621,8 @@ int RTFDocumentImpl::popState() { m_aStates.top().resetFrame(); parBreak(); + // Save this state for later use, so we only reset frame status only for the first shape inside a frame. + aState = m_aStates.top(); m_bNeedPap = true; } break; @@ -3863,7 +3865,8 @@ int RTFDocumentImpl::popState() m_aStates.top().aCharacterAttributes = aState.aCharacterAttributes; } else if (aState.nDestinationState == DESTINATION_FLYMAINCONTENT || - aState.nDestinationState == DESTINATION_SHPPICT) + aState.nDestinationState == DESTINATION_SHPPICT || + aState.nDestinationState == DESTINATION_SHAPE) m_aStates.top().aFrame = aState.aFrame; if (m_pCurrentBuffer == &m_aSuperBuffer) { |