summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-03-11 07:04:23 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2018-03-11 07:02:38 +0100
commita8fc81d478f4dcf8600ed9a2b4e0f7adff4a17ee (patch)
tree00d04bb321e093ddd48867fac8a79817b5b60cd1 /sd
parent98eb91a1b99ce9c5ff43b49a9a7789ee8b1c8cc5 (diff)
tdf#44774: Parent style's msApiName could yet be empty; use GetApiName()
Change-Id: Ie0e218ea83d34aa7ee22fea1f32b2851a942544f Reviewed-on: https://gerrit.libreoffice.org/51069 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/misc-tests.cxx30
-rw-r--r--sd/source/core/stlsheet.cxx2
2 files changed, 31 insertions, 1 deletions
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index 3d3c2c9064bb..c22b35b88435 100644
--- a/sd/qa/unit/misc-tests.cxx
+++ b/sd/qa/unit/misc-tests.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/frame/XLoadable.hpp>
#include <vcl/scheduler.hxx>
#include <osl/thread.hxx>
@@ -60,6 +61,7 @@ public:
void testTdf99396();
void testTdf99396TextEdit();
void testFillGradient();
+ void testTdf44774();
CPPUNIT_TEST_SUITE(SdMiscTest);
CPPUNIT_TEST(testTdf96206);
@@ -67,6 +69,7 @@ public:
CPPUNIT_TEST(testTdf99396);
CPPUNIT_TEST(testTdf99396TextEdit);
CPPUNIT_TEST(testFillGradient);
+ CPPUNIT_TEST(testTdf44774);
CPPUNIT_TEST_SUITE_END();
private:
@@ -298,6 +301,33 @@ void SdMiscTest::testFillGradient()
CPPUNIT_ASSERT_EQUAL(sal_Int32(Color(0, 255, 0)),aGradient2.EndColor);
}
+void SdMiscTest::testTdf44774()
+{
+ sd::DrawDocShellRef xDocShRef = new sd::DrawDocShell(SfxObjectCreateMode::EMBEDDED, false,
+ DocumentType::Draw);
+ const uno::Reference<frame::XLoadable> xLoadable(xDocShRef->GetModel(), uno::UNO_QUERY_THROW);
+ xLoadable->initNew();
+ SfxStyleSheetBasePool* pSSPool = xDocShRef->GetStyleSheetPool();
+
+ // Create a new style with an empty name, like what happens in UI when creating a new style
+ SfxStyleSheetBase& rStyleA = pSSPool->Make("", SfxStyleFamily::Para, SFXSTYLEBIT_USERDEF);
+ // Assign a new name, which does not yet set its ApiName
+ rStyleA.SetName("StyleA");
+ // Create another style
+ SfxStyleSheetBase& rStyleB = pSSPool->Make("StyleB", SfxStyleFamily::Para, SFXSTYLEBIT_USERDEF);
+ // ... and set its parent to the first one
+ rStyleB.SetParent("StyleA");
+
+ // Now save the file and reload
+ xDocShRef = saveAndReload(xDocShRef.get(), ODG);
+ pSSPool = xDocShRef->GetStyleSheetPool();
+
+ SfxStyleSheetBase* pStyle = pSSPool->Find("StyleB", SfxStyleFamily::Para);
+ CPPUNIT_ASSERT(pStyle);
+ // The parent set in StyleB used to reset, because parent style's msApiName was empty
+ CPPUNIT_ASSERT_EQUAL(OUString("StyleA"), pStyle->GetParent());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 042512f05b8e..a304bd36f65d 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -873,7 +873,7 @@ OUString SAL_CALL SdStyleSheet::getParentStyle()
{
SdStyleSheet* pParentStyle = static_cast< SdStyleSheet* >( mxPool->Find( GetParent(), nFamily ) );
if( pParentStyle )
- return pParentStyle->msApiName;
+ return pParentStyle->GetApiName();
}
return OUString();
}