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 <karthik.godha@collabora.com>
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Tested-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
karthik
2026-02-17 14:26:05 +01:00
committed by Karthik Godha
parent 08f940a22d
commit 6fc9264fd9
4 changed files with 47 additions and 2 deletions
+3
View File
@@ -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();
+39
View File
@@ -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()
+4 -1
View File
@@ -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; }
+1 -1
View File
@@ -608,7 +608,7 @@ void XMLTableExport::exportTableTemplates()
{
}
if (!xTableStyle->isInUse() && !bPhysical && !mbWriter)
if (!xTableStyle->isInUse() && !bPhysical)
continue;
const TableStyleElement* pElements;