From 65d6173152deab49f9c9ed138f6d9fa56008b800 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 13 Nov 2020 09:45:47 +0100 Subject: DOCX import: lost cached result of fields: fix leading whitespace " IF " and "IF " is the same, but "IFF " is something different. Change-Id: Ieb2d128d28ed3daa3df73128804bcc40dda9878d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105783 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'writerfilter/source/dmapper') diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 0a7ae26d937e..d1d0309a6b83 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -206,7 +206,15 @@ static FieldContextPtr GetParentFieldContext(const std::deque& static bool IsFieldNestingAllowed(const FieldContextPtr& pOuter, const FieldContextPtr& pInner) { std::optional oOuterFieldId = pOuter->GetFieldId(); - if (!oOuterFieldId && pOuter->GetCommand().startsWith(" IF ")) + OUString aCommand = pOuter->GetCommand(); + + // Ignore leading space before the field name, but don't accept IFF when we check for IF. + if (!aCommand.isEmpty() && aCommand[0] == ' ') + { + aCommand = aCommand.subView(1); + } + + if (!oOuterFieldId && aCommand.startsWith("IF ")) { // This will be FIELD_IF once the command is closed. oOuterFieldId = FIELD_IF; -- cgit v1.2.3