sc/source/core/data/stlsheet.cxx |    1 +
 sc/source/ui/unoobj/servuno.cxx  |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 3709d62860b07110a8420ff30c0150d81267b31d
Author:     Maxim Monastirsky <momonas...@gmail.com>
AuthorDate: Fri Apr 7 00:40:43 2023 +0300
Commit:     Maxim Monastirsky <momonas...@gmail.com>
CommitDate: Fri Apr 7 09:34:01 2023 +0200

    crashtesting: crash on saving of fdo48916-1.ods
    
    That document has <style:style ... style:family="graphic">
    before <style:default-style style:family="graphic">. The
    problem was that only the default style was creating the
    draw layer (in ScDrawDefaultsObj::getModelPool), which
    means that the SdrItemPool didn't exist at the time the
    item set of the former style was created.
    
    The easiest solution seems to ensure the draw layer
    existence on each UNO style object creation, similar to
    the other draw layer related objects in this method.
    
    A similar fix was added recently for another scenario in
    commit aec0830f31c2fd258de711baaa7da24bd01488c9 ("Ensure
    valid SdrItemPool for drawing styles").
    
    Change-Id: I50d89fea6d419119cd47ab163c82d1470b04b4a2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150115
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonas...@gmail.com>

diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx
index 665b806ba540..062be0a05280 100644
--- a/sc/source/core/data/stlsheet.cxx
+++ b/sc/source/core/data/stlsheet.cxx
@@ -227,6 +227,7 @@ SfxItemSet& ScStyleSheet::GetItemSet()
                 SfxItemPool* pItemPool = &GetPool()->GetPool();
                 if (dynamic_cast<SdrItemPool*>(pItemPool) == nullptr)
                     pItemPool = pItemPool->GetSecondaryPool();
+                assert(pItemPool);
 
                 pSet = new SfxItemSetFixed<
                         XATTR_LINE_FIRST, XATTR_LINE_LAST,
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 855d0ae76b22..d135ad68abfa 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -425,7 +425,11 @@ uno::Reference<uno::XInterface> 
ScServiceProvider::MakeInstance(
             xRet.set(static_cast<style::XStyle*>(new ScStyleObj( nullptr, 
SfxStyleFamily::Page, OUString() )));
             break;
         case Type::GRAPHICSTYLE:
-            xRet.set(static_cast<style::XStyle*>(new ScStyleObj( nullptr, 
SfxStyleFamily::Frame, OUString() )));
+            if (pDocShell)
+            {
+                pDocShell->MakeDrawLayer();
+                xRet.set(static_cast<style::XStyle*>(new ScStyleObj( nullptr, 
SfxStyleFamily::Frame, OUString() )));
+            }
             break;
         case Type::AUTOFORMAT:
             xRet.set(static_cast<container::XIndexAccess*>(new 
ScAutoFormatObj( SC_AFMTOBJ_INVALID )));

Reply via email to