From a8ee2ee7529900628b1c533d77c039618917bc97 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 25 Jun 2013 14:47:48 +0200 Subject: fdo#66040 RTF import: initial groupshape support There are two cases here: if the shapes contain tables (or other Writer-specific features), we should use text frames and we should not create the actual group shape, as Writer textframes can't be part of such group shapes. The other case is when the shapes contain simple text, OTOH there are groupshape-level transformations defined, in that case we should choose drawinglayer rectangles and actually create a group shape. This commit implements support for the first case only. Change-Id: I9dc99b0711ce5c7a29ea0b14539df0121f9de3d0 --- sw/qa/extras/rtfimport/data/fdo66040.rtf | 85 ++++++++++++++++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 23 +++++++++ 2 files changed, 108 insertions(+) create mode 100644 sw/qa/extras/rtfimport/data/fdo66040.rtf (limited to 'sw') diff --git a/sw/qa/extras/rtfimport/data/fdo66040.rtf b/sw/qa/extras/rtfimport/data/fdo66040.rtf new file mode 100644 index 000000000000..e067f2386ff6 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo66040.rtf @@ -0,0 +1,85 @@ +{\rtf1 +\paperw16840\paperh11907\margl567\margr567\margt567\margb567 +{\shpgrp +{\*\shpinst\shpleft-201\shptop-585\shpright16112\shpbottom11321 +{\sp +{\sn groupLeft} +{\sv 288} +} +{\sp +{\sn groupTop} +{\sv -18} +} +{\sp +{\sn groupRight} +{\sv 16601} +} +{\sp +{\sn groupBottom} +{\sv 11888} +} +{\shp +{\*\shpinst +{\sp +{\sn relLeft} +{\sv 288} +} +{\sp +{\sn relTop} +{\sv -18} +} +{\sp +{\sn relRight} +{\sv 8225} +} +{\sp +{\sn relBottom} +{\sv 11888} +} +{\sp +{\sn shapeType} +{\sv 202} +} +{\shptxt foo\par +\pard\plain \intbl A\cell B\cell +{ +\trowd \irow0\irowband0\lastrow \ltrrow\ts32\trgaph108\trleft-108\trbrdrt\brdrs\brdrw10\brdrcf17 \trbrdrl\brdrs\brdrw10\brdrcf17 \trbrdrb\brdrs\brdrw10\brdrcf17 \trbrdrr\brdrs\brdrw10\brdrcf17 \trbrdrh +\brdrs\brdrw10\brdrcf17 \trbrdrv\brdrs\brdrw10\brdrcf17 \trftsWidth1\trftsWidthB3\trautofit1\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\tblrsid14568770\tbllkhdrrows\tbllkhdrcols\tbllknocolband\tblind0\tblindtype3 \clvertalt\clbrdrt +\brdrs\brdrw10\brdrcf17 \clbrdrl\brdrs\brdrw10\brdrcf17 \clbrdrb\brdrs\brdrw10\brdrcf17 \clbrdrr\brdrs\brdrw10\brdrcf17 \cltxlrtb\clftsWidth3\clwWidth1783\clshdrawnil \cellx1675\clvertalt\clbrdrt\brdrs\brdrw10\brdrcf17 \clbrdrl\brdrs\brdrw10\brdrcf17 +\clbrdrb\brdrs\brdrw10\brdrcf17 \clbrdrr\brdrs\brdrw10\brdrcf17 \cltxlrtb\clftsWidth3\clwWidth1784\clshdrawnil \cellx3459\row } +\pard +bar +\par +} +} +} +{\shp +{\*\shpinst +{\sp +{\sn relLeft} +{\sv 8664} +} +{\sp +{\sn relTop} +{\sv -18} +} +{\sp +{\sn relRight} +{\sv 16601} +} +{\sp +{\sn relBottom} +{\sv 11888} +} +{\sp +{\sn shapeType} +{\sv 202} +} +{\shptxt baz +} +} +} +} +} +\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 53be3b296884..a9c74b10e946 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -146,6 +146,7 @@ public: void testN825305(); void testParaBottomMargin(); void testN823655(); + void testFdo66040(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -278,6 +279,7 @@ void Test::run() {"n825305.rtf", &Test::testN825305}, {"para-bottom-margin.rtf", &Test::testParaBottomMargin}, {"n823655.rtf", &Test::testN823655}, + {"fdo66040.rtf", &Test::testFdo66040}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1332,6 +1334,27 @@ void Test::testN823655() CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates[0].Second.Value.get()); } +void Test::testFdo66040() +{ + uno::Reference xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + // This was 0 (no shapes were imported), we want two textframes. + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount()); + + // The second paragraph of the first shape should be actually a table, with "A" in its A1 cell. + uno::Reference xTextRange(xDraws->getByIndex(0), uno::UNO_QUERY); + uno::Reference xText = xTextRange->getText(); + uno::Reference xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString()); + + // Make sure the second shape has the correct position and size. + uno::Reference xShape(xDraws->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(14420), getProperty(xShape, "HoriOrientPosition")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1032), getProperty(xShape, "VertOrientPosition")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(14000), xShape->getSize().Width); + CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), xShape->getSize().Height); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit