sw/qa/uitest/ui/frmdlg/frmdlg.py   |    5 +++++
 sw/source/uibase/frmdlg/frmmgr.cxx |    4 ++++
 sw/source/uibase/shells/textsh.cxx |   15 ++++++++++++---
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit c1a535ee2db757b2e40683dc918cbad8b7429cfa
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Nov 14 08:20:47 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Nov 14 09:34:10 2023 +0100

    sw floattable, insert UI: fix unexpected border and spacing
    
    Select an inline table (make sure the whole table is selected), insert a
    frame, then the frame width is already calculated from the table width,
    but an unexpected second frame border / spacing is also added. Given
    that the table already has its own border, adding a second border by
    default makes no sense.
    
    It's possible to disable default borders in SetFrameSizeFromTable(), but
    in case the borders are unchanged, the dialog's output item set will
    still contain no border info, so we will still get the default borders.
    
    Fix the problem by making this explicit: if the dialog's input item set
    had border info and the output item set had none, then still copy over
    the border info from the input to the output in
    SwTextShell::ExecInsert().
    
    This automatically fixes the unwanted border spacing as well, so the
    default frame properties are on par with the ones created by Word import
    filters.
    
    Change-Id: I4c9f165dad7a8bb70cfcfadaea4466a8d174b46e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159399
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/uitest/ui/frmdlg/frmdlg.py b/sw/qa/uitest/ui/frmdlg/frmdlg.py
index bbb9d9a270dd..51b6f6e53199 100644
--- a/sw/qa/uitest/ui/frmdlg/frmdlg.py
+++ b/sw/qa/uitest/ui/frmdlg/frmdlg.py
@@ -98,6 +98,11 @@ class Test(UITestCase):
             # inserted first, only then it could be marked as "split allowed".
             self.assertEqual(fly_split_visible, True)
 
+            # Without the accompanying fix in place, this test would have 
failed with:
+            # AssertionError: 2 != 0
+            # i.e. the frame had a border by default when the table already 
had its own border.
+            
self.assertEqual(xComponent.TextFrames.Frame1.LeftBorder.LineWidth, 0)
+
     def test_insert_simple_frame(self):
         # Given a Writer document:
         with self.ui_test.create_doc_in_start_center("writer") as xComponent:
diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx 
b/sw/source/uibase/frmdlg/frmmgr.cxx
index eb38c1c803f7..cdfeb267b990 100644
--- a/sw/source/uibase/frmdlg/frmmgr.cxx
+++ b/sw/source/uibase/frmdlg/frmmgr.cxx
@@ -666,6 +666,10 @@ void SwFlyFrameAttrMgr::SetFrameSizeFromTable()
     // The whole table is selected: default fly width should be the table width
     // in this case.
     m_aSet.Put(pTableFormat->GetFrameSize());
+
+    // The table can have its own border already, so an additional fly border 
makes no sense.
+    SvxBoxItem aBoxItem(RES_BOX);
+    m_aSet.Put(aBoxItem);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/textsh.cxx 
b/sw/source/uibase/shells/textsh.cxx
index d0c9aabc979f..0924935b3d7e 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -531,7 +531,7 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
                                                   GetView().GetViewFrame(),
                                                   GetView().GetFrameWeld(),
                                                   aSet));
-            pDlg->StartExecuteAsync([pDlg, nSlot, this](sal_Int32 nResult) {
+            pDlg->StartExecuteAsync([aSet, pDlg, nSlot, this](sal_Int32 
nResult) {
                 if (nResult == RET_OK && pDlg->GetOutputItemSet())
                 {
                     SwFlyFrameAttrMgr aAttrMgr( true, GetShellPtr(), 
Frmmgr_Type::TEXT, nullptr );
@@ -541,8 +541,17 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
                     rShell.StartAllAction();
                     rShell.StartUndo(SwUndoId::INSERT);
 
-                    const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
-                    aAttrMgr.SetAttrSet(*pOutSet);
+                    SfxItemSet aOutSet(*pDlg->GetOutputItemSet());
+                    const SvxBoxItem* pBox = aSet.GetItem(RES_BOX);
+                    if (pBox && !aOutSet.HasItem(RES_BOX))
+                    {
+                        // The input set had border info but the output set 
not, then copy it over
+                        // to not lose the custom border info. This can happen 
when a whole table
+                        // is selected and that case has its own defaults, not 
matching the frame
+                        // style.
+                        aOutSet.Put(*pBox);
+                    }
+                    aAttrMgr.SetAttrSet(aOutSet);
 
                     // At first delete the selection at the ClickToEditField.
                     if( rShell.IsInClickToEdit() )

Reply via email to