sw/qa/extras/ooxmlexport/data/nospacing_hidden.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 12 ++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 10 +++++++--- 3 files changed, 19 insertions(+), 3 deletions(-)
New commits: commit 5bee91d5d1ed57d103c79bc09173411c081bb99e Author: Szymon Kłos <[email protected]> AuthorDate: Tue Nov 25 08:39:33 2025 +0000 Commit: Szymon Kłos <[email protected]> CommitDate: Tue Dec 16 13:22:51 2025 +0100 sw: preserve status of qFormat on export - so far we don't have UI to change "favourite" setting - value from the import if it was explicitly set to false should be preserved Change-Id: I9a2ad637a70ea4c90233f157676d4c71e7ab0f86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194511 Reviewed-by: Szymon Kłos <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194807 Tested-by: Jenkins diff --git a/sw/qa/extras/ooxmlexport/data/nospacing_hidden.docx b/sw/qa/extras/ooxmlexport/data/nospacing_hidden.docx new file mode 100644 index 000000000000..43d2692e6807 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/nospacing_hidden.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index 714329a85aa6..05196bc96e26 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -343,6 +343,18 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf169274) assertXPath(pXmlDoc, sPath + "w:sdtContent/w:sdt", 0); } +CPPUNIT_TEST_FIXTURE(Test, testQFormatPreservation) +{ + createSwDoc("nospacing_hidden.docx"); + save(TestFilter::DOCX); + + xmlDocUniquePtr pXmlStyles = parseExport(u"word/styles.xml"_ustr); + + assertXPath(pXmlStyles, "//w:style[@w:styleId='Heading']/w:qFormat", 1); + // not used currently and had qFormat = 0 on import + assertXPath(pXmlStyles, "//w:style[@w:styleId='No spacing']/w:qFormat", 0); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 1364be083a1b..4a0b6cfdb082 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6919,7 +6919,10 @@ static bool lcl_guessQFormat(const OUString& rName, sal_uInt16 nWwId) void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType, sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 nLink, sal_uInt16 nWwId, sal_uInt16 nSlot, bool bAutoUpdate ) { - bool bQFormat = false, bUnhideWhenUsed = false, bSemiHidden = false, bLocked = false, bDefault = false, bCustomStyle = false; + bool bUnhideWhenUsed = false, bSemiHidden = false, bLocked = false, bDefault = false, bCustomStyle = false; + bool bQFormat = false; // DEPRECATED: from grab-bag + bool bRealQFormat = true; // from SwFormat + OUString aRsid, aUiPriority; rtl::Reference<FastAttributeList> pStyleAttributeList = FastSerializerHelper::createAttrList(); uno::Any aAny; @@ -6927,6 +6930,7 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType, { const SwFormat* pFormat = m_rExport.m_pStyles->GetSwFormat(nSlot); pFormat->GetGrabBagItem(aAny); + bRealQFormat = pFormat->IsFavourite(); } else { @@ -7004,8 +7008,8 @@ void DocxAttributeOutput::StartStyle( const OUString& rName, StyleType eType, m_pSerializer->singleElementNS(XML_w, XML_semiHidden); if (bUnhideWhenUsed) m_pSerializer->singleElementNS(XML_w, XML_unhideWhenUsed); - - if (bQFormat || lcl_guessQFormat(rName, nWwId)) + // by default we use old quess, if user marks style as non-favourite -> do not export qFormat + if (bRealQFormat && (bQFormat || lcl_guessQFormat(rName, nWwId))) m_pSerializer->singleElementNS(XML_w, XML_qFormat); if (bLocked) m_pSerializer->singleElementNS(XML_w, XML_locked);
