summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-10-19 12:06:34 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-10-19 12:37:30 +0200
commit1becc60df9caa9fef5011ae877c832fe8bcefb6c (patch)
treeb0bfc401c6f184792806c7868b1e57aa840698a5
parent9e51601833718b529fe2fe5446ec0470d4ee5173 (diff)
import RTF_DPPOLYLINE
Change-Id: I65f1ddb9d0d691c126c8e94b2e60c8309b0d33ff
-rw-r--r--sw/qa/extras/rtfimport/data/dppolyline.rtf6
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx11
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx34
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx2
4 files changed, 52 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfimport/data/dppolyline.rtf b/sw/qa/extras/rtfimport/data/dppolyline.rtf
new file mode 100644
index 000000000000..0f6b8ce3d626
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/dppolyline.rtf
@@ -0,0 +1,6 @@
+{\rtf1
+{\*\do\dobxpage\dobypara\dodhgt8192\dppolyline\dppolycount2\dpptx11\dppty11\dpptx11\dppty209\dpx10885\dpy8458\dpxsize22\dpysize221}
+{\*\do\dobxpage\dobypara\dodhgt8192\dppolyline\dppolycount2\dpptx1258\dppty11\dpptx11\dppty11\dpx9637\dpy8657\dpxsize1269\dpysize22}
+{\*\do\dobxpage\dobypara\dodhgt8192\dppolyline\dppolycount2\dpptx11\dppty11\dpptx294\dppty68\dpx9637\dpy8657\dpxsize306\dpysize79}
+{\*\do\dobxpage\dobypara\dodhgt8192\dppolyline\dppolycount2\dpptx11\dppty68\dpptx294\dppty11\dpx9637\dpy8600\dpxsize306\dpysize79}
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 1ebadad841e7..9db7579be6a7 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -120,6 +120,7 @@ public:
void testDoDhgt();
void testDplinehollow();
void testLeftmarginDefault();
+ void testDppolyline();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -178,6 +179,7 @@ public:
CPPUNIT_TEST(testDoDhgt);
CPPUNIT_TEST(testDplinehollow);
CPPUNIT_TEST(testLeftmarginDefault);
+ CPPUNIT_TEST(testDppolyline);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -945,6 +947,15 @@ void Test::testLeftmarginDefault()
CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), getProperty<sal_Int32>(getStyles("PageStyles")->getByName("Default"), "LeftMargin"));
}
+void Test::testDppolyline()
+{
+ // This was completely ignored, for now, just make sure we have all 4 lines.
+ load("dppolyline.rtf");
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDraws->getCount());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 19d146571a6c..452c107f1fc1 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2273,6 +2273,7 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_DPRECT:
case RTF_DPELLIPSE:
case RTF_DPTXBX:
+ case RTF_DPPOLYLINE:
{
sal_Int32 nType = 0;
switch (nKeyword)
@@ -2280,6 +2281,10 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_DPLINE:
m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.drawing.LineShape"), uno::UNO_QUERY);
break;
+ case RTF_DPPOLYLINE:
+ // The reason this is not a simple CustomShape is that in the old syntax we have no ViewBox info.
+ m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.drawing.PolyLineShape"), uno::UNO_QUERY);
+ break;
case RTF_DPRECT:
nType = ESCHER_ShpInst_Rectangle;
break;
@@ -3143,6 +3148,32 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
case RTF_DODHGT:
m_aStates.top().aDrawingObject.nDhgt = nParam;
break;
+ case RTF_DPPOLYCOUNT:
+ if (nParam >= 0)
+ {
+ m_aStates.top().aDrawingObject.nPolyLineCount = nParam;
+ m_aStates.top().aDrawingObject.aPolyLinePoints.realloc(nParam);
+ }
+ break;
+ case RTF_DPPTX:
+ {
+ RTFDrawingObject& rDrawingObject = m_aStates.top().aDrawingObject;
+ rDrawingObject.aPolyLinePoints[rDrawingObject.aPolyLinePoints.getLength() - rDrawingObject.nPolyLineCount].X = TWIP_TO_MM100(nParam);
+ }
+ break;
+ case RTF_DPPTY:
+ {
+ RTFDrawingObject& rDrawingObject = m_aStates.top().aDrawingObject;
+ rDrawingObject.aPolyLinePoints[rDrawingObject.aPolyLinePoints.getLength() - rDrawingObject.nPolyLineCount].Y = TWIP_TO_MM100(nParam);
+ rDrawingObject.nPolyLineCount--;
+ if (rDrawingObject.nPolyLineCount == 0)
+ {
+ uno::Sequence< uno::Sequence<awt::Point> >aPointSequenceSequence(1);
+ aPointSequenceSequence[0] = rDrawingObject.aPolyLinePoints;
+ rDrawingObject.xPropertySet->setPropertyValue("PolyPolygon", uno::Any(aPointSequenceSequence));
+ }
+ }
+ break;
default:
SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
aSkip.setParsed(false);
@@ -4133,7 +4164,8 @@ RTFDrawingObject::RTFDrawingObject()
nFillColorB(0),
bHasFillColor(false),
nDhgt(0),
- nFLine(-1)
+ nFLine(-1),
+ nPolyLineCount(0)
{
}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 7f0988c20263..43dc7483313b 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -274,6 +274,8 @@ namespace writerfilter {
bool bHasFillColor;
sal_Int32 nDhgt;
sal_Int32 nFLine;
+ sal_Int32 nPolyLineCount;
+ uno::Sequence<awt::Point> aPolyLinePoints;
};
/// Stores the properties of a picture.