From e849f5d84a4bc35a241c2d1231b48c57c43ecce4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 26 Jul 2013 11:57:34 +0200 Subject: [PATCH] RTF import: fix groupshape import when shapes don't contain text Without this, the groupshape itself was created, not it had no child shapes. Change-Id: I5d3276498eb3ffe840f3d42dad16661849596da4 --- .../rtfimport/data/groupshape-notext.rtf | 71 +++++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 1 + .../source/rtftok/rtfdocumentimpl.cxx | 5 +- .../source/rtftok/rtfdocumentimpl.hxx | 1 + 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 sw/qa/extras/rtfimport/data/groupshape-notext.rtf diff --git a/sw/qa/extras/rtfimport/data/groupshape-notext.rtf b/sw/qa/extras/rtfimport/data/groupshape-notext.rtf new file mode 100644 index 000000000000..98d3c8b5f888 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/groupshape-notext.rtf @@ -0,0 +1,71 @@ +{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch0\stshfloch31506\stshfhich31506\stshfbi31506\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0 +{\shpgrp +{\*\shpinst\shpleft1058\shptop353\shpright3443\shpbottom1148\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026 +{\sp +{\sn groupLeft} +{\sv 2475} +} +{\sp +{\sn groupTop} +{\sv 1770} +} +{\sp +{\sn groupRight} +{\sv 4860} +} +{\sp +{\sn groupBottom} +{\sv 2565} +} +{\shp +{\*\shpinst\shplid1027 +{\sp +{\sn relLeft} +{\sv 2475} +} +{\sp +{\sn relTop} +{\sv 1770} +} +{\sp +{\sn relRight} +{\sv 3285} +} +{\sp +{\sn relBottom} +{\sv 2565} +} +{\sp +{\sn shapeType} +{\sv 2} +} +} +} +{\shp +{\*\shpinst\shplid1028 +{\sp +{\sn relLeft} +{\sv 3900} +} +{\sp +{\sn relTop} +{\sv 1770} +} +{\sp +{\sn relRight} +{\sv 4860} +} +{\sp +{\sn relBottom} +{\sv 2565} +} +{\sp +{\sn shapeType} +{\sv 5} +} +} +} +} +} +\par +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index a25564d2ba7f..eabdd69cfbd2 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -294,6 +294,7 @@ void Test::run() {"fdo47802.rtf", &Test::testFdo47802}, {"fdo39001.rtf", &Test::testFdo39001}, {"groupshape.rtf", &Test::testGroupshape}, + {"groupshape-notext.rtf", &Test::testGroupshape}, {"fdo66565.rtf", &Test::testFdo66565}, {"fdo54900.rtf", &Test::testFdo54900}, {"fdo64637.rtf", &Test::testFdo64637}, diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 840c2c263ee7..56e175952183 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1327,6 +1327,7 @@ int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword) case RTF_SHP: m_bNeedCrOrig = m_bNeedCr; m_aStates.top().nDestinationState = DESTINATION_SHAPE; + m_aStates.top().bInShape = true; break; case RTF_SHPINST: m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION; @@ -3930,7 +3931,8 @@ int RTFDocumentImpl::popState() break; case DESTINATION_PICPROP: case DESTINATION_SHAPEINSTRUCTION: - if (!m_bObject && !aState.bInListpicture && !m_aStates.top().bHadShapeText && !m_aStates.top().bInShapeGroup) + // Don't trigger a shape import in case we're only leaving the \shpinst of the groupshape itself. + if (!m_bObject && !aState.bInListpicture && !aState.bHadShapeText && !(aState.bInShapeGroup && !aState.bInShape)) m_pSdrImport->resolve(m_aStates.top().aShape, true); break; case DESTINATION_BOOKMARKSTART: @@ -4808,6 +4810,7 @@ RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl) bInBackground(false), bHadShapeText(false), bInShapeGroup(false), + bInShape(false), bCreatedShapeGroup(false), bStartedTrackchange(false) { diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index d55572e74491..86b6912f4df3 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 bInShape; ///< If we're inside a \shp group. bool bCreatedShapeGroup; ///< A GroupShape was created and pushed to the parent stack. bool bStartedTrackchange; ///< Track change is started, need to end it before popping. };