diff --git a/xmloff/qa/unit/data/table-in-shape.fodt b/xmloff/qa/unit/data/table-in-shape.fodt new file mode 100644 index 000000000000..44c2bcb05db2 --- /dev/null +++ b/xmloff/qa/unit/data/table-in-shape.fodt @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + A1 + + + diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index f13a60082d7d..fc07053cbacf 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include @@ -218,6 +220,28 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testReferToTheme) "color-lum-off"); } +CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTableInShape) +{ + // Given a document with a shape with a "FrameX" parent style (starts with Frame, but is not + // Frame): + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "table-in-shape.fodt"; + + // When loading that document: + getComponent() = loadFromDesktop(aURL); + + // Then make sure the table inside the shape is not lost: + uno::Reference xDrawPageSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference xText(xShape->getText(), uno::UNO_QUERY); + uno::Reference xEnum = xText->createEnumeration(); + uno::Reference xTable(xEnum->nextElement(), uno::UNO_QUERY); + // Without the accompanying fix in place, this test would have crashed, as xTable was an empty + // reference, i.e. the table inside the shape was lost. + uno::Reference xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("A1"), xCell->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index c1f93885c9c7..4d2dec38a3c8 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -3503,7 +3503,9 @@ SdXMLCustomShapeContext::SdXMLCustomShapeContext( rtl::Reference xTxtImport = GetImport().GetTextImport(); XMLPropStyleContext* pStyle = xTxtImport->FindAutoFrameStyle(aStyleName); // Note that this an API name, so intentionally not localized. - if (pStyle && pStyle->GetParentName() == "Frame") + // Also allow other Frame styles with the same prefix, we just want to reject + // Graphics after all. + if (pStyle && pStyle->GetParentName().startsWith("Frame")) { mbTextBox = true; break;