summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-07-08 16:21:28 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-07-08 17:16:10 +0200
commit2e11cb276e54c6fe4e903c7f44e36bc36798ba63 (patch)
tree60939cc9293be1aaca94f3f293008ea4eb7a7f40
parent6d191c06c737e4c7f3e2c5f8b871d1037b4ce783 (diff)
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
-rw-r--r--sw/qa/extras/rtfimport/data/groupshape.rtf76
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx12
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx20
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx1
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx3
5 files changed, 109 insertions, 3 deletions
diff --git a/sw/qa/extras/rtfimport/data/groupshape.rtf b/sw/qa/extras/rtfimport/data/groupshape.rtf
new file mode 100644
index 000000000000..b237570d0937
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/groupshape.rtf
@@ -0,0 +1,76 @@
+{\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
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index b22e72904049..3aa8d19e2109 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -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();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 73d06c43a941..1cd2ad2d9b88 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -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)
{
}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 5c39af1a115e..6d05b900c276 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -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;
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index e10457ba837f..0494ac04813c 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -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;