summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-07-18 22:47:03 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-07-19 10:09:31 +0200
commit173d769a9d32af83ea75dcf4d23b7663a5f19cb9 (patch)
tree6dcbda20b6b571ca48170bb26084c2bf68cb32f8
parentc68afc22fe8b1f90033cbe7d328a74daeae18e22 (diff)
fdo#52066 fix RTF import of rectangle shape without text in it
We used to always add a paragraph on shapes, which breaks import of abused rectangle shapes with minimal height, used as lines. Change-Id: Ice240bad68bc030e7889c46f72c45646307f17e5
-rw-r--r--sw/qa/extras/rtfimport/data/fdo52066.rtf21
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx17
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx4
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx10
5 files changed, 48 insertions, 6 deletions
diff --git a/sw/qa/extras/rtfimport/data/fdo52066.rtf b/sw/qa/extras/rtfimport/data/fdo52066.rtf
new file mode 100644
index 000000000000..d293838926cb
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo52066.rtf
@@ -0,0 +1,21 @@
+{\rtf1
+{\shp
+{\*\shpinst\shpleft3381\shptop249\shpright11461\shpbottom268
+{\sp
+{\sn shapeType}
+{\sv 1}
+}
+{\sp
+{\sn fillColor}
+{\sv 0}
+}
+{\sp
+{\sn fillBackColor}
+{\sv 0}
+}
+}
+{\shprslt
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index cb5a584503e0..4aa2904fa453 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -97,6 +97,7 @@ public:
void testFdo50665();
void testFdo49659();
void testFdo46966();
+ void testFdo52066();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -137,6 +138,7 @@ public:
CPPUNIT_TEST(testFdo50665);
CPPUNIT_TEST(testFdo49659);
CPPUNIT_TEST(testFdo46966);
+ CPPUNIT_TEST(testFdo52066);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -811,6 +813,21 @@ void Test::testFdo46966()
CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(720)), nValue);
}
+void Test::testFdo52066()
+{
+ /*
+ * The problem was that the height of the shape was too big.
+ *
+ * xray ThisComponent.DrawPage(0).Size.Height
+ */
+ load("fdo52066.rtf");
+
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(19)), xShape->getSize().Height);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index c7b719ec97d4..37da9c015805 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3644,9 +3644,11 @@ void RTFDocumentImpl::setDestinationText(OUString& rString)
m_aStates.top().aDestinationText.append(rString);
}
-void RTFDocumentImpl::replayShapetext()
+bool RTFDocumentImpl::replayShapetext()
{
+ bool bRet = !m_aShapetextBuffer.empty();
replayBuffer(m_aShapetextBuffer);
+ return bRet;
}
bool RTFDocumentImpl::getSkipUnknown()
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 34dddd24d8fc..14ded59a416d 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -370,7 +370,7 @@ namespace writerfilter {
/// Resolve a picture: If not inline, then anchored.
int resolvePict(bool bInline);
void runBreak();
- void replayShapetext();
+ bool replayShapetext();
bool getSkipUnknown();
void setSkipUnknown(bool bSkipUnknown);
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 9ba957ea5665..ae7b14477ede 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -333,10 +333,12 @@ void RTFSdrImport::resolve(RTFShape& rShape)
// Send it to dmapper
m_rImport.Mapper().startShape(xShape);
m_rImport.Mapper().startParagraphGroup();
- m_rImport.replayShapetext();
- m_rImport.Mapper().startCharacterGroup();
- m_rImport.runBreak();
- m_rImport.Mapper().endCharacterGroup();
+ if (m_rImport.replayShapetext())
+ {
+ m_rImport.Mapper().startCharacterGroup();
+ m_rImport.runBreak();
+ m_rImport.Mapper().endCharacterGroup();
+ }
m_rImport.Mapper().endParagraphGroup();
m_rImport.Mapper().endShape();
}