[Libreoffice-commits] core.git: Branch 'distro/suse/suse-4.0' - 2 commits - sw/qa writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Mon Jun 24 07:50:18 PDT 2013
sw/qa/extras/rtfimport/data/n823655.rtf | 48 +++++++++++++++++++++
sw/qa/extras/rtfimport/data/para-bottom-margin.rtf | 14 ++++++
sw/qa/extras/rtfimport/rtfimport.cxx | 34 ++++++++++++++
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 3 +
writerfilter/source/rtftok/rtfsdrimport.cxx | 14 +++---
5 files changed, 106 insertions(+), 7 deletions(-)
New commits:
commit 48a25944a8bc00f4cac90c602c01f9f1ecd63256
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Jun 24 14:13:39 2013 +0200
bnc#823655 fix RTF import of freeform shape coordinates
E.g. 0,1 was imported as 1,0, as we did not differentiate between not
having the coordinate yet and having it as zero.
Change-Id: Ia5fbbcc791dc9c6866ffd4c146793690661d81b4
(cherry picked from commit ddddfe8d6ffa05c467bddb3480e43d7043a3d3c9)
diff --git a/sw/qa/extras/rtfimport/data/n823655.rtf b/sw/qa/extras/rtfimport/data/n823655.rtf
new file mode 100644
index 0000000..94e73ed
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/n823655.rtf
@@ -0,0 +1,48 @@
+{\rtf1
+foo
+{\shp
+{\*\shpinst\shpleft450\shptop1904\shpright11595\shpbottom2190\shpfhdr0\shpbxpage\shpbxignore\shpbypage\shpbyignore\shpwr3\shpwrk0\shpfblwtxt1\shpz0\shplid1026
+{\sp
+{\sn shapeType}
+{\sv 0}
+}
+{\sp
+{\sn fFlipH}
+{\sv 0}
+}
+{\sp
+{\sn fFlipV}
+{\sv 0}
+}
+{\sp
+{\sn geoRight}
+{\sv 11145}
+}
+{\sp
+{\sn geoBottom}
+{\sv 286}
+}
+{\sp
+{\sn pVerticies}
+{\sv 8;4;(0,286);(11145,286);(11145,1);(0,1)}
+}
+{\sp
+{\sn pSegmentInfo}
+{\sv 2;5;16384;1;1;1;32768}
+}
+{\sp
+{\sn fFillOK}
+{\sv 1}
+}
+{\sp
+{\sn fillColor}
+{\sv 15000804}
+}
+{\sp
+{\sn fFilled}
+{\sv 1}
+}
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index d3362da..84d59c0 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
@@ -151,6 +152,7 @@ public:
void testFdo64671();
void testN825305();
void testParaBottomMargin();
+ void testN823655();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -272,6 +274,7 @@ void Test::run()
{"fdo64671.rtf", &Test::testFdo64671},
{"n825305.rtf", &Test::testN825305},
{"para-bottom-margin.rtf", &Test::testParaBottomMargin},
+ {"n823655.rtf", &Test::testN823655},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{
@@ -1252,6 +1255,29 @@ void Test::testParaBottomMargin()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
}
+void Test::testN823655()
+{
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xDraws->getByIndex(0), "CustomShapeGeometry");
+ uno::Sequence<beans::PropertyValue> aPathProps;
+ for (int i = 0; i < aProps.getLength(); ++i)
+ {
+ const beans::PropertyValue& rProp = aProps[i];
+ if (rProp.Name == "Path")
+ aPathProps = rProp.Value.get< uno::Sequence<beans::PropertyValue> >();
+ }
+ uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aCoordinates;
+ for (int i = 0; i < aPathProps.getLength(); ++i)
+ {
+ const beans::PropertyValue& rProp = aPathProps[i];
+ if (rProp.Name == "Coordinates")
+ aCoordinates = rProp.Value.get< uno::Sequence<drawing::EnhancedCustomShapeParameterPair> >();
+ }
+ // The first coordinate pair of this freeform shape was 286,0 instead of 0,286.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(286), aCoordinates[0].Second.Value.get<sal_Int32>());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 3bb7af9..62a6cb5 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -192,19 +192,19 @@ void RTFSdrImport::resolve(RTFShape& rShape)
// The coordinates are in an (x,y) form.
aToken = aToken.copy(1, aToken.getLength() - 2);
sal_Int32 nI = 0;
- sal_Int32 nX = 0;
- sal_Int32 nY = 0;
+ boost::optional<sal_Int32> oX;
+ boost::optional<sal_Int32> oY;
do
{
OUString aPoint = aToken.getToken(0, ',', nI);
- if (!nX)
- nX = aPoint.toInt32();
+ if (!oX)
+ oX.reset(aPoint.toInt32());
else
- nY = aPoint.toInt32();
+ oY.reset(aPoint.toInt32());
}
while (nI >= 0);
- aCoordinates[nIndex].First.Value <<= nX;
- aCoordinates[nIndex].Second.Value <<= nY;
+ aCoordinates[nIndex].First.Value <<= *oX;
+ aCoordinates[nIndex].Second.Value <<= *oY;
nIndex++;
}
}
commit 59d70e958005cd0ca93eb5def4fae7174bc9fb65
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Jun 21 15:48:39 2013 +0200
bnc#823655 RTF import: ignore styles without a type
Regression from 29dcdf6b56f8dbc1b7de0478afb04122f8dbf0f9.
Change-Id: I970c0e7b3652d7e6f093815b90e04e0c45904b28
(cherry picked from commit c6a941b51b68eb097d4d43323b39ff1aba4c753e)
diff --git a/sw/qa/extras/rtfimport/data/para-bottom-margin.rtf b/sw/qa/extras/rtfimport/data/para-bottom-margin.rtf
new file mode 100644
index 0000000..7bc5051
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/para-bottom-margin.rtf
@@ -0,0 +1,14 @@
+{\rtf1
+{\stylesheet
+{\ql \li0\ri0\sa200\sl276\slmult1
+\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang4105\langfe4105\loch\f31506\hich\af31506\dbch\af31505\cgrid\langnp4105\langfenp4105 \snext0 \sqformat \spriority0 Normal;}
+{\*\cs10 \additive \ssemihidden \sunhideused \spriority1 Default Paragraph Font;}
+{\*
+\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tblind0\tblindtype3\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\sa200\sl276\slmult1
+\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \fs22\lang4105\langfe4105\loch\f31506\hich\af31506\dbch\af31505\cgrid\langnp4105\langfenp4105 \snext11 \ssemihidden \sunhideused
+Normal Table;}
+}
+\pard \ltrpar\ql \li720\ri0\sb1\sl-179\slmult0\nowidctlpar\tx9924\wrapdefault\faauto\rin0\lin720\itap0
+{\rtlch\fcs1 \af0\afs16 \ltrch\fcs0 \f0\fs16\expnd-1\expndtw-5\cf1\insrsid10962741 \hich\af0\dbch\af31505\loch\f0 hello
+\par }
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index c87ba3e..d3362da 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -150,6 +150,7 @@ public:
void testN818997();
void testFdo64671();
void testN825305();
+ void testParaBottomMargin();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -270,6 +271,7 @@ void Test::run()
{"n818997.rtf", &Test::testN818997},
{"fdo64671.rtf", &Test::testFdo64671},
{"n825305.rtf", &Test::testN825305},
+ {"para-bottom-margin.rtf", &Test::testParaBottomMargin},
};
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
{
@@ -1244,6 +1246,12 @@ void Test::testN825305()
CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState);
}
+void Test::testParaBottomMargin()
+{
+ // This was 353, i.e. bottom margin of the paragraph was 0.35cm instead of 0.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 951adc4..876ab9f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1025,6 +1025,7 @@ void RTFDocumentImpl::text(OUString& rString)
break;
case DESTINATION_STYLESHEET:
case DESTINATION_STYLEENTRY:
+ if (m_aStates.top().aTableAttributes.find(NS_rtf::LN_SGC))
{
RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aDestinationText.makeStringAndClear()));
m_aStates.top().aTableAttributes.set(NS_rtf::LN_XSTZNAME1, pValue);
@@ -1034,6 +1035,8 @@ void RTFDocumentImpl::text(OUString& rString)
);
m_aStyleTableEntries.insert(make_pair(m_nCurrentStyleIndex, pProp));
}
+ else
+ SAL_INFO("writerfilter", "no RTF style type defined, ignoring");
break;
case DESTINATION_REVISIONTABLE:
case DESTINATION_REVISIONENTRY:
More information about the Libreoffice-commits
mailing list