tdf#151100: xText->getString() may be empty for content needing export

The check that is removed prevents collecting the table data.
Assume that it's the performance optimization, and that processing
empty text objects would be fast anyway.

This basically reverts commit 73fcb052ed
  Author Christian Lippka <cl@openoffice.org>
  Date   Thu Nov 22 12:26:35 2001 +0000
    #90330# only export text autostyles for shapes with text

and commit 7661bbbaef
  Author Michael Stahl <mstahl@redhat.com>
  Date   Fri Nov 25 22:46:34 2016 +0100
    tdf#102479 ODF export: ignore exceptions when checking shape text

that becomes unnecessary after the former change is reverted.

Change-Id: I709a7b4c5ac1cc0621d3a1b18f2eb74feb987efb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140313
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2022-09-21 13:48:44 +02:00
parent f10067abcb
commit bdf346830b
3 changed files with 14 additions and 15 deletions
Binary file not shown.
+14
View File
@@ -520,6 +520,20 @@ CPPUNIT_TEST_FIXTURE(Test, tdf150927)
assertXPath(pXmlDoc, "/office:document-styles/office:automatic-styles/style:style[@style:family='table']", 2);
}
CPPUNIT_TEST_FIXTURE(Test, tdf151100)
{
// Similar to tdf135942
loadAndReload("tdf151100.docx");
// All table autostyles should be collected, including nested, and must not crash.
CPPUNIT_ASSERT_EQUAL(1, getPages());
xmlDocUniquePtr pXmlDoc = parseExport("styles.xml");
assertXPath(pXmlDoc, "/office:document-styles/office:automatic-styles/style:style[@style:family='table']", 1);
}
DECLARE_ODFEXPORT_TEST(testGutterLeft, "gutter-left.odt")
{
CPPUNIT_ASSERT_EQUAL(1, getPages());
-15
View File
@@ -307,22 +307,7 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap
if( xPropSet.is() && bObjSupportsText )
{
uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY);
bool bSkip = false;
if (xText.is())
{
try
{
bSkip = xText->getString().isEmpty();
}
catch (uno::RuntimeException const&)
{
// tdf#102479: SwXTextFrame that contains only a table will
// throw, but the table must be iterated so that
// SwXMLExport::ExportTableLines() can find its auto styles
// so do not skip it!
}
}
if (!bSkip)
{
uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );