officecfg/registry/schema/org/openoffice/Office/Writer.xcs | 7 ++ sw/inc/tblafmt.hxx | 1 sw/source/core/doc/tblafmt.cxx | 10 ++++ sw/source/core/doc/tblrwcl.cxx | 15 +++++- sw/source/core/docnode/ndtbl.cxx | 32 +++++++++---- sw/source/core/frmedt/fetab.cxx | 1 sw/source/core/undo/untbl.cxx | 8 ++- sw/source/ui/table/instable.cxx | 14 ----- 8 files changed, 65 insertions(+), 23 deletions(-)
New commits: commit 27198ec7031e9ef3bbc592423e5c12e333e206ee Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Jul 18 18:31:19 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Jul 19 10:28:51 2024 +0200 (related tdf#126008) sw: add config to disable table autoformat ... ... automatic updates when editing the table. Office::Writer::Table::Change::ApplyTableAutoFormat Change-Id: I84667c68c9372d7594bb3a688da80495ef46168f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170702 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs index 8497cc87bb67..124e0a3dd931 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs @@ -1955,6 +1955,13 @@ </constraints> <value>2</value> </prop> + <prop oor:name="ApplyTableAutoFormat" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Determines if editing a table causes the table's AutoFormat to be applied automatically to update the formatting of the table and its contents.</desc> + <label>Apply table AutoFormat automatically when table is edited.</label> + </info> + <value>true</value> + </prop> </group> <group oor:name="Input"> <info> diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 38c5074f0e89..1e8ec32c136b 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -19,6 +19,7 @@ #include <memory> #include <com/sun/star/text/HoriOrientation.hpp> +#include <officecfg/Office/Writer.hxx> #include <osl/diagnose.h> #include <svl/numformat.hxx> #include <hintids.hxx> @@ -507,7 +508,12 @@ bool SwTable::InsertCol( SwDoc& rDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, rDoc.UpdateCharts( GetFrameFormat()->GetName() ); if (SwFEShell* pFEShell = rDoc.GetDocShell()->GetFEShell()) - pFEShell->UpdateTableStyleFormatting(); + { + if (officecfg::Office::Writer::Table::Change::ApplyTableAutoFormat::get()) + { + pFEShell->UpdateTableStyleFormatting(); + } + } return bRes; } @@ -631,7 +637,12 @@ bool SwTable::InsertRow_( SwDoc* pDoc, const SwSelBoxes& rBoxes, pDoc->UpdateCharts( GetFrameFormat()->GetName() ); if (SwFEShell* pFEShell = pDoc->GetDocShell()->GetFEShell()) - pFEShell->UpdateTableStyleFormatting(pTableNd); + { + if (officecfg::Office::Writer::Table::Change::ApplyTableAutoFormat::get()) + { + pFEShell->UpdateTableStyleFormatting(pTableNd); + } + } return true; } diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index a3f2de6507f3..3d6ba9e8ab2d 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -89,6 +89,7 @@ #include <calbck.hxx> #include <fntcache.hxx> #include <frameformats.hxx> +#include <officecfg/Office/Writer.hxx> #include <o3tl/numeric.hxx> #include <o3tl/string_view.hxx> #include <svl/numformat.hxx> @@ -2120,9 +2121,6 @@ void SwDoc::DelTable(SwTableNode *const pTableNd) getIDocumentContentOperations().DeleteSection( pTableNd ); } - if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) - pFEShell->UpdateTableStyleFormatting(); - getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); } @@ -2194,7 +2192,12 @@ bool SwDoc::DeleteRowCol(const SwSelBoxes& rBoxes, RowColMode const eMode) if (bRet) { if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) - pFEShell->UpdateTableStyleFormatting(); + { + if (officecfg::Office::Writer::Table::Change::ApplyTableAutoFormat::get()) + { + pFEShell->UpdateTableStyleFormatting(); + } + } getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); @@ -2257,7 +2260,12 @@ bool SwDoc::SplitTable( const SwSelBoxes& rBoxes, bool bVert, sal_uInt16 nCnt, if (bRet) { if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) - pFEShell->UpdateTableStyleFormatting(); + { + if (officecfg::Office::Writer::Table::Change::ApplyTableAutoFormat::get()) + { + pFEShell->UpdateTableStyleFormatting(); + } + } getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); @@ -3286,8 +3294,11 @@ void SwDoc::SplitTable( const SwPosition& rPos, SplitTable_HeadlineOption eHdlnM // update table style formatting of both the tables if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) { - pFEShell->UpdateTableStyleFormatting(pTNd); - pFEShell->UpdateTableStyleFormatting(pNew); + if (officecfg::Office::Writer::Table::Change::ApplyTableAutoFormat::get()) + { + pFEShell->UpdateTableStyleFormatting(pTNd); + pFEShell->UpdateTableStyleFormatting(pNew); + } } getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); @@ -3561,7 +3572,12 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool bWithPrev ) if( bRet ) { if (SwFEShell* pFEShell = GetDocShell()->GetFEShell()) - pFEShell->UpdateTableStyleFormatting(); + { + if (officecfg::Office::Writer::Table::Change::ApplyTableAutoFormat::get()) + { + pFEShell->UpdateTableStyleFormatting(); + } + } getIDocumentState().SetModified(); getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, SwNodeOffset(0) ); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index caae49e6f8a2..0f515b942d8c 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -62,6 +62,7 @@ #include <calbck.hxx> #include <frameformats.hxx> #include <editeng/formatbreakitem.hxx> +#include <officecfg/Office/Writer.hxx> #include <osl/diagnose.h> #include <docsh.hxx> @@ -1784,7 +1785,12 @@ void SwUndoTableNdsChg::UndoImpl(::sw::UndoRedoContext & rContext) // TL_CHART2: need to inform chart of probably changed cell names rDoc.UpdateCharts( pTableNd->GetTable().GetFrameFormat()->GetName() ); if (SwFEShell* pFEShell = rDoc.GetDocShell()->GetFEShell()) - pFEShell->UpdateTableStyleFormatting(pTableNd); + { + if (officecfg::Office::Writer::Table::Change::ApplyTableAutoFormat::get()) + { + pFEShell->UpdateTableStyleFormatting(pTableNd); + } + } if( IsDelBox() ) m_nSttNode = pTableNd->GetIndex(); ClearFEShellTabCols(rDoc, nullptr); commit 1e978fffddc3d7044f3def026340844b59d2d656 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Jul 18 13:21:50 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Jul 19 10:28:41 2024 +0200 (related tdf#126008) sw: when removing table auto format, don't... ... change the formatting. Change-Id: I50fbb290f0a7f2cccc2559059859fa820d5c9aba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170688 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index dbbec1909ae2..16f84d8ad42c 100644 --- a/sw/inc/tblafmt.hxx +++ b/sw/inc/tblafmt.hxx @@ -225,6 +225,7 @@ public: /// Check if style is defined by user. bool IsUserDefined() const { return m_bUserDefined; } + void DisableAll(); void SetFont( const bool bNew ) { m_bInclFont = bNew; } void SetJustify( const bool bNew ) { m_bInclJustify = bNew; } void SetFrame( const bool bNew ) { m_bInclFrame = bNew; } diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index c348688e954e..8b3e4bd30f88 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -441,6 +441,16 @@ SwTableAutoFormat::~SwTableAutoFormat() delete *ppFormat; } +void SwTableAutoFormat::DisableAll() +{ + SetFont(false); + SetJustify(false); + SetFrame(false); + SetBackground(false); + SetValueFormat(false); + SetWidthHeight(false); +} + void SwTableAutoFormat::SetBoxFormat( const SwBoxAutoFormat& rNew, sal_uInt8 nPos ) { OSL_ENSURE( nPos < 16, "wrong area" ); diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index eda5200dba0c..625c05b97dde 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -1447,6 +1447,7 @@ bool SwFEShell::UpdateTableStyleFormatting(SwTableNode *pTableNode, if (pStyleName && pStyleName->isEmpty()) { pNone.reset(new SwTableAutoFormat(SwViewShell::GetShellRes()->aStrNone)); + pNone->DisableAll(); pTableStyle = pNone.get(); } else diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx index c0e443676a1c..2bdd6c7cac50 100644 --- a/sw/source/ui/table/instable.cxx +++ b/sw/source/ui/table/instable.cxx @@ -173,16 +173,6 @@ sal_uInt8 SwInsTableDlg::lbIndexToTableIndex( const sal_uInt8 listboxIndex ) return 255; } -static void lcl_SetProperties( SwTableAutoFormat* pTableAutoFormat, bool bVal ) -{ - pTableAutoFormat->SetFont( bVal ); - pTableAutoFormat->SetJustify( bVal ); - pTableAutoFormat->SetFrame( bVal ); - pTableAutoFormat->SetBackground( bVal ); - pTableAutoFormat->SetValueFormat( bVal ); - pTableAutoFormat->SetWidthHeight( bVal ); -} - IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, weld::TreeView&, void) { // Get index of selected item from the listbox @@ -196,7 +186,7 @@ IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, weld::TreeView&, void) else { SwTableAutoFormat aTmp( SwViewShell::GetShellRes()->aStrNone ); - lcl_SetProperties( &aTmp, false ); + aTmp.DisableAll(); m_aWndPreview.NotifyChange( aTmp ); } @@ -217,7 +207,7 @@ IMPL_LINK_NOARG(SwInsTableDlg, OKHdl, weld::Button&, void) else { m_xTAutoFormat.reset(new SwTableAutoFormat( SwViewShell::GetShellRes()->aStrNone )); - lcl_SetProperties( m_xTAutoFormat.get(), false ); + m_xTAutoFormat->DisableAll(); } m_xDialog->response(RET_OK);