summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/ww8atr.cxx
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-10-01 17:42:48 +0200
committerLászló Németh <nemeth@numbertext.org>2021-10-04 08:22:23 +0200
commit05f92eb1359c399c43d3bcbe8942034408fa23eb (patch)
tree84e4c5fcdd8f8fd84f25160db52b17dd64e0a50f /sw/source/filter/ww8/ww8atr.cxx
parentf8e086f185b31f753074fd22ecc73c44b193a784 (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/source/filter/ww8/ww8atr.cxx')
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx20
1 files changed, 12 insertions, 8 deletions
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())