bnc#825305 RTF import of fFilled shape property

Change-Id: Iaa2ff9d5d1a28aec046f885acecbd1a44c734ec0
This commit is contained in:
Miklos Vajna
2013-06-18 16:22:32 +02:00
parent f8d1dcc621
commit 2af60e2eff
3 changed files with 98 additions and 1 deletions

View File

@@ -0,0 +1,76 @@
{\rtf
\viewkind1\margl360\margr360
\margt360\margb360\paperw12240\paperh15840\pard
{\shp
{\*\shpinst\shpleft555\shpright1185\shptop5715\shpbottom5970\shpbxpage
\shpbypage\shpwr3\shpz1
{\sp
{\sn shapeType}
{\sv 1}
}
{\sp
{\sn fLine}
{\sv 1}
}
{\sp
{\sn lineWidth}
{\sv 0}
}
{\sp
{\sn lineColor}
{\sv 10485760}
}
{\sp
{\sn lineDashing
}
{\sv 0}
}
{\sp
{\sn fFilled}
{\sv 1}
}
{\sp
{\sn fillColor}
{\sv 10485760}
}
}
}
{\shp
{\*\shpinst\shpleft780\shpright1425\shptop5790\shpbottom6030\shpbxpage
\shpbypage\shpwr3\shpz2
{\sp
{\sn shapeType}
{\sv 202}
}
{\sp
{\sn dxTextLeft}
{\sv
0}
}
{\sp
{\sn dxTextRight}
{\sv 0}
}
{\sp
{\sn dyTextTop}
{\sv 0}
}
{\sp
{\sn
dyTextBottom}
{\sv 0}
}
{\sp
{\sn fLine}
{\sv 0}
}
{\shptxt\plain\pard\f29\fs20 Ln #
\par}
{\sp
{\sn fFilled}
{\sv 0}
}
}
}
}

View File

@@ -142,6 +142,7 @@ public:
void testPageBackground(); void testPageBackground();
void testFdo62044(); void testFdo62044();
void testPoshPosv(); void testPoshPosv();
void testN825305();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT) #if !defined(MACOSX) && !defined(WNT)
@@ -271,6 +272,7 @@ void Test::run()
{"page-background.rtf", &Test::testPageBackground}, {"page-background.rtf", &Test::testPageBackground},
{"fdo62044.rtf", &Test::testFdo62044}, {"fdo62044.rtf", &Test::testFdo62044},
{"posh-posv.rtf", &Test::testPoshPosv}, {"posh-posv.rtf", &Test::testPoshPosv},
{"n825305.rtf", &Test::testN825305},
}; };
header(); header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -1284,6 +1286,18 @@ void Test::testPoshPosv()
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xDraws->getByIndex(0), "FrameIsAutomaticHeight")); CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xDraws->getByIndex(0), "FrameIsAutomaticHeight"));
} }
void Test::testN825305()
{
// The problem was that the textbox wasn't transparent, due to unimplemented fFilled == 0.
uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
uno::Reference<beans::XPropertyState> xPropertyState(xDraws->getByIndex(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(xDraws->getByIndex(1), "BackColorTransparency"));
beans::PropertyState ePropertyState = xPropertyState->getPropertyState("BackColorTransparency");
// Was beans::PropertyState_DEFAULT_VALUE.
CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, ePropertyState);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();

View File

@@ -121,6 +121,8 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> xShape, OUStrin
sal_Int16 nHoriOrient = 0; sal_Int16 nHoriOrient = 0;
sal_Int16 nVertOrient = 0; sal_Int16 nVertOrient = 0;
boost::optional<bool> obFitShapeToText; boost::optional<bool> obFitShapeToText;
bool bFilled = true;
if (aKey == "posh") if (aKey == "posh")
{ {
switch (aValue.toInt32()) switch (aValue.toInt32())
@@ -163,6 +165,9 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> xShape, OUStrin
} }
else if (aKey == "fFitShapeToText") else if (aKey == "fFitShapeToText")
obFitShapeToText.reset(aValue.toInt32() == 1); obFitShapeToText.reset(aValue.toInt32() == 1);
else if (aKey == "fFilled")
bFilled = aValue.toInt32() == 1;
if (nHoriOrient != 0) if (nHoriOrient != 0)
xPropertySet->setPropertyValue("HoriOrient", uno::makeAny(nHoriOrient)); xPropertySet->setPropertyValue("HoriOrient", uno::makeAny(nHoriOrient));
if (nVertOrient != 0) if (nVertOrient != 0)
@@ -172,6 +177,8 @@ void RTFSdrImport::applyProperty(uno::Reference<drawing::XShape> xShape, OUStrin
xPropertySet->setPropertyValue("SizeType", uno::makeAny(*obFitShapeToText ? text::SizeType::MIN : text::SizeType::FIX)); xPropertySet->setPropertyValue("SizeType", uno::makeAny(*obFitShapeToText ? text::SizeType::MIN : text::SizeType::FIX));
xPropertySet->setPropertyValue("FrameIsAutomaticHeight", uno::makeAny(*obFitShapeToText)); xPropertySet->setPropertyValue("FrameIsAutomaticHeight", uno::makeAny(*obFitShapeToText));
} }
if (!bFilled)
xPropertySet->setPropertyValue("BackColorTransparency", uno::makeAny(sal_Int32(100)));
} }
void RTFSdrImport::resolve(RTFShape& rShape, bool bClose) void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
@@ -452,7 +459,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose)
else if (i->first == "shadowOffsetX") else if (i->first == "shadowOffsetX")
// EMUs to points // EMUs to points
aShadowModel.moOffset.set(OUString::number(i->second.toDouble() / 12700) + "pt"); aShadowModel.moOffset.set(OUString::number(i->second.toDouble() / 12700) + "pt");
else if (i->first == "posh" || i->first == "posv" || i->first == "fFitShapeToText") else if (i->first == "posh" || i->first == "posv" || i->first == "fFitShapeToText" || i->first == "fFilled")
applyProperty(xShape, i->first, i->second); applyProperty(xShape, i->first, i->second);
else if (i->first == "posrelh") else if (i->first == "posrelh")
{ {