From b3698a6ac2642777ef0c25688e5dd5acde9594ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 21 Aug 2014 08:29:03 +0100 Subject: [PATCH] NS_ooxml::LN_CT_LevelText_val might be missing Change-Id: I2683dd30d521b91cf026b3553ed4f75ee4172b3a --- ...d4c8608af9396952724a0-128299-minimized.rtf | 57 +++++++++++++++++++ .../source/rtftok/rtfdocumentimpl.cxx | 35 ++++++------ 2 files changed, 76 insertions(+), 16 deletions(-) create mode 100644 writerfilter/qa/cppunittests/rtftok/data/fail/sf_edeb1eb341ad4c8608af9396952724a0-128299-minimized.rtf diff --git a/writerfilter/qa/cppunittests/rtftok/data/fail/sf_edeb1eb341ad4c8608af9396952724a0-128299-minimized.rtf b/writerfilter/qa/cppunittests/rtftok/data/fail/sf_edeb1eb341ad4c8608af9396952724a0-128299-minimized.rtf new file mode 100644 index 000000000000..45597c0857e9 --- /dev/null +++ b/writerfilter/qa/cppunittests/rtftok/data/fail/sf_edeb1eb341ad4c8608af9396952724a0-128299-minimized.rtf @@ -0,0 +1,57 @@ +{\rtf1\ansi\ansicpg1252\deff0 +{\fonttbl +{\f0\fnil\fcharset0\fprq0\fttruetype Times New Roman;} +{\f1\fnil\fcharset0\fprq0\fttruetype Nimbus Sans L;} +{\f2\fnil\fcharset0\fprq0\fttruetype Dingbats;} +{\f3\fnil\fcharset0\fprq0\fttruetype Symbol;} +{\f4\fnil\fcharset0\fprq0\fttruetype Courier New;}} +{\colortbl +\red0\green0\blue0; +\red255\green255\blue255;} +{\stylesheet +{\s1\fi-431\li720\sbasedon28\snext28 Contents 1;} +{\s2\fi-431\li1440\sbasedon28\snext28 Contents 2;} +{\s3\fi-431\li2160\sbasedon28\snext28 Contents 3;} +{\s8\fi-431\li720\sbasedon28 Lower Roman List;} +{\s5\tx431\sbasedon24\snext28 Numbered Heading 1;} +{\s6\tx431\sbasedon25\snext28 Numbered Heading 2;} +{\s7\fi-431\li720 Square List;} +{\*\cs11\sbasedon28 Endnote Text;} +{\s4\fi-431\li2880\sbasedon28\snext28 Contents 4;} +{\s9\fi-431\li720 Diamond List;} +{\s10\fi-431\li720 Numbered List;} +{\*\cs12\fs20\super Endnote Reference;} +{\s13\fi-431\li720 Triangle List;} +{\s14\tx431\sbasedon26\snext28 Numbered Heading 3;} +{\s15\fi-431\li720 Dashed List;} +{\s16\fi-431\li720\sbasedon10 Upper Roman List;} +{\s17\sb440\sa60\f1\fs24\b\sbasedon28\snext28 Heading 4;} +{\s18\fi-431\li720 Heart List;} +{\s34\fi-431\li720 Box List;} +{\s20\fi-431\li720\sbasedon10 Upper Case List;} +{\s21\fi-431\li720 Bullet List;} +{\s22\fi-431\li720 Hand List;} +{\*\cs23\fs20\sbasedon28 Footnote Text;} +{\s24\sb440\sa60\f1\fs34\b\sbasedon28\snext28 Heading 1;} +{\s25\sb440\sa60\f1\fs28\b\sbasedon28\snext28 Heading 2;} +{\s19\qc\sb240\sa120\f1\fs32\b\sbasedon28\snext28 Contents Header;} +{\s27\fi-431\li720 Tick List;} +{\s26\sb440\sa60\f1\fs24\b\sbasedon28\snext28 Heading 3;} +{\s29\fi-431\li720\sbasedon10 Lower Case List;} +{\s30\li1440\ri1440\sa120\sbasedon28 Block Text;} +{\s36\f4\sbasedon28 Plain Text;} +{\s32\tx1584\sbasedon5\snext28 Section Heading;} +{\s33\fi-431\li720 Implies List;} +{\s28\f0\fs24\lang1033 Normal;} +{\s35\fi-431\li720 Star List;} +{\*\cs31\fs20\super Footnote Reference;} +{\s37\tx1584\sbasedon5\snext28 Chapter Heading;}} +{\*\listtable +{\list\listtemplateid1002\listsimple{\listlevel\levelnfc0\levelstartat1\levelspAce0\levelfollow0\fi-431\li720{\leveltext\'02\'00.{}{\levelnumbers\'01;}}\listid1000}} +{\*\listoverridetable +{\listoverride\listoverridecount0\listid1000\levelnfc0\levelstartat1\levelspace0\levelfollow0\fi-431\li720{\leveltext\'02\'00.;}{\levelnumbers\'01;}\ls1}} + +\kerning0\cf0\ftnbj\fet2\ftnstart1\ftnnar\aftnnar\ftnstart1\aftnstart1\aenddoc\facingp\titlepg\revprop3{\info}\deftab720\viewkind1\paperw12240\paperh15840\margl1440\margr1440\widowctl +\sectd\sbknone\colsx360\pgncont\ltrsect +{\listtext\pard\fi-431\li720 1. }\pard\plain{\ltrpar\ql\fi-431\li720\s28{\*\abilist\abilistid1000\abilistparentid0\abilistlevel1\abistartat1{\abifieldfont NULL}{\abilistdecimal .}{\abilistdelim %L.}{\abiliststyle Numbered List}}{\*\pn\pnql\pnstart1\pnlvlbody\pndec{\pntxtb AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA}{\pntxta .}}\fn-431\li720\ls1\ilvl0\itap0{\s28\f0\fs24\lang1033{\*\listtag0}\abinodiroverride\ltrch test}{\s28\f0\fs24\lang1033{\*\listtag1001}\par} +}\pard\plain\ltrpar\ql\s28\itap0{\s28\f0\fs24\lang1033{\*\listtag0}\par}} diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 3cd33baeabb8..4fe164e6305a 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -4894,24 +4894,27 @@ int RTFDocumentImpl::popState() { RTFSprms& rAttributes = aState.aTableSprms.find(NS_ooxml::LN_CT_Lvl_lvlText)->getAttributes(); RTFValue::Pointer_t pValue = rAttributes.find(NS_ooxml::LN_CT_LevelText_val); - OUString aOrig = pValue->getString(); - - OUStringBuffer aBuf; - sal_Int32 nReplaces = 1; - for (int i = 0; i < aOrig.getLength(); i++) + if (pValue) { - if (std::find(aState.aLevelNumbers.begin(), aState.aLevelNumbers.end(), i+1) - != aState.aLevelNumbers.end()) - { - aBuf.append('%'); - // '1.1.1' -> '%1.%2.%3', but '1.' (with '2.' prefix omitted) is %2. - aBuf.append(sal_Int32(nReplaces++ + aState.nListLevelNum + 1 - aState.aLevelNumbers.size())); - } - else - aBuf.append(aOrig.copy(i, 1)); - } + OUString aOrig = pValue->getString(); - pValue->setString(aBuf.makeStringAndClear()); + OUStringBuffer aBuf; + sal_Int32 nReplaces = 1; + for (int i = 0; i < aOrig.getLength(); i++) + { + if (std::find(aState.aLevelNumbers.begin(), aState.aLevelNumbers.end(), i+1) + != aState.aLevelNumbers.end()) + { + aBuf.append('%'); + // '1.1.1' -> '%1.%2.%3', but '1.' (with '2.' prefix omitted) is %2. + aBuf.append(sal_Int32(nReplaces++ + aState.nListLevelNum + 1 - aState.aLevelNumbers.size())); + } + else + aBuf.append(aOrig.copy(i, 1)); + } + + pValue->setString(aBuf.makeStringAndClear()); + } } break; case DESTINATION_SHAPEPROPERTYNAME: