[Libreoffice-commits] .: sw/qa writerfilter/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Thu Jul 19 01:12:43 PDT 2012
sw/qa/extras/rtfimport/data/fdo52066.rtf | 21 +++++++++++++++++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 17 +++++++++++++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 4 +++-
writerfilter/source/rtftok/rtfdocumentimpl.hxx | 2 +-
writerfilter/source/rtftok/rtfsdrimport.cxx | 10 ++++++----
5 files changed, 48 insertions(+), 6 deletions(-)
New commits:
commit 173d769a9d32af83ea75dcf4d23b7663a5f19cb9
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Jul 18 22:47:03 2012 +0200
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
diff --git a/sw/qa/extras/rtfimport/data/fdo52066.rtf b/sw/qa/extras/rtfimport/data/fdo52066.rtf
new file mode 100644
index 0000000..d293838
--- /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 cb5a584..4aa2904 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 c7b719e..37da9c0 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 34dddd2..14ded59 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 9ba957e..ae7b144 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();
}
More information about the Libreoffice-commits
mailing list