RTF filter: import posh/posv property of shapes

Change-Id: I55eccccf7f9ed06bba1ada18574890b5bee296f4
This commit is contained in:
Miklos Vajna 2013-06-15 19:05:50 +02:00
parent 16613995dd
commit 9d640dc6ad
5 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,24 @@
{\rtf1
{\shp
{\*\shpinst\shpleft0\shptop0\shpright3727\shpbottom2212\shpfhdr0\shpbxcolumn\shpbxignore\shpbypara\shpbyignore\shpwr3\shpwrk0\shpfblwtxt0\shpz0\shplid1026
{\sp
{\sn shapeType}
{\sv 202}
}
{\shptxt test}
{\sp
{\sn fFitShapeToText}
{\sv 1}
}
{\sp
{\sn posh}
{\sv 2}
}
{\sp
{\sn posv}
{\sv 2}
}
}
}
\par
}

View File

@ -32,6 +32,8 @@
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <rtl/ustring.hxx>
@ -139,6 +141,7 @@ public:
void testFdo64671();
void testPageBackground();
void testFdo62044();
void testPoshPosv();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@ -267,6 +270,7 @@ void Test::run()
{"fdo64671.rtf", &Test::testFdo64671},
{"page-background.rtf", &Test::testPageBackground},
{"fdo62044.rtf", &Test::testFdo62044},
{"posh-posv.rtf", &Test::testPoshPosv},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@ -1271,6 +1275,14 @@ void Test::testFdo62044()
CPPUNIT_ASSERT_EQUAL(10.f, getProperty<float>(xPropertySet, "CharHeight")); // Was 18, i.e. reset back to original value.
}
void Test::testPoshPosv()
{
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, getProperty<sal_Int16>(xDraws->getByIndex(0), "HoriOrient"));
CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, getProperty<sal_Int16>(xDraws->getByIndex(0), "VertOrient"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();

View File

@ -4750,7 +4750,9 @@ RTFShape::RTFShape()
nTop(0),
nRight(0),
nBottom(0),
nHoriOrient(0),
nHoriOrientRelation(0),
nVertOrient(0),
nVertOrientRelation(0),
nWrap(-1)
{

View File

@ -244,7 +244,9 @@ namespace writerfilter {
sal_Int32 nRight;
sal_Int32 nBottom;
boost::optional<sal_Int32> oZ; ///< Z-Order of the shape.
sal_Int16 nHoriOrient;
sal_Int16 nHoriOrientRelation;
sal_Int16 nVertOrient;
sal_Int16 nVertOrientRelation;
int nWrap;
};

View File

@ -393,6 +393,46 @@ void RTFSdrImport::resolve(RTFShape& rShape)
else if (i->first == "shadowOffsetX")
// EMUs to points
aShadowModel.moOffset.set(OUString::number(i->second.toDouble() / 12700) + "pt");
else if (i->first == "posh")
{
switch(i->second.toInt32())
{
case 1:
rShape.nHoriOrient = text::HoriOrientation::LEFT;
break;
case 2:
rShape.nHoriOrient = text::HoriOrientation::CENTER;
break;
case 3:
rShape.nHoriOrient = text::HoriOrientation::RIGHT;
break;
case 4:
rShape.nHoriOrient = text::HoriOrientation::INSIDE;
break;
case 5:
rShape.nHoriOrient = text::HoriOrientation::OUTSIDE;
break;
default:
break;
}
}
else if (i->first == "posv")
{
switch(i->second.toInt32())
{
case 1:
rShape.nVertOrient = text::VertOrientation::TOP;
break;
case 2:
rShape.nVertOrient = text::VertOrientation::CENTER;
break;
case 3:
rShape.nVertOrient = text::VertOrientation::BOTTOM;
break;
default:
break;
}
}
else if (i->first == "posrelh")
{
switch (i->second.toInt32())
@ -503,8 +543,12 @@ void RTFSdrImport::resolve(RTFShape& rShape)
else
xShape->setPosition(awt::Point(rShape.nLeft, rShape.nTop));
xShape->setSize(awt::Size(rShape.nRight - rShape.nLeft, rShape.nBottom - rShape.nTop));
if (rShape.nHoriOrient != 0)
xPropertySet->setPropertyValue("HoriOrient", uno::makeAny(rShape.nHoriOrient));
if (rShape.nHoriOrientRelation != 0)
xPropertySet->setPropertyValue("HoriOrientRelation", uno::makeAny(rShape.nHoriOrientRelation));
if (rShape.nVertOrient != 0)
xPropertySet->setPropertyValue("VertOrient", uno::makeAny(rShape.nVertOrient));
if (rShape.nVertOrientRelation != 0)
xPropertySet->setPropertyValue("VertOrientRelation", uno::makeAny(rShape.nVertOrientRelation));
if (rShape.nWrap != -1)