sw/qa/extras/ooxmlexport/data/nospacing_hidden.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 11 +++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 10 +++++++--- 3 files changed, 18 insertions(+), 3 deletions(-)
New commits: commit bb4d5c5fe416bca48553e47e7ec0045f75124f27 Author: Szymon Kłos <[email protected]> AuthorDate: Tue Nov 25 08:39:33 2025 +0000 Commit: Szymon Kłos <[email protected]> CommitDate: Sat Nov 29 09:25:49 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]> 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 c49120ac2834..c93d86e7a318 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -209,6 +209,17 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf169274) assertXPath(pXmlDoc, sPath + "w:sdtContent/w:sdt", 0); } +CPPUNIT_TEST_FIXTURE(Test, testQFormatPreservation) +{ + loadAndSave("nospacing_hidden.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 a370869514b7..d9c40f51a189 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6905,7 +6905,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; @@ -6913,6 +6916,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 { @@ -6990,8 +6994,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);
