Kaydet (Commit) 2e11cb27 authored tarafından Miklos Vajna's avatar Miklos Vajna

Related: fdo#66040 RTF import: by default, do create a group shape for \shpgrp

The bugfix was just for the special case when we must create textframes
due to the contained tables, this one add support for the default case
when we want a real group shape.

Change-Id: I74b77b233235959266a24660c970a79e41d8b272
üst 6d191c06
{\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
}
}
}
{\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
}
......@@ -151,6 +151,7 @@ public:
void testN823675();
void testFdo47802();
void testFdo39001();
void testGroupshape();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
......@@ -287,6 +288,7 @@ void Test::run()
{"n823675.rtf", &Test::testN823675},
{"fdo47802.rtf", &Test::testFdo47802},
{"fdo39001.rtf", &Test::testFdo39001},
{"groupshape.rtf", &Test::testGroupshape},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
......@@ -1395,6 +1397,16 @@ void Test::testFdo39001()
CPPUNIT_ASSERT_EQUAL(3, getPages());
}
void Test::testGroupshape()
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
// There should be a single groupshape with 2 children.
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
uno::Reference<drawing::XShapes> xGroupshape(xDraws->getByIndex(0), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xGroupshape->getCount());
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -1682,7 +1682,18 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_SHPGRP:
{
RTFLookahead aLookahead(Strm(), m_pTokenizer->getGroupStart());
SAL_WARN_IF(!aLookahead.hasTable(), "writerfilter", "no table in groupshape, should create it!");
if (!aLookahead.hasTable())
{
uno::Reference<drawing::XShapes> xGroupShape(m_xModelFactory->createInstance("com.sun.star.drawing.GroupShape"), uno::UNO_QUERY);
uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, uno::UNO_QUERY);
if (xDrawSupplier.is())
{
uno::Reference<drawing::XShape> xShape(xGroupShape, uno::UNO_QUERY);
xDrawSupplier->getDrawPage()->add(xShape);
}
m_pSdrImport->pushParent(xGroupShape);
m_aStates.top().bCreatedShapeGroup = true;
}
m_aStates.top().nDestinationState = DESTINATION_SHAPEGROUP;
m_aStates.top().bInShapeGroup = true;
}
......@@ -4404,6 +4415,10 @@ int RTFDocumentImpl::popState()
case DESTINATION_MEQARR:
m_aMathBuffer.appendClosingTag(M_TOKEN(eqArr));
break;
case DESTINATION_SHAPEGROUP:
if (aState.bCreatedShapeGroup)
m_pSdrImport->popParent();
break;
default:
break;
}
......@@ -4764,7 +4779,8 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl)
bInListpicture(false),
bInBackground(false),
bHadShapeText(false),
bInShapeGroup(false)
bInShapeGroup(false),
bCreatedShapeGroup(false)
{
}
......
......@@ -263,6 +263,7 @@ namespace writerfilter {
bool bHadShapeText;
bool bInShapeGroup; ///< If we're inside a \shpgrp group.
bool bCreatedShapeGroup; ///< A GroupShape was created and pushed to the parent stack.
};
class RTFTokenizer;
......
......@@ -236,7 +236,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
break;
case ESCHER_ShpInst_Rectangle:
case ESCHER_ShpInst_TextBox:
if (!bClose)
// If we're inside a groupshape, can't use text frames.
if (!bClose && m_aParents.size() == 1)
{
createShape("com.sun.star.text.TextFrame", xShape, xPropertySet);
bTextFrame = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment