sw/inc/tblafmt.hxx | 3 ++ sw/source/core/doc/tblafmt.cxx | 39 +++++++++++++++++++++++++++++++++ sw/source/core/unocore/unostyle.cxx | 5 +++- xmloff/source/table/XMLTableExport.cxx | 2 - 4 files changed, 47 insertions(+), 2 deletions(-)
New commits: commit 6fc9264fd967a51a91de401ba871d2642e57f9df Author: karthik <[email protected]> AuthorDate: Tue Feb 17 12:18:43 2026 +0530 Commit: Karthik Godha <[email protected]> CommitDate: Tue Feb 17 14:26:05 2026 +0100 tdf#170771: Export only edited table styles Instead of exporting all table styles, export only the ones which were edited. Note that this will export the edited table style even when it is not used in the document, this is intentional. Change-Id: I3ad0587352defc81828e7de7015ee7cb5cb3af76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199514 Reviewed-by: Karthik Godha <[email protected]> Reviewed-by: Heiko Tietze <[email protected]> Tested-by: Heiko Tietze <[email protected]> diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index 069a8f65c8c5..a4540b1f1ba2 100644 --- a/sw/inc/tblafmt.hxx +++ b/sw/inc/tblafmt.hxx @@ -59,6 +59,7 @@ public: /// Comparing based of boxes backgrounds. bool operator==(const SwBoxAutoFormat& rRight) const; + bool IsSameAs(const SwBoxAutoFormat& rBox) const; const SvxFrameDirectionItem& GetTextOrientation() const { return *m_aTextOrientation; } const SwFormatVertOrient& GetVerticalAlignment() const { return *m_aVerticalAlignment; } @@ -145,6 +146,8 @@ public: SvNumberFormatter const*); void FillToItemSet(size_t nIndex, SfxItemSet& rItemSet, SvNumberFormatter* pNFormatr) const; + bool NeedsExport(); + /// These methods returns what style (row or column) is applied first on given Cell bool FirstRowEndColumnIsRow(); bool FirstRowStartColumnIsRow(); diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 5005421b7236..0fcc2e27453c 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -209,6 +209,29 @@ bool SwBoxAutoFormat::operator==(const SwBoxAutoFormat& rRight) const return GetBackground().GetColor() == rRight.GetBackground().GetColor(); } +bool SwBoxAutoFormat::IsSameAs(const SwBoxAutoFormat& rRight) const +{ + if (GetFont() == rRight.GetFont() && GetHeight() == rRight.GetHeight() + && GetWeight() == rRight.GetWeight() && GetPosture() == rRight.GetPosture() && + + GetCJKFont() == rRight.GetCJKFont() && GetCJKHeight() == rRight.GetCJKHeight() + && GetCJKWeight() == rRight.GetCJKWeight() && GetCJKPosture() == rRight.GetCJKPosture() && + + GetCTLFont() == rRight.GetCTLFont() && GetCTLHeight() == rRight.GetCTLHeight() + && GetCTLWeight() == rRight.GetCTLWeight() && GetCTLPosture() == rRight.GetCTLPosture() && + + GetUnderline() == rRight.GetUnderline() && GetColor() == rRight.GetColor() + && GetAdjust() == rRight.GetAdjust() && GetVerJustify() == rRight.GetVerJustify() && + + GetBackground() == rRight.GetBackground() && + + GetBox() == rRight.GetBox()) + { + return true; + } + return false; +} + void SwBoxAutoFormat::SetXObject(rtl::Reference<SwXTextCellStyle> const& xObject) { m_xAutoFormatUnoObject = xObject.get(); @@ -561,6 +584,22 @@ void SwTableAutoFormat::FillToItemSet(size_t nIndex, SfxItemSet& rItemSet, } } +bool SwTableAutoFormat::NeedsExport() +{ + const SwTableAutoFormat* rDefaultStyle + = SwModule::get()->GetAutoFormatTable().FindAutoFormat(GetName()); + + if (!rDefaultStyle || rDefaultStyle->GetParent() != GetParent()) + return true; + + for (size_t i = 0; i < ELEMENT_COUNT; i++) + { + if (!m_aBoxAutoFormat[i]->IsSameAs(*rDefaultStyle->GetField(i))) + return true; + } + return false; +} + bool SwTableAutoFormat::FirstRowEndColumnIsRow() { if (*GetField(FIRST_ROW) != GetDefaultBoxFormat() diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 4aa6b2f8c0c9..c543a20cdf35 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -4565,6 +4565,9 @@ sal_Bool SAL_CALL SwXTextTableStyle::isInUse() if (!m_bPhysical) return false; + if (m_pTableAutoFormat->NeedsExport()) + return true; + for (const SwTableFormat* pFormat : *m_pDocShell->GetDoc()->GetTableFrameFormats()) { if(pFormat->IsUsed()) @@ -4934,7 +4937,7 @@ sal_Bool SAL_CALL SwXTextCellStyle::isInUse() if (!xStyle.is()) return false; - return true; + return xStyle->isInUse(); } OUString SAL_CALL SwXTextCellStyle::getParentStyle() { return m_sParentName; } diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx index c22e68db1609..455319dfcdf7 100644 --- a/xmloff/source/table/XMLTableExport.cxx +++ b/xmloff/source/table/XMLTableExport.cxx @@ -608,7 +608,7 @@ void XMLTableExport::exportTableTemplates() { } - if (!xTableStyle->isInUse() && !bPhysical && !mbWriter) + if (!xTableStyle->isInUse() && !bPhysical) continue; const TableStyleElement* pElements;
