summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2023-08-18 21:55:12 -0400
committerJustin Luth <jluth@mail.com>2023-08-20 03:34:41 +0200
commit91358f11ee7e87c8c8290b9507f64d8f90aac3ea (patch)
tree87f545d46f6984270bda30d1ab5e591532964190 /sw/source
parent81c19355d7ad830c2356d7d82e244929be3823a8 (diff)
tdf#148834 docxexport: also write suppressLineNumbers = false
This code also affects DOC export, but shouldn't be detrimental. It just means that some unnecessary sprms will not be added to DOC files. RTF - similar to old DOCX - only outputs if !IsCount, but I didn't find a corresponding "enable" to offset \noline. make CppunitTest_sw_ooxmlexport18 \ CPPUNIT_TEST_NAME=testTdf148834_lineNumbering Change-Id: Ib5369c2f2c24f75dab7d02e3591a4ddefa335ebf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155858 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx1
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx2
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx36
3 files changed, 38 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index d5d92924ba9c..bad43d37843a 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -618,6 +618,7 @@ protected:
virtual void FormatTextGrid( const SwTextGridItem& ) = 0;
/// Sfx item RES_LINENUMBER
+ void FormatLineNumberingBase(const SwFormatLineNumber&);
virtual void FormatLineNumbering( const SwFormatLineNumber& ) = 0;
/// Sfx item RES_FRAMEDIR
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index d6c9c14544b1..df29dd801e08 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -9869,6 +9869,8 @@ void DocxAttributeOutput::FormatLineNumbering( const SwFormatLineNumber& rNumber
{
if ( !rNumbering.IsCount( ) )
m_pSerializer->singleElementNS(XML_w, XML_suppressLineNumbers);
+ else
+ m_pSerializer->singleElementNS(XML_w, XML_suppressLineNumbers, FSNS(XML_w, XML_val), "0");
}
void DocxAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index e3d39a56d4a7..4751047e0f74 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3774,6 +3774,40 @@ void WW8AttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
m_rWW8Export.m_pO->insert( m_rWW8Export.m_pO->end(), aZeroArr, aZeroArr+3);
}
+void AttributeOutputBase::FormatLineNumberingBase(const SwFormatLineNumber& rNumbering)
+{
+ // always write out suppressLineNumberings - even if it matches the parent,
+ // so that even if the parent is modified, special styles/situations won't lose that suppression
+ if (!rNumbering.IsCount())
+ {
+ FormatLineNumbering(rNumbering);
+ return;
+ }
+
+ // Don't spam suppressLineNumberings = false - that is the default when not specified at all
+ if (auto pNd = dynamic_cast<const SwContentNode*>(GetExport().m_pOutFormatNode)) //paragraph
+ {
+ // useless IsCount can be added to paragraph when specifying MID_LINENUMBER_STARTVALUE
+ const auto& rSet = static_cast<SwTextFormatColl&>(pNd->GetAnyFormatColl()).GetAttrSet();
+ const SwFormatLineNumber& rInherited = rSet.GetLineNumber();
+ if (rInherited.IsCount() && rInherited.GetStartValue() != rNumbering.GetStartValue())
+ return; // same IsCount as parent style
+ }
+ else if (GetExport().m_bStyDef) //style
+ {
+ if (GetExport().m_pCurrentStyle && GetExport().m_pCurrentStyle->DerivedFrom())
+ {
+ const auto& rSet = GetExport().m_pCurrentStyle->DerivedFrom()->GetAttrSet();
+ if (rSet.GetLineNumber().IsCount())
+ return; // same as parent style
+ }
+ else
+ return; // same as default value
+ }
+
+ FormatLineNumbering(rNumbering);
+}
+
void AttributeOutputBase::ParaOutlineLevelBase( const SfxUInt16Item& rItem )
{
sal_uInt16 nOutLvl = rItem.GetValue();
@@ -5749,7 +5783,7 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
FormatTextGrid( static_cast< const SwTextGridItem& >( rHt ) );
break;
case RES_LINENUMBER:
- FormatLineNumbering( static_cast< const SwFormatLineNumber& >( rHt ) );
+ FormatLineNumberingBase(static_cast<const SwFormatLineNumber&>(rHt));
break;
case RES_FRAMEDIR:
FormatFrameDirection( static_cast< const SvxFrameDirectionItem& >( rHt ) );