summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-01-06 21:29:54 +0300
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2020-01-18 20:29:56 +0100
commita031dc687bb35aa42835e0b4aa046250795d8fc0 (patch)
tree84bf9ac811d5952c65fcf0210ffdad20b2bb34e7
parent7dab34bc494e5b03537105cff385aa880968d9c8 (diff)
tdf#129839: pass initialized shared_ptr to SwDoc::GetBoxAttr
Regression after commit 1e2682235cded9a7cd90e55f0bfc60a1285e9a46 Change-Id: I40acc9e0ffdd292283381366a31eb6647b80324f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86291 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 4056b70e6339102374898fff26f099da455475b1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86329 Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit ed7dc32834e11c93eaf21de8424d9d46c7fa0d53) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86965 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com> Tested-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx23
-rw-r--r--sw/source/core/unocore/unotbl.cxx3
2 files changed, 25 insertions, 1 deletions
diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx
index faaac078bff6..788acffbef7e 100644
--- a/sw/qa/extras/unowriter/unowriter.cxx
+++ b/sw/qa/extras/unowriter/unowriter.cxx
@@ -12,6 +12,7 @@
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <com/sun/star/text/AutoTextContainer.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/XAutoTextGroup.hpp>
#include <com/sun/star/text/XTextPortionAppend.hpp>
#include <com/sun/star/text/XTextContentAppend.hpp>
@@ -821,6 +822,28 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testTextConvertToTableLineSpacing)
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(convertTwipToMm100(220)), aLineSpacing.Height);
}
+CPPUNIT_TEST_FIXTURE(SwUnoWriter, testTdf129839)
+{
+ // Create a new document and add a table
+ loadURL("private:factory/swriter", nullptr);
+ css::uno::Reference<css::text::XTextDocument> xTextDocument(mxComponent,
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::lang::XMultiServiceFactory> xFac(xTextDocument,
+ css::uno::UNO_QUERY_THROW);
+ css::uno::Reference<css::text::XTextTable> xTable(
+ xFac->createInstance("com.sun.star.text.TextTable"), css::uno::UNO_QUERY_THROW);
+ xTable->initialize(4, 4);
+ auto xSimpleText = xTextDocument->getText();
+ xSimpleText->insertTextContent(xSimpleText->createTextCursor(), xTable, true);
+ css::uno::Reference<css::table::XCellRange> xTableCellRange(xTable, css::uno::UNO_QUERY_THROW);
+ // Get instance of SwXCellRange
+ css::uno::Reference<css::beans::XPropertySet> xCellRange(
+ xTableCellRange->getCellRangeByPosition(0, 0, 1, 1), css::uno::UNO_QUERY_THROW);
+ // Test retrieval of VertOrient property - this crashed
+ css::uno::Any aOrient = xCellRange->getPropertyValue("VertOrient");
+ CPPUNIT_ASSERT_EQUAL(css::uno::Any(css::text::VertOrientation::NONE), aOrient);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 1ad6dc454657..fa378c7e8ae1 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -3572,7 +3572,8 @@ uno::Any SAL_CALL SwXCellRange::getPropertyValue(const OUString& rPropertyName)
break;
case RES_VERT_ORIENT:
{
- std::shared_ptr<SfxPoolItem> aVertOrient;
+ std::shared_ptr<SfxPoolItem> aVertOrient(
+ std::make_shared<SwFormatVertOrient>(RES_VERT_ORIENT));
if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aVertOrient))
{
aVertOrient->QueryValue( aRet, pEntry->nMemberId );