oox: support non-TextFrame shapes in WpsContext::onCreateContext
Change-Id: I692fa22132cd3a722b58de22e3dbb759ff888e5d
This commit is contained in:
parent
b6bfcaa054
commit
28e9b5bc01
@ -75,8 +75,9 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
|
||||
|
||||
uno::Reference<lang::XServiceInfo> xServiceInfo(mxShape, uno::UNO_QUERY);
|
||||
uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
|
||||
if (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
|
||||
if (xServiceInfo.is())
|
||||
{
|
||||
bool bTextFrame = xServiceInfo->supportsService("com.sun.star.text.TextFrame");
|
||||
// Handle inset attributes for Writer textframes.
|
||||
sal_Int32 aInsets[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
|
||||
boost::optional<sal_Int32> oInsets[4];
|
||||
@ -87,9 +88,10 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
|
||||
oInsets[i] = oox::drawingml::GetCoordinate(oValue.get());
|
||||
}
|
||||
OUString aProps[] = { OUString("LeftBorderDistance"), OUString("TopBorderDistance"), OUString("RightBorderDistance"), OUString("BottomBorderDistance") };
|
||||
for (size_t i = 0; i < SAL_N_ELEMENTS(aProps); ++i)
|
||||
OUString aShapeProps[] = { OUString("TextLeftDistance"), OUString("TextUpperDistance"), OUString("TextRightDistance"), OUString("TextLowerDistance") };
|
||||
for (size_t i = 0; i < SAL_N_ELEMENTS(bTextFrame ? aProps : aShapeProps); ++i)
|
||||
if (oInsets[i])
|
||||
xPropertySet->setPropertyValue(aProps[i], uno::makeAny(*oInsets[i]));
|
||||
xPropertySet->setPropertyValue((bTextFrame ? aProps : aShapeProps)[i], uno::makeAny(*oInsets[i]));
|
||||
}
|
||||
|
||||
// Handle text vertical adjustment inside a text frame
|
||||
|
@ -605,11 +605,23 @@ DECLARE_OOXMLEXPORT_TEST(testFdo48557, "fdo48557.odt")
|
||||
// Inner margins of the textframe wasn't exported.
|
||||
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
|
||||
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
|
||||
uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "LeftBorderDistance"));
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "RightBorderDistance"));
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TopBorderDistance"));
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "BottomBorderDistance"));
|
||||
if (xIndexAccess->getCount() > 0)
|
||||
{
|
||||
// TODO TextBox: remove this when TextBox is enabled by default
|
||||
uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "LeftBorderDistance"));
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "RightBorderDistance"));
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TopBorderDistance"));
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "BottomBorderDistance"));
|
||||
}
|
||||
else
|
||||
{
|
||||
uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextLeftDistance"));
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextRightDistance"));
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextUpperDistance"));
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextLowerDistance"));
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_OOXMLEXPORT_TEST(testI120928, "i120928.docx")
|
||||
|
Loading…
x
Reference in New Issue
Block a user