summaryrefslogtreecommitdiff
path: root/sw/source/uibase/frmdlg/frmmgr.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-11-08 08:25:23 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-11-08 10:17:09 +0100
commit0ecb69d53864b582eb59533729ada01d85d383e6 (patch)
tree50327d15a732528af8935a286c2819d690ddf1fd /sw/source/uibase/frmdlg/frmmgr.cxx
parent4261f337b647bd504c9500f23fbb0cdd90a2d50e (diff)
sw floattable, insert UI: inherit fly width from selected table width
Inline table width defaults to the body frame width, so a hardcoded 2cm default for the fly width is a bit poor. Leave the normal fly insert case unchanged, but if an entire table is selected, then change the default to the table width. Check for the table selection like SwFEShell::NewFlyFrame() does it, and determine if the entire table is selected like SwDoc::MakeFlyAndMove() does it. With this, a default table with a default frame keeps its width on frame insert. Change-Id: Iaf954395a4799222074acd83b5eae52ca75ae0ae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159104 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/uibase/frmdlg/frmmgr.cxx')
-rw-r--r--sw/source/uibase/frmdlg/frmmgr.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/sw/source/uibase/frmdlg/frmmgr.cxx b/sw/source/uibase/frmdlg/frmmgr.cxx
index 729892398997..a71b7ef3fb0a 100644
--- a/sw/source/uibase/frmdlg/frmmgr.cxx
+++ b/sw/source/uibase/frmdlg/frmmgr.cxx
@@ -84,6 +84,9 @@ SwFlyFrameAttrMgr::SwFlyFrameAttrMgr( bool bNew, SwWrtShell* pSh, Frmmgr_Type nT
}
m_aSet.SetParent( &m_pOwnSh->GetFormatFromPool( nId )->GetAttrSet());
m_aSet.Put( SwFormatFrameSize( SwFrameSize::Minimum, DFLT_WIDTH, DFLT_HEIGHT ));
+
+ SetFrameSizeFromTable();
+
if ( 0 != ::GetHtmlMode(pSh->GetView().GetDocShell()) )
m_aSet.Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::PRINT_AREA ) );
@@ -622,4 +625,36 @@ void SwFlyFrameAttrMgr::SetAttrSet(const SfxItemSet& rSet)
m_aSet.Put( rSet );
}
+void SwFlyFrameAttrMgr::SetFrameSizeFromTable()
+{
+ if (!m_pOwnSh->IsTableMode())
+ {
+ return;
+ }
+
+ // We have a table selection.
+ SwSelBoxes aBoxes;
+ GetTableSel(*m_pOwnSh, aBoxes);
+ if (aBoxes.empty())
+ {
+ return;
+ }
+
+ auto pTableNd = const_cast<SwTableNode*>(aBoxes[0]->GetSttNd()->FindTableNode());
+ if (!pTableNd)
+ {
+ return;
+ }
+
+ SwTable& rTable = pTableNd->GetTable();
+ if (aBoxes.size() != rTable.GetTabSortBoxes().size())
+ {
+ return;
+ }
+
+ // The whole table is selected: default fly width should be the table width
+ // in this case.
+ m_aSet.Put(rTable.GetFrameFormat()->GetFrameSize());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */