https://bugs.documentfoundation.org/show_bug.cgi?id=164949

--- Comment #8 from Octavio Alvarez <[email protected]> ---
In the commit causing the crash, the changed file is
sw/source/uibase/uiview/formatclipboard.cxx.

In the backtrace, the crash occurs in an assert() in frame #5:

    SfxItemPool* pTarget(getTargetPool(nWhich));
    if (nullptr == pTarget)
        assert(!"unknown which - don't ask me for defaults");


#5  0x00007ffff32e58d5 in SfxItemPool::GetUserOrPoolDefaultItem(unsigned short)
const (this=0x5555565c19e0, nWhich=10023) at
/home/alvarezp/src/libreoffice/core/svl/source/items/itempool.cxx:725

#6  0x00007ffff33339ad in SfxItemSet::MergeItem_Impl(unsigned short,
SfxPoolItem const*, bool) (this=0x55555b2b0050, nWhich=10023, pFnd2=0x0,
bIgnoreDefaults=false) at /home/alvarezp/src/libreoffice/cor
e/svl/source/items/itemset.cxx:1167

#7  0x00007ffff3333c75 in SfxItemSet::MergeValues(SfxItemSet const&)
(this=0x55555b2b0050, rSet=...) at
/home/alvarezp/src/libreoffice/core/svl/source/items/itemset.cxx:1218

#8  0x00007fff99465804 in SwEditShell::GetTableBoxFormulaAttrs(SfxItemSet&)
const (this=0x555556ddcb60, rSet=warning: RTTI symbol not found for class
'SfxItemSetFixed<(unsigned short)99, (unsigned short)100, (unsigned short)111,
(unsigned short)113, (unsigned short)116, (unsigned short)116, (unsigned
short)119, (unsigned short)119, (unsigned short)126, (unsigned short)126,
(unsigned short)128, (unsigned short)128, (unsigned short)156, (unsigned
short)156, (unsigned short)10023, (unsigned short)10025, (unsigned short)10368,
(unsigned short)10453, (unsigned short)20588, (unsigned short)20588, (unsigned
short)20592, (unsigned short)20592, (unsigned short)21150, (unsigned
short)21150>'
...) at /home/alvarezp/src/libreoffice/core/sw/source/core/edit/edtab.cxx:334

#9  0x00007fff9a3a601f in (anonymous
namespace)::lcl_getTableAttributes(SfxItemSet&, SwWrtShell&, bool)
(rSet=warning: RTTI symbol not found for class 'SfxItemSetFixed<(unsigned
short)99, (unsigned short)100, (unsigned short)111, (unsigned short)113,
(unsigned short)116, (unsigned short)116, (unsigned short)119, (unsigned
short)119, (unsigned short)126, (unsigned short)126, (unsigned short)128,
(unsigned short)128, (unsigned short)156, (unsigned short)156, (unsigned
short)10023, (unsigned short)10025, (unsigned short)10368, (unsigned
short)10453, (unsigned short)20588, (unsigned short)20588, (unsigned
short)20592, (unsigned short)20592, (unsigned short)21150, (unsigned
short)21150>'
..., rSh=..., bAllCellAttrs=true) at
/home/alvarezp/src/libreoffice/core/sw/source/uibase/uiview/formatclipboard.cxx:143

#10 0x00007fff9a3a718d in SwFormatClipboard::Copy(SwWrtShell&, SfxItemPool&,
bool) (this=0x555559c52df0, rWrtShell=..., rPool=..., bPersistentCopy=false) at
/home/alvarezp/src/libreoffice/core/sw/source/uibase/uiview/formatclipboard.cxx:403

#11 0x00007fff9a3d83fb in SwView::ExecFormatPaintbrush(SfxRequest const&)
(this=0x555559c63a50, rReq=...) at
/home/alvarezp/src/libreoffice/core/sw/source/uibase/uiview/view1.cxx:176

#12 0x00007fff9a3d3c51 in SfxStubSwViewExecFormatPaintbrush(SfxShell*,
SfxRequest&) (pShell=0x555559c63a50, rReq=...) at
/home/alvarezp/src/libreoffice/core/workdir/SdiTarget/sw/sdi/swslots.hxx:15051

#13 0x00007ffff3d12568 in SfxDispatcher::Call_Impl(SfxShell&, SfxSlot const&,
SfxRequest&, bool) (this=0x5555566f62c0, rShell=..., rSlot=..., rReq=...,
bRecord=true) at
/home/alvarezp/src/libreoffice/core/sfx2/source/control/dispatch.cxx:254


The patch diff has some reindentation. Ignoring whitespace (git -w show), the
patch is:

commit 3e4aa127416a5947882e6644409468aa1ca039ae
Author:     Oliver Specht <[email protected]>
AuthorDate: Wed May 29 12:19:24 2024 +0200
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Mon Jul 15 20:10:24 2024 +0200

    tdf#122756 clone formatting includes table number format

    In clone formatting the number format of the current cell(s)
    is copied and applied if the target is a table

    Change-Id: I0b7dc1d5015aeb2262c8d37f76442519c5b6d655
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168184
    Reviewed-by: Thorsten Behrens <[email protected]>
    Tested-by: Jenkins

diff --git a/sw/source/uibase/uiview/formatclipboard.cxx
b/sw/source/uibase/uiview/formatclipboard.cxx
index 1878b3efc209..1d5d1f80c39c 100644
--- a/sw/source/uibase/uiview/formatclipboard.cxx
+++ b/sw/source/uibase/uiview/formatclipboard.cxx
@@ -23,6 +23,7 @@
 #include <formatclipboard.hxx>

 #include <cmdid.h>
+#include <cellatr.hxx>
 #include <charfmt.hxx>
 #include <frmfmt.hxx>
 #include <docstyle.hxx>
@@ -91,7 +92,9 @@ std::unique_ptr<SfxItemSet> lcl_CreateEmptyItemSet(
SelectionType nSelectionType
     return pItemSet;
 }

-void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh )
+void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh, bool
bAllCellAttrs )
+{
+    if (bAllCellAttrs)
     {
         std::unique_ptr<SvxBrushItem>
aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
         rSh.GetBoxBackground(aBrush);
@@ -137,6 +140,8 @@ void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell
&rSh )
         if(pSplit)
             rSet.Put(std::move(pSplit));
     }
+    rSh.GetTableBoxFormulaAttrs(rSet);
+}

 void lcl_setTableAttributes( const SfxItemSet& rSet, SwWrtShell &rSh )
 {
@@ -216,6 +221,10 @@ void lcl_setTableAttributes( const SfxItemSet& rSet,
SwWrtShell &rSh )

     if( const SwFormatRowSplit* pSplitItem = rSet.GetItemIfSet( RES_ROW_SPLIT,
false ) )
         rSh.SetRowSplit(*pSplitItem);
+
+    if (rSet.GetItemIfSet( RES_BOXATR_FORMAT, false ))
+        rSh.SetTableBoxFormulaAttrs(rSet);
+
 }
 }//end anonymous namespace

@@ -364,8 +373,11 @@ void SwFormatClipboard::Copy( SwWrtShell& rWrtShell,
SfxItemPool& rPool, bool bP
         }
     }

-    if( nSelectionType & SelectionType::TableCell )//only copy table
attributes if really cells are selected (not only text in tables)
+    if(nSelectionType & (SelectionType::Table | SelectionType::TableCell))
+    {
+        if (nSelectionType & SelectionType::TableCell)
         {
+            //only copy all table attributes if really cells are selected (not
only text in tables)
             m_pTableItemSet = std::make_unique<SfxItemSetFixed<
                 RES_PAGEDESC, RES_BREAK,
                 RES_BACKGROUND, RES_SHADOW, // RES_BOX is inbetween
@@ -373,13 +385,22 @@ void SwFormatClipboard::Copy( SwWrtShell& rWrtShell,
SfxItemPool& rPool, bool bP
                 RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
                 RES_FRAMEDIR, RES_FRAMEDIR,
                 RES_ROW_SPLIT, RES_ROW_SPLIT,
+                RES_BOXATR_FORMAT, RES_BOXATR_FORMAT,
                 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
                     // SID_ATTR_BORDER_OUTER is inbetween
                 SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE,
                 FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN,
                 FN_TABLE_BOX_TEXTORIENTATION, FN_TABLE_BOX_TEXTORIENTATION,
                 FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE>>(rPool);
-        lcl_getTableAttributes( *m_pTableItemSet, rWrtShell );
+        }
+        else
+        {
+            //selection in table should copy number format
+            m_pTableItemSet = std::make_unique<SfxItemSetFixed<
+                RES_BOXATR_FORMAT, RES_BOXATR_FORMAT>>(rPool);
+        }
+
+        lcl_getTableAttributes( *m_pTableItemSet, rWrtShell, nSelectionType &
SelectionType::TableCell ? true : false);
     }

     m_nSelectionType = nSelectionType;

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to