sw/inc/swmodule.hxx | 2 +- sw/source/core/docnode/ndtbl.cxx | 3 ++- sw/source/core/unocore/unotbl.cxx | 9 +++++---- sw/source/ui/dbui/dbinsdlg.cxx | 8 ++++---- sw/source/ui/table/convert.cxx | 2 +- sw/source/ui/table/instable.cxx | 2 +- sw/source/ui/table/tautofmt.cxx | 3 ++- sw/source/uibase/shells/basesh.cxx | 10 +++++----- 8 files changed, 21 insertions(+), 18 deletions(-)
New commits: commit 31055d3b22bbdcfa14a38a944c8a02b04197dfc4 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri May 30 20:06:57 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Jun 1 20:57:46 2025 +0200 use shallow copy of default AutoFormatTable Change-Id: I958f0b6329c4d55af61a94e641bd328abe08dad7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186063 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 316438884c4b..4f561b7fc076 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -50,6 +50,7 @@ #include <cntfrm.hxx> #include <pam.hxx> #include <swcrsr.hxx> +#include <swmodule.hxx> #include <swtable.hxx> #include <swundo.hxx> #include <tblsel.hxx> @@ -3961,7 +3962,7 @@ bool SwDoc::GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGe SwTableAutoFormatTable& SwDoc::GetTableStyles() { if (!m_pTableStyles) - m_pTableStyles.reset(new SwTableAutoFormatTable); + m_pTableStyles.reset(new SwTableAutoFormatTable(SwModule::get()->GetAutoFormatTable())); return *m_pTableStyles; } diff --git a/sw/source/ui/table/convert.cxx b/sw/source/ui/table/convert.cxx index 7e348f88e3c4..a96346eee8fc 100644 --- a/sw/source/ui/table/convert.cxx +++ b/sw/source/ui/table/convert.cxx @@ -95,7 +95,7 @@ SwConvertTableDlg::SwConvertTableDlg(SwView& rView, bool bToTable) , m_nIndex(0) , m_nDfltStylePos(0) , m_bCoreDataChanged(false) - , m_xTableTable(new SwTableAutoFormatTable) + , m_xTableTable(new SwTableAutoFormatTable(SwModule::get()->GetAutoFormatTable())) , m_xTabBtn(m_xBuilder->weld_radio_button(u"tabs"_ustr)) , m_xSemiBtn(m_xBuilder->weld_radio_button(u"semicolons"_ustr)) , m_xParaBtn(m_xBuilder->weld_radio_button(u"paragraph"_ustr)) diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx index 35e6eb41203f..b8a1e32ce611 100644 --- a/sw/source/ui/table/instable.cxx +++ b/sw/source/ui/table/instable.cxx @@ -131,7 +131,7 @@ void SwInsTableDlg::InitAutoTableFormat() m_xLbFormat->connect_selection_changed(LINK(this, SwInsTableDlg, SelFormatHdl)); - m_xTableTable.reset(new SwTableAutoFormatTable); + m_xTableTable.reset(new SwTableAutoFormatTable(SwModule::get()->GetAutoFormatTable())); // Add "- none -" style autoformat table. m_xLbFormat->append_text(SwViewShell::GetShellRes()->aStrNone); // Insert to listbox diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx index f0714867fb44..493693288c20 100644 --- a/sw/source/ui/table/tautofmt.cxx +++ b/sw/source/ui/table/tautofmt.cxx @@ -23,6 +23,7 @@ #include <sal/log.hxx> #include <strings.hrc> #include <shellres.hxx> +#include <swmodule.hxx> #include <tautofmt.hxx> namespace @@ -66,7 +67,7 @@ SwAutoFormatDlg::SwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pWrtShell, b , m_nDfltStylePos(0) , m_bCoreDataChanged(false) , m_bSetAutoFormat(bAutoFormat) - , m_xTableTable(new SwTableAutoFormatTable) + , m_xTableTable(new SwTableAutoFormatTable(SwModule::get()->GetAutoFormatTable())) , m_xLbFormat(m_xBuilder->weld_tree_view(u"formatlb"_ustr)) , m_xBtnNumFormat(m_xBuilder->weld_check_button(u"numformatcb"_ustr)) , m_xBtnBorder(m_xBuilder->weld_check_button(u"bordercb"_ustr)) diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index c8f194c08435..f50e8dc31a7d 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -1170,7 +1170,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) { OUString sAutoFormat = static_cast< const SfxStringItem* >(pItem)->GetValue(); - pAutoFormatTable.reset(new SwTableAutoFormatTable); + pAutoFormatTable.reset(new SwTableAutoFormatTable(SwModule::get()->GetAutoFormatTable())); for( sal_uInt16 i = 0, nCount = pAutoFormatTable->size(); i < nCount; i++ ) { commit 8c252310ae33182a77997a4e3b6e600a66eb5422 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Fri May 30 13:17:51 2025 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Jun 1 20:57:37 2025 +0200 only read-only access to AutoFormatTable needed for these cases. Change-Id: Ie2d7423fee72e993b05d855aa4d56c5514ba626a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186062 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx index 3bcce7fa1c7f..ce9cead72925 100644 --- a/sw/inc/swmodule.hxx +++ b/sw/inc/swmodule.hxx @@ -253,7 +253,7 @@ public: SW_DLLPUBLIC void RegisterAutomationApplicationEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller); void CallAutomationApplicationEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments); - const SwTableAutoFormatTable& GetAutoFormatTable(); + SW_DLLPUBLIC const SwTableAutoFormatTable& GetAutoFormatTable(); void InvalidateAutoFormatTable();; // Access to SwModule diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index f59233add44e..2f5e08b1d833 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -30,6 +30,7 @@ #include <tools/UnitConversion.hxx> #include <editeng/memberids.h> #include <float.h> +#include <swmodule.hxx> #include <swtypes.hxx> #include <cmdid.h> #include <unocoll.hxx> @@ -2451,9 +2452,9 @@ void SwXTextTable::autoFormat(const OUString& sAutoFormatName) SolarMutexGuard aGuard; SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), this); SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFormat), this); - SwTableAutoFormatTable aAutoFormatTable; - for (size_t i = aAutoFormatTable.size(); i;) - if( sAutoFormatName == aAutoFormatTable[ --i ].GetName() ) + const SwTableAutoFormatTable& rAutoFormatTable = SwModule::get()->GetAutoFormatTable(); + for (size_t i = rAutoFormatTable.size(); i;) + if( sAutoFormatName == rAutoFormatTable[ --i ].GetName() ) { SwSelBoxes aBoxes; const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes(); @@ -2463,7 +2464,7 @@ void SwXTextTable::autoFormat(const OUString& sAutoFormatName) aBoxes.insert( pBox ); } UnoActionContext aContext( pFormat->GetDoc() ); - pFormat->GetDoc()->SetTableAutoFormat( aBoxes, aAutoFormatTable[i] ); + pFormat->GetDoc()->SetTableAutoFormat( aBoxes, rAutoFormatTable[i] ); break; } } diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 672943a24a5a..32bce2773636 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -1708,11 +1708,11 @@ void SwInsertDBColAutoPilot::Load() if( !sTmp.isEmpty() ) { // then load the AutoFormat file and look for Autoformat first - SwTableAutoFormatTable aAutoFormatTable; - for( size_t nAutoFormat = aAutoFormatTable.size(); nAutoFormat; ) - if( sTmp == aAutoFormatTable[ --nAutoFormat ].GetName() ) + const SwTableAutoFormatTable& rAutoFormatTable = SwModule::get()->GetAutoFormatTable(); + for( size_t nAutoFormat = rAutoFormatTable.size(); nAutoFormat; ) + if( sTmp == rAutoFormatTable[ --nAutoFormat ].GetName() ) { - m_xTAutoFormat.reset(new SwTableAutoFormat(aAutoFormatTable[nAutoFormat])); + m_xTAutoFormat.reset(new SwTableAutoFormat(rAutoFormatTable[nAutoFormat])); break; } } diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index c20aa3da634d..c8f194c08435 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -3208,12 +3208,12 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest ) aAutoNameIn = pAuto->GetValue(); if ( !aAutoNameIn.isEmpty() ) { - SwTableAutoFormatTable aTableTable; - for ( size_t n=0; n<aTableTable.size(); n++ ) + const SwTableAutoFormatTable& rTableTable = SwModule::get()->GetAutoFormatTable(); + for (size_t n = 0; n < rTableTable.size(); ++n) { - if ( aTableTable[n].GetName() == aAutoNameIn ) + if (rTableTable[n].GetName() == aAutoNameIn) { - pTAFormatIn.reset(new SwTableAutoFormat( aTableTable[n] )); + pTAFormatIn.reset(new SwTableAutoFormat(rTableTable[n])); break; } }