Kaydet (Commit) bafd3675 authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Andras Timar

tdf#44774: Parent style's msApiName could yet be empty; use GetApiName()

Reviewed-on: https://gerrit.libreoffice.org/51069Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit a8fc81d4)

Change-Id: Ie0e218ea83d34aa7ee22fea1f32b2851a942544f
Reviewed-on: https://gerrit.libreoffice.org/51101Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 14e9320d
......@@ -20,6 +20,7 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/frame/XLoadable.hpp>
#include <vcl/scheduler.hxx>
#include <osl/thread.hxx>
#include <FactoryIds.hxx>
......@@ -51,12 +52,14 @@ public:
void testTdf96708();
void testTdf99396();
void testTdf99396TextEdit();
void testTdf44774();
CPPUNIT_TEST_SUITE(SdMiscTest);
CPPUNIT_TEST(testTdf96206);
CPPUNIT_TEST(testTdf96708);
CPPUNIT_TEST(testTdf99396);
CPPUNIT_TEST(testTdf99396TextEdit);
CPPUNIT_TEST(testTdf44774);
CPPUNIT_TEST_SUITE_END();
private:
......@@ -255,6 +258,33 @@ void SdMiscTest::testTdf99396TextEdit()
xDocSh->DoClose();
}
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();
......
......@@ -912,7 +912,7 @@ OUString SAL_CALL SdStyleSheet::getParentStyle() throw(RuntimeException, std::ex
{
SdStyleSheet* pParentStyle = static_cast< SdStyleSheet* >( mxPool->Find( GetParent(), nFamily ) );
if( pParentStyle )
return pParentStyle->msApiName;
return pParentStyle->GetApiName();
}
return OUString();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment