diff options
author | László Németh <nemeth@numbertext.org> | 2021-10-01 17:42:48 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-10-04 08:22:23 +0200 |
commit | 05f92eb1359c399c43d3bcbe8942034408fa23eb (patch) | |
tree | 84e4c5fcdd8f8fd84f25160db52b17dd64e0a50f /sw | |
parent | f8e086f185b31f753074fd22ecc73c44b193a784 (diff) |
tdf#77051 DOCX: fix user index and index entry support
defined by field code \f.
E.g. INDEX \f "user-index" inserts only the entries
defined by XE "entry" \f "user-index" field codes.
Revert commit a7bc9c1e4977bd3430df69287fa0a8377a686c58
"fdo#77051: Preservation of Index field flag '\f'", which
added an undocumented UNO property only for round-trip
support of INDEX, but not for XE index entries, so the
DOCX export still resulted a broken index with lost
entries, not only the import was broken because of the
missing functionality in com.sun.star.text.DocumentIndex.
Now the import uses com.sun.star.text.UserIndex and
com.sun.star.text.UserIndexMark index and index entry
fields, which support the requested user index not
only during the DOCX and OpenDocument round-trip, but
its run-time functionality, the multiple user-defined
indices.
Note: for manual testing, update the user index (the
first index) of the left original unit test document
IndexFieldFlagF.docx: the updated index is not empty,
as before, but contains the user index entries.
Change-Id: Ia6139bba88907051fd050cfd40809f5544b9a89e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122930
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/tox.hxx | 19 | ||||
-rw-r--r-- | sw/inc/unomap.hxx | 1 | ||||
-rw-r--r-- | sw/inc/unoprnms.hxx | 1 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/tox/tox.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/unocore/unoidx.cxx | 25 | ||||
-rw-r--r-- | sw/source/core/unocore/unomap.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 17 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 20 |
9 files changed, 33 insertions, 64 deletions
diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx index e16882e87afa..77f7e6cd5e5b 100644 --- a/sw/inc/tox.hxx +++ b/sw/inc/tox.hxx @@ -99,7 +99,6 @@ class SW_DLLPUBLIC SwTOXMark final sal_uInt16 m_nLevel; OUString m_aBookmarkName; - OUString m_aEntryTypeName; // stored specific entry type name for INDEX field \f bool m_bAutoGenerated; // generated using a concordance file bool m_bMainEntry; // main entry emphasized by character style @@ -136,8 +135,6 @@ public: inline sal_uInt16 GetLevel() const; inline void SetBookmarkName( const OUString& bName); inline const OUString& GetBookmarkName() const; - inline void SetEntryTypeName( const OUString& sName); - inline const OUString& GetEntryTypeName() const; // for alphabetical index only inline void SetPrimaryKey(const OUString& rStr ); @@ -381,7 +378,6 @@ enum class SwTOXElement : sal_uInt16 Bookmark = 0x0400, Newline = 0x0800, ParagraphOutlineLevel = 0x1000, - IndexEntryType = 0x2000, }; namespace o3tl { template<> struct typed_flags<SwTOXElement> : is_typed_flags<SwTOXElement, 0x3fff> {}; @@ -432,7 +428,6 @@ class SW_DLLPUBLIC SwTOXBase : public SwClient OUString m_aName; // unique name OUString m_aTitle; // title OUString m_aBookmarkName; //Bookmark Name - OUString m_aEntryTypeName; // Type name OUString m_sMainEntryCharStyle; // name of the character style applied to main index entries @@ -507,10 +502,6 @@ public: const OUString& GetMainEntryCharStyle() const {return m_sMainEntryCharStyle;} void SetMainEntryCharStyle(const OUString& rSet) {m_sMainEntryCharStyle = rSet;} - // for record the Index field expression of MS Word - const OUString& GetEntryTypeName() const; - void SetEntryTypeName(const OUString& sName); - // content index only inline void SetLevel(sal_uInt16); // consider outline level inline sal_uInt16 GetLevel() const; @@ -582,9 +573,6 @@ inline const OUString& SwTOXMark::GetAlternativeText() const inline const OUString& SwTOXMark::GetBookmarkName() const { return m_aBookmarkName; } -inline const OUString& SwTOXMark::GetEntryTypeName() const - { return m_aEntryTypeName; } - inline const SwTOXType* SwTOXMark::GetTOXType() const { return m_pType; } @@ -601,10 +589,6 @@ inline void SwTOXMark::SetBookmarkName(const OUString& bName) m_aBookmarkName = bName; } -inline void SwTOXMark::SetEntryTypeName(const OUString& sName) -{ - m_aEntryTypeName = sName; -} inline void SwTOXMark::SetLevel( sal_uInt16 nLvl ) { SAL_WARN_IF( GetTOXType() && GetTOXType()->GetType() == TOX_INDEX, "sw", "Wrong type"); @@ -723,9 +707,6 @@ inline const OUString& SwTOXBase::GetTitle() const inline const OUString& SwTOXBase::GetBookmarkName() const { return m_aBookmarkName; } -inline const OUString& SwTOXBase::GetEntryTypeName() const - { return m_aEntryTypeName; } - inline OUString const & SwTOXBase::GetTypeName() const { return GetTOXType()->GetTypeName(); } diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx index d2c54d204188..c4c166032983 100644 --- a/sw/inc/unomap.hxx +++ b/sw/inc/unomap.hxx @@ -223,7 +223,6 @@ struct SfxItemPropertyMapEntry; #define WID_TOC_BOOKMARK 1061 #define WID_TOC_NEWLINE 1062 #define WID_TOC_PARAGRAPH_OUTLINE_LEVEL 1063 -#define WID_INDEX_ENTRY_TYPE 1064 // Text document #define WID_DOC_CHAR_COUNT 1000 diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index a823d381e607..7ef5d0a58cd7 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -490,7 +490,6 @@ #define UNO_NAME_HIDE_FIELD_TIPS "HideFieldTips" #define UNO_NAME_PARA_SHADOW_FORMAT "ParaShadowFormat" #define UNO_NAME_CONTOUR_POLY_POLYGON "ContourPolyPolygon" -#define UNO_NAME_INDEX_ENTRY_TYPE "IndexEntryType" #define UNO_NAME_IS_PIXEL_CONTOUR "IsPixelContour" #define UNO_NAME_IS_AUTOMATIC_CONTOUR "IsAutomaticContour" diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index f6e6ea78bc99..658830274534 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -290,7 +290,11 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testIndexFieldFlagF,"IndexFieldFlagF.docx") // Specific Entry Type (ex. "Syn" in our case). xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); // We check the Index field flag '\f'. - assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[4]/w:r[2]/w:instrText[1]", " INDEX \\c \"2\"\\f \"Syn\" \" \\e \""); + // Note: no syntax error any more (extra quotation mark between "Syn" and \e) + assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[4]/w:r[2]/w:instrText[1]", " INDEX \\c \"2\"\\f \"Syn\"\\e \""); + // XE entries lost their \f "Syn" before + assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[17]/w:r[21]/w:instrText[1]", " XE \"formatting\" \\f \"Syn\" "); + assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[17]/w:r[29]/w:instrText[1]", " XE \"choosing:aaaa\" \\f \"Syn\" "); } DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testBibliography,"FDO75133.docx") diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index 65462bf44f80..0af14542e2de 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -590,7 +590,6 @@ void SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource ) m_aTitle = rSource.m_aTitle; m_aForm = rSource.m_aForm; m_aBookmarkName = rSource.m_aBookmarkName; - m_aEntryTypeName = rSource.m_aEntryTypeName ; m_bProtected = rSource.m_bProtected; m_bFromChapter = rSource.m_bFromChapter; m_bFromObjectNames = rSource.m_bFromObjectNames; @@ -629,18 +628,12 @@ void SwTOXBase::SetBookmarkName(const OUString& bName) m_aBookmarkName = bName; } -void SwTOXBase::SetEntryTypeName(const OUString& sName) -{ - m_aEntryTypeName = sName ; -} - SwTOXBase & SwTOXBase::operator = (const SwTOXBase & rSource) { m_aForm = rSource.m_aForm; m_aName = rSource.m_aName; m_aTitle = rSource.m_aTitle; m_aBookmarkName = rSource.m_aBookmarkName; - m_aEntryTypeName = rSource.m_aEntryTypeName ; m_sMainEntryCharStyle = rSource.m_sMainEntryCharStyle; for(sal_uInt16 nLevel = 0; nLevel < MAXLEVEL; nLevel++) m_aStyleNames[nLevel] = rSource.m_aStyleNames[nLevel]; diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index b7f2681953a0..5e2e39a49a21 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -633,13 +633,6 @@ SwXDocumentIndex::setPropertyValue( rTOXBase.SetCreate(nCreate); } break; - case WID_INDEX_ENTRY_TYPE: - { - rTOXBase.SetEntryTypeName(lcl_AnyToType<OUString>(rValue)); - nCreate = SwTOXElement::IndexEntryType; - rTOXBase.SetCreate(nCreate); - } - break; case WID_CREATE_FROM_MARKS: lcl_AnyToBitMask(rValue, nCreate, SwTOXElement::Mark); break; @@ -954,9 +947,6 @@ SwXDocumentIndex::getPropertyValue(const OUString& rPropertyName) case WID_TOC_BOOKMARK : aRet <<= pTOXBase->GetBookmarkName(); break; - case WID_INDEX_ENTRY_TYPE : - aRet <<= pTOXBase->GetEntryTypeName(); - break; case WID_CREATE_FROM_MARKS: lcl_BitMaskToAny(aRet, nCreate, SwTOXElement::Mark); break; @@ -1506,7 +1496,6 @@ public: bool m_bMainEntry; sal_uInt16 m_nLevel; OUString m_aBookmarkName; - OUString m_aEntryTypeName; OUString m_sAltText; OUString m_sPrimaryKey; OUString m_sSecondaryKey; @@ -2075,9 +2064,6 @@ SwXDocumentIndexMark::setPropertyValue( case WID_TOC_BOOKMARK : aMark.SetBookmarkName(lcl_AnyToType<OUString>(rValue)); break; - case WID_INDEX_ENTRY_TYPE : - aMark.SetEntryTypeName(lcl_AnyToType<OUString>(rValue)); - break; case WID_PRIMARY_KEY : aMark.SetPrimaryKey(lcl_AnyToType<OUString>(rValue)); break; @@ -2134,11 +2120,6 @@ SwXDocumentIndexMark::setPropertyValue( m_pImpl->m_aBookmarkName = lcl_AnyToType<OUString>(rValue); } break; - case WID_INDEX_ENTRY_TYPE : - { - m_pImpl->m_aEntryTypeName = lcl_AnyToType<OUString>(rValue); - } - break; case WID_PRIMARY_KEY: m_pImpl->m_sPrimaryKey = lcl_AnyToType<OUString>(rValue); break; @@ -2209,9 +2190,6 @@ SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) case WID_TOC_BOOKMARK : aRet <<= m_pImpl->m_pTOXMark->GetBookmarkName(); break; - case WID_INDEX_ENTRY_TYPE : - aRet <<= m_pImpl->m_pTOXMark->GetEntryTypeName(); - break; case WID_PRIMARY_KEY : aRet <<= m_pImpl->m_pTOXMark->GetPrimaryKey(); break; @@ -2255,9 +2233,6 @@ SwXDocumentIndexMark::getPropertyValue(const OUString& rPropertyName) case WID_TOC_BOOKMARK : aRet <<= m_pImpl->m_aBookmarkName; break; - case WID_INDEX_ENTRY_TYPE : - aRet <<= m_pImpl->m_aEntryTypeName; - break; case WID_PRIMARY_KEY: aRet <<= m_pImpl->m_sPrimaryKey; break; diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 3580a8f416a2..4e373b6c511e 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -348,7 +348,6 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s { u"" UNO_NAME_IS_RELATIVE_TABSTOPS, WID_IS_RELATIVE_TABSTOPS, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, { u"" UNO_NAME_LOCALE, WID_IDX_LOCALE, cppu::UnoType<css::lang::Locale>::get(), PROPERTY_NONE, 0}, { u"" UNO_NAME_SORT_ALGORITHM, WID_IDX_SORT_ALGORITHM, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { u"" UNO_NAME_INDEX_ENTRY_TYPE, WID_INDEX_ENTRY_TYPE, cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, { u"", 0, css::uno::Type(), 0, 0 } }; m_aMapEntriesArr[nPropertyId] = aTOXIndexMap_Impl; diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 4856fb16065e..68bd7654f5f9 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -1292,7 +1292,17 @@ void AttributeOutputBase::TOXMark( const SwTextNode& rNode, const SwTOXMark& rAt else sText = rAttr.GetAlternativeText(); - switch ( rAttr.GetTOXType()->GetType() ) + OUString sUserTypeName; + auto aType = rAttr.GetTOXType()->GetType(); + // user index mark, it needs XE with \f + if ( TOX_USER == aType ) + { + sUserTypeName = rAttr.GetTOXType()->GetTypeName(); + if ( !sUserTypeName.isEmpty() ) + aType = TOX_INDEX; + } + + switch ( aType ) { case TOX_INDEX: eType = ww::eXE; @@ -1306,6 +1316,11 @@ void AttributeOutputBase::TOXMark( const SwTextNode& rNode, const SwTOXMark& rAt sText = rAttr.GetPrimaryKey() + ":" + sText; } sText = " XE \"" + sText + "\" "; + + if (!sUserTypeName.isEmpty()) + { + sText += "\\f \"" + sUserTypeName + "\" "; + } break; case TOX_USER: diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 8d5710e2b1cd..de8dbc3f0468 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2248,7 +2248,16 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) OUString sStr = pTOX ->GetMSTOCExpression(); if ( sStr.isEmpty() ) { - switch (pTOX->GetType()) + OUString sUserTypeName; + auto aType = pTOX->GetType(); + // user index, it needs INDEX with \f + if ( TOX_USER == aType ) + { + sUserTypeName = pTOX->GetTOXType()->GetTypeName(); + if ( !sUserTypeName.isEmpty() ) + aType = TOX_INDEX; + } + switch (aType) { case TOX_INDEX: eCode = ww::eINDEX; @@ -2280,14 +2289,9 @@ void AttributeOutputBase::StartTOX( const SwSection& rSect ) if (SwTOIOptions::AlphaDelimiter & pTOX->GetOptions()) sStr += "\\h \"A\" "; - if(SwTOXElement::IndexEntryType & pTOX->GetCreateType()) + if (!sUserTypeName.isEmpty()) { - sStr += "\\f "; - const OUString& sName = pTOX->GetEntryTypeName(); - if(!sName.isEmpty()) - { - sStr += sName + sEntryEnd; - } + sStr += "\\f \"" + sUserTypeName + "\""; } if (!pTOX->GetTOXForm().IsCommaSeparated()) |