summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/ww8par5.cxx
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2023-01-17 20:46:25 -0500
committerJustin Luth <jluth@mail.com>2023-01-18 13:44:59 +0000
commitf610082534745e88fd1fbfd8059948c38fb88fb6 (patch)
tree0ff741be86abacab72abc54cdf209138d2b2229e /sw/source/filter/ww8/ww8par5.cxx
parenteb760387efbc804c8a8b0c1cc630d6dba2699284 (diff)
tdf#114537 doc import: trim switches before evaluating FIELD_IF
Although this function is only used for ww8 import (and qa tests), it is documented as being more generic. So I decided to just trim at the source and not try to introduce any MS-isms into the parse function. Something similar will be needed for DOCX, but DOCX import for FIELD_IF is completely missing. Change-Id: I822b400e3e53abd953f4c382947f0e80ae62b234 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145691 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'sw/source/filter/ww8/ww8par5.cxx')
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 7e7cedd3f4b5..35cb2b507369 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -623,12 +623,28 @@ sal_uInt16 SwWW8ImplReader::End_Field()
case ww::eIF: // IF-field
{
// conditional field parameters
- const OUString& fieldDefinition = m_aFieldStack.back().GetBookmarkCode();
+ OUString fieldDefinition = m_aFieldStack.back().GetBookmarkCode();
OUString paramCondition;
OUString paramTrue;
OUString paramFalse;
+ // ParseIfFieldDefinition expects: IF <some condition> "true result" "false result"
+ // while many fields include '\* MERGEFORMAT' after that.
+ // So first trim off the switches that are not supported anyway
+ sal_Int32 nLastIndex = fieldDefinition.lastIndexOf("\\*");
+ sal_Int32 nOtherIndex = fieldDefinition.lastIndexOf("\\#"); //number format
+ if (nOtherIndex > 0 && (nOtherIndex < nLastIndex || nLastIndex < 0))
+ nLastIndex = nOtherIndex;
+ nOtherIndex = fieldDefinition.lastIndexOf("\\@"); //date format
+ if (nOtherIndex > 0 && (nOtherIndex < nLastIndex || nLastIndex < 0))
+ nLastIndex = nOtherIndex;
+ nOtherIndex = fieldDefinition.lastIndexOf("\\!"); //locked result
+ if (nOtherIndex > 0 && (nOtherIndex < nLastIndex || nLastIndex < 0))
+ nLastIndex = nOtherIndex;
+ if (nLastIndex > 0)
+ fieldDefinition = fieldDefinition.copy(0, nLastIndex);
+
SwHiddenTextField::ParseIfFieldDefinition(fieldDefinition, paramCondition, paramTrue, paramFalse);
// create new field