LCOV - code coverage report
Current view: top level - writerfilter/source/rtftok - rtfdocumentimpl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1929 2463 78.3 %
Date: 2012-08-25 Functions: 74 78 94.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3363 7305 46.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       3                 :            :  *
       4                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       5                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       6                 :            :  * the License. You may obtain a copy of the License at
       7                 :            :  * http://www.mozilla.org/MPL/
       8                 :            :  *
       9                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      10                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11                 :            :  * for the specific language governing rights and limitations under the
      12                 :            :  * License.
      13                 :            :  *
      14                 :            :  * The Initial Developer of the Original Code is
      15                 :            :  *       Miklos Vajna <vmiklos@frugalware.org>
      16                 :            :  * Portions created by the Initial Developer are Copyright (C) 2011 the
      17                 :            :  * Initial Developer. All Rights Reserved.
      18                 :            :  *
      19                 :            :  * Contributor(s):
      20                 :            :  *
      21                 :            :  * Alternatively, the contents of this file may be used under the terms of
      22                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      23                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      24                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      25                 :            :  * instead of those above.
      26                 :            :  */
      27                 :            : 
      28                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      29                 :            : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      30                 :            : #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
      31                 :            : #include <com/sun/star/graphic/GraphicProvider.hpp>
      32                 :            : #include <com/sun/star/io/UnexpectedEOFException.hpp>
      33                 :            : #include <com/sun/star/text/XTextFrame.hpp>
      34                 :            : #include <com/sun/star/text/SizeType.hpp>
      35                 :            : #include <com/sun/star/text/HoriOrientation.hpp>
      36                 :            : #include <com/sun/star/text/VertOrientation.hpp>
      37                 :            : #include <com/sun/star/text/RelOrientation.hpp>
      38                 :            : #include <rtl/tencinfo.h>
      39                 :            : #include <svtools/wmf.hxx>
      40                 :            : #include <svl/lngmisc.hxx>
      41                 :            : #include <unotools/ucbstreamhelper.hxx>
      42                 :            : #include <unotools/streamwrap.hxx>
      43                 :            : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
      44                 :            : #include <rtl/oustringostreaminserter.hxx>
      45                 :            : #include <vcl/graph.hxx>
      46                 :            : #include <svtools/grfmgr.hxx>
      47                 :            : #include <vcl/svapp.hxx>
      48                 :            : #include <filter/msfilter/util.hxx>
      49                 :            : #include <filter/msfilter/escherex.hxx>
      50                 :            : #include <comphelper/string.hxx>
      51                 :            : #include <tools/globname.hxx>
      52                 :            : #include <comphelper/classids.hxx>
      53                 :            : #include <comphelper/embeddedobjectcontainer.hxx>
      54                 :            : #include <sfx2/sfxbasemodel.hxx>
      55                 :            : 
      56                 :            : #include <oox/mathml/import.hxx>
      57                 :            : #include <doctok/sprmids.hxx> // NS_sprm namespace
      58                 :            : #include <doctok/resourceids.hxx> // NS_rtf namespace
      59                 :            : #include <ooxml/resourceids.hxx> // NS_ooxml namespace
      60                 :            : #include <ooxml/OOXMLFastTokens.hxx> // ooxml namespace
      61                 :            : #include <oox/token/namespaces.hxx> // oox namespace
      62                 :            : #include <oox/token/tokens.hxx>
      63                 :            : 
      64                 :            : #include <rtfsdrimport.hxx>
      65                 :            : #include <rtftokenizer.hxx>
      66                 :            : #include <rtfcharsets.hxx>
      67                 :            : #include <rtfreferenceproperties.hxx>
      68                 :            : #include <rtfskipdestination.hxx>
      69                 :            : #include <rtffly.hxx>
      70                 :            : 
      71                 :            : #define TWIP_TO_MM100(TWIP)     ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
      72                 :            : #define M_TOKEN(token) OOX_TOKEN(officeMath, token)
      73                 :            : #define OPEN_M_TOKEN( rtftok, ooxtok ) \
      74                 :            :         case RTF_M##rtftok: \
      75                 :            :             m_aMathBuffer.appendOpeningTag(M_TOKEN(ooxtok)); \
      76                 :            :             m_aStates.top().nDestinationState = DESTINATION_M##rtftok; \
      77                 :            :             break
      78                 :            : 
      79                 :            : using std::make_pair;
      80                 :            : using rtl::OString;
      81                 :            : using rtl::OStringBuffer;
      82                 :            : using rtl::OUString;
      83                 :            : using rtl::OUStringBuffer;
      84                 :            : using rtl::OUStringToOString;
      85                 :            : 
      86                 :            : namespace writerfilter {
      87                 :            : namespace rtftok {
      88                 :            : 
      89                 :         27 : static Id lcl_getParagraphBorder(sal_uInt32 nIndex)
      90                 :            : {
      91                 :            :     static const Id aBorderIds[] =
      92                 :            :     {
      93                 :            :         NS_sprm::LN_PBrcTop, NS_sprm::LN_PBrcLeft, NS_sprm::LN_PBrcBottom, NS_sprm::LN_PBrcRight
      94                 :            :     };
      95                 :            : 
      96                 :         27 :     return aBorderIds[nIndex];
      97                 :            : }
      98                 :            : 
      99                 :       5070 : static void lcl_putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, RTFValue::Pointer_t pValue,
     100                 :            :         bool bOverwrite = true, bool bAttribute = true)
     101                 :            : {
     102         [ +  - ]:       5070 :     RTFValue::Pointer_t pParent = rSprms.find(nParent);
     103         [ +  + ]:       5070 :     if (!pParent.get())
     104                 :            :     {
     105         [ +  - ]:       1647 :         RTFSprms aAttributes;
     106         [ -  + ]:       1647 :         if (nParent == NS_ooxml::LN_CT_TcPrBase_shd)
     107                 :            :         {
     108                 :            :             // RTF default is 'auto', see writerfilter::dmapper::CellColorHandler
     109 [ #  # ][ #  # ]:          0 :             aAttributes.set(NS_ooxml::LN_CT_Shd_color, RTFValue::Pointer_t(new RTFValue(0x0a)));
         [ #  # ][ #  # ]
                 [ #  # ]
     110 [ #  # ][ #  # ]:          0 :             aAttributes.set(NS_ooxml::LN_CT_Shd_fill, RTFValue::Pointer_t(new RTFValue(0x0a)));
         [ #  # ][ #  # ]
                 [ #  # ]
     111                 :            :         }
     112 [ +  - ][ +  - ]:       1647 :         RTFValue::Pointer_t pParentValue(new RTFValue(aAttributes));
         [ +  - ][ +  - ]
     113 [ +  - ][ +  - ]:       1647 :         rSprms.set(nParent, pParentValue, bOverwrite);
                 [ +  - ]
     114 [ +  - ][ +  - ]:       1647 :         pParent = pParentValue;
     115                 :            :     }
     116 [ +  + ][ +  - ]:       5070 :     RTFSprms& rAttributes = (bAttribute ? pParent->getAttributes() : pParent->getSprms());
                 [ +  - ]
     117 [ +  - ][ +  - ]:       5070 :     rAttributes.set(nId, pValue, bOverwrite);
         [ +  - ][ +  - ]
     118                 :       5070 : }
     119                 :            : 
     120                 :       2094 : static void lcl_putNestedSprm(RTFSprms& rSprms, Id nParent, Id nId, RTFValue::Pointer_t pValue, bool bOverwrite = false)
     121                 :            : {
     122         [ +  - ]:       2094 :     lcl_putNestedAttribute(rSprms, nParent, nId, pValue, bOverwrite, false);
     123                 :       2094 : }
     124                 :            : 
     125                 :        162 : static bool lcl_eraseNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId)
     126                 :            : {
     127         [ +  - ]:        162 :     RTFValue::Pointer_t pParent = rSprms.find(nParent);
     128         [ +  - ]:        162 :     if (!pParent.get())
     129                 :            :         // It doesn't even have a parent, we're done!
     130                 :        162 :         return false;
     131         [ #  # ]:          0 :     RTFSprms& rAttributes = pParent->getAttributes();
     132 [ #  # ][ +  - ]:        162 :     return rAttributes.erase(nId);
     133                 :            : }
     134                 :            : 
     135                 :       1023 : static RTFSprms& lcl_getLastAttributes(RTFSprms& rSprms, Id nId)
     136                 :            : {
     137         [ +  - ]:       1023 :     RTFValue::Pointer_t p = rSprms.find(nId);
     138 [ +  + ][ +  - ]:       1023 :     if (p.get() && p->getSprms().size())
         [ +  - ][ +  + ]
     139 [ +  - ][ +  - ]:        861 :         return p->getSprms().back().second->getAttributes();
                 [ +  - ]
     140                 :            :     else
     141                 :            :     {
     142                 :            :         SAL_WARN("writerfilter", "trying to set property when no type is defined");
     143                 :        162 :         return rSprms;
     144         [ +  - ]:       1023 :     }
     145                 :            : }
     146                 :            : 
     147                 :       1080 : static void lcl_putBorderProperty(std::stack<RTFParserState>& aStates, Id nId, RTFValue::Pointer_t pValue)
     148                 :            : {
     149                 :       1080 :     RTFSprms* pAttributes = 0;
     150         [ +  + ]:       1080 :     if (aStates.top().nBorderState == BORDER_PARAGRAPH_BOX)
     151         [ +  + ]:         15 :         for (int i = 0; i < 4; i++)
     152                 :            :         {
     153 [ +  - ][ +  - ]:         12 :             RTFValue::Pointer_t p = aStates.top().aParagraphSprms.find(lcl_getParagraphBorder(i));
     154         [ +  - ]:         12 :             if (p.get())
     155                 :            :             {
     156         [ +  - ]:         12 :                 RTFSprms& rAttributes = p->getAttributes();
     157 [ +  - ][ +  - ]:         12 :                 rAttributes.set(nId, pValue);
                 [ +  - ]
     158                 :            :             }
     159         [ +  - ]:         12 :         }
     160                 :            :     // Attributes of the last border type
     161         [ +  + ]:       1077 :     else if (aStates.top().nBorderState == BORDER_PARAGRAPH)
     162                 :          9 :         pAttributes = &lcl_getLastAttributes(aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PrBase_pBdr);
     163         [ +  + ]:       1068 :     else if (aStates.top().nBorderState == BORDER_CELL)
     164                 :       1014 :         pAttributes = &lcl_getLastAttributes(aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcBorders);
     165         [ -  + ]:         54 :     else if (aStates.top().nBorderState == BORDER_PAGE)
     166                 :          0 :         pAttributes = &lcl_getLastAttributes(aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgBorders);
     167         [ +  + ]:       1080 :     if (pAttributes)
     168         [ +  - ]:       1023 :         pAttributes->set(nId, pValue);
     169                 :       1080 : }
     170                 :            : 
     171                 :          6 : static OString lcl_DTTM22OString(long lDTTM)
     172                 :            : {
     173         [ +  - ]:          6 :     return msfilter::util::DateTimeToOString(msfilter::util::DTTM2DateTime(lDTTM));
     174                 :            : }
     175                 :            : 
     176                 :          0 : static writerfilter::Reference<Properties>::Pointer_t lcl_getBookmarkProperties(int nPos, OUString& rString)
     177                 :            : {
     178         [ #  # ]:          0 :     RTFSprms aAttributes;
     179 [ #  # ][ #  # ]:          0 :     RTFValue::Pointer_t pPos(new RTFValue(nPos));
                 [ #  # ]
     180         [ #  # ]:          0 :     if (!rString.isEmpty())
     181                 :            :     {
     182                 :            :         // If present, this should be sent first.
     183 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pString(new RTFValue(rString));
                 [ #  # ]
     184 [ #  # ][ #  # ]:          0 :         aAttributes.set(NS_rtf::LN_BOOKMARKNAME, pString);
         [ #  # ][ #  # ]
     185                 :            :     }
     186 [ #  # ][ #  # ]:          0 :     aAttributes.set(NS_rtf::LN_IBKL, pPos);
                 [ #  # ]
     187 [ #  # ][ #  # ]:          0 :     return writerfilter::Reference<Properties>::Pointer_t(new RTFReferenceProperties(aAttributes));
         [ #  # ][ #  # ]
                 [ #  # ]
     188                 :            : }
     189                 :            : 
     190                 :          0 : static writerfilter::Reference<Properties>::Pointer_t lcl_getBookmarkProperties(int nPos)
     191                 :            : {
     192                 :          0 :     OUString aStr;
     193         [ #  # ]:          0 :     return lcl_getBookmarkProperties(nPos, aStr);
     194                 :            : }
     195                 :            : 
     196                 :          0 : static const char* lcl_RtfToString(RTFKeyword nKeyword)
     197                 :            : {
     198         [ #  # ]:          0 :     for (int i = 0; i < nRTFControlWords; i++)
     199                 :            :     {
     200         [ #  # ]:          0 :         if (nKeyword == aRTFControlWords[i].nIndex)
     201                 :          0 :             return aRTFControlWords[i].sKeyword;
     202                 :            :     }
     203                 :          0 :     return NULL;
     204                 :            : }
     205                 :            : 
     206                 :        240 : static util::DateTime lcl_getDateTime(std::stack<RTFParserState>& aStates)
     207                 :            : {
     208 [ +  - ][ +  - ]:        240 :     return util::DateTime(0 /*100sec*/, 0 /*sec*/, aStates.top().nMinute, aStates.top().nHour,
     209 [ +  - ][ +  - ]:        480 :             aStates.top().nDay, aStates.top().nMonth, aStates.top().nYear);
     210                 :            : }
     211                 :            : 
     212                 :       3783 : static void lcl_DestinationToMath(OUStringBuffer& rDestinationText, oox::formulaimport::XmlStreamBuilder& rMathBuffer)
     213                 :            : {
     214         [ +  - ]:       3783 :     OUString aStr = rDestinationText.makeStringAndClear();
     215         [ +  + ]:       3783 :     if (!aStr.isEmpty())
     216                 :            :     {
     217         [ +  - ]:       1470 :         rMathBuffer.appendOpeningTag(M_TOKEN(r));
     218         [ +  - ]:       1470 :         rMathBuffer.appendOpeningTag(M_TOKEN(t));
     219         [ +  - ]:       1470 :         rMathBuffer.appendCharacters(aStr);
     220         [ +  - ]:       1470 :         rMathBuffer.appendClosingTag(M_TOKEN(t));
     221         [ +  - ]:       1470 :         rMathBuffer.appendClosingTag(M_TOKEN(r));
     222                 :       3783 :     }
     223                 :       3783 : }
     224                 :            : 
     225                 :        336 : RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& xContext,
     226                 :            :         uno::Reference<io::XInputStream> const& xInputStream,
     227                 :            :         uno::Reference<lang::XComponent> const& xDstDoc,
     228                 :            :         uno::Reference<frame::XFrame>    const& xFrame,
     229                 :            :         uno::Reference<task::XStatusIndicator> const& xStatusIndicator)
     230                 :            :     : m_xContext(xContext),
     231                 :            :     m_xInputStream(xInputStream),
     232                 :            :     m_xDstDoc(xDstDoc),
     233                 :            :     m_xFrame(xFrame),
     234                 :            :     m_xStatusIndicator(xStatusIndicator),
     235                 :            :     m_nGroup(0),
     236                 :            :     m_aDefaultState(this),
     237                 :            :     m_bSkipUnknown(false),
     238                 :            :     m_aFontEncodings(),
     239                 :            :     m_aFontIndexes(),
     240                 :            :     m_aColorTable(),
     241                 :            :     m_bFirstRun(true),
     242                 :            :     m_bNeedPap(true),
     243                 :            :     m_bNeedCr(false),
     244                 :            :     m_bNeedPar(true),
     245                 :            :     m_bNeedFinalPar(false),
     246                 :            :     m_aListTableSprms(),
     247                 :            :     m_aSettingsTableAttributes(),
     248                 :            :     m_aSettingsTableSprms(),
     249                 :            :     m_xStorage(),
     250                 :            :     m_aTableBuffer(),
     251                 :            :     m_aSuperBuffer(),
     252                 :            :     m_aShapetextBuffer(),
     253                 :            :     m_pCurrentBuffer(0),
     254                 :            :     m_bHasFootnote(false),
     255                 :            :     m_pSuperstream(0),
     256                 :            :     m_nHeaderFooterPositions(),
     257                 :            :     m_nGroupStartPos(0),
     258                 :            :     m_aBookmarks(),
     259                 :            :     m_aAuthors(),
     260                 :            :     m_aFormfieldSprms(),
     261                 :            :     m_aFormfieldAttributes(),
     262                 :            :     m_nFormFieldType(FORMFIELD_NONE),
     263                 :            :     m_aObjectSprms(),
     264                 :            :     m_aObjectAttributes(),
     265                 :            :     m_bObject(false),
     266                 :            :     m_aFontTableEntries(),
     267                 :            :     m_nCurrentFontIndex(0),
     268                 :            :     m_aStyleTableEntries(),
     269                 :            :     m_nCurrentStyleIndex(0),
     270                 :            :     m_bFormField(false),
     271                 :            :     m_bIsInFrame(false),
     272                 :            :     m_aUnicodeBuffer(),
     273 [ +  - ][ +  - ]:        336 :     m_aHexBuffer()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     274                 :            : {
     275                 :            :     OSL_ASSERT(xInputStream.is());
     276 [ +  - ][ +  - ]:        336 :     m_pInStream.reset(utl::UcbStreamHelper::CreateStream(xInputStream, sal_True));
     277                 :            : 
     278         [ +  - ]:        336 :     m_xModelFactory.set(m_xDstDoc, uno::UNO_QUERY);
     279                 :            : 
     280         [ +  - ]:        336 :     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(m_xDstDoc, uno::UNO_QUERY);
     281         [ +  + ]:        336 :     if (xDocumentPropertiesSupplier.is())
     282 [ +  - ][ +  - ]:        303 :         m_xDocumentProperties.set(xDocumentPropertiesSupplier->getDocumentProperties(), uno::UNO_QUERY);
                 [ +  - ]
     283                 :            : 
     284 [ +  - ][ +  - ]:        336 :     m_pGraphicHelper.reset(new oox::GraphicHelper(m_xContext, xFrame, m_xStorage));
                 [ +  - ]
     285                 :            : 
     286 [ +  - ][ +  - ]:        336 :     m_pTokenizer.reset(new RTFTokenizer(*this, m_pInStream.get(), m_xStatusIndicator));
                 [ +  - ]
     287 [ +  - ][ +  - ]:        336 :     m_pSdrImport.reset(new RTFSdrImport(*this, m_xDstDoc));
                 [ +  - ]
     288                 :        336 : }
     289                 :            : 
     290 [ +  - ][ +  - ]:        336 : RTFDocumentImpl::~RTFDocumentImpl()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     291                 :            : {
     292         [ -  + ]:        672 : }
     293                 :            : 
     294                 :    4333104 : SvStream& RTFDocumentImpl::Strm()
     295                 :            : {
     296                 :    4333104 :     return *m_pInStream;
     297                 :            : }
     298                 :            : 
     299                 :      59757 : Stream& RTFDocumentImpl::Mapper()
     300                 :            : {
     301                 :      59757 :     return *m_pMapperStream;
     302                 :            : }
     303                 :            : 
     304                 :         21 : void RTFDocumentImpl::setSuperstream(RTFDocumentImpl *pSuperstream)
     305                 :            : {
     306                 :         21 :     m_pSuperstream = pSuperstream;
     307                 :         21 : }
     308                 :            : 
     309                 :          6 : void RTFDocumentImpl::setAuthor(rtl::OUString& rAuthor)
     310                 :            : {
     311                 :          6 :     m_aAuthor = rAuthor;
     312                 :          6 : }
     313                 :            : 
     314                 :          6 : void RTFDocumentImpl::setAuthorInitials(rtl::OUString& rAuthorInitials)
     315                 :            : {
     316                 :          6 :     m_aAuthorInitials = rAuthorInitials;
     317                 :          6 : }
     318                 :            : 
     319                 :        327 : bool RTFDocumentImpl::isSubstream() const
     320                 :            : {
     321                 :        327 :     return m_pSuperstream != 0;
     322                 :            : }
     323                 :            : 
     324                 :         21 : void RTFDocumentImpl::finishSubstream()
     325                 :            : {
     326                 :         21 :     checkUnicode();
     327                 :            :     // At the end of a footnote stream, we need to emit a run break when importing from Word.
     328                 :            :     // We can't do so unconditionally, as Writer already writes a \par at the end of the footnote.
     329         [ -  + ]:         21 :     if (m_bNeedCr)
     330                 :            :     {
     331                 :          0 :         Mapper().startCharacterGroup();
     332                 :          0 :         runBreak();
     333                 :          0 :         Mapper().endCharacterGroup();
     334                 :            :     }
     335                 :         21 : }
     336                 :            : 
     337                 :         21 : void RTFDocumentImpl::setIgnoreFirst(OUString& rIgnoreFirst)
     338                 :            : {
     339                 :         21 :     m_aIgnoreFirst = rIgnoreFirst;
     340                 :         21 : }
     341                 :            : 
     342                 :         18 : void RTFDocumentImpl::resolveSubstream(sal_uInt32 nPos, Id nId)
     343                 :            : {
     344                 :         18 :     OUString aStr;
     345         [ +  - ]:         18 :     resolveSubstream(nPos, nId, aStr);
     346                 :         18 : }
     347                 :         21 : void RTFDocumentImpl::resolveSubstream(sal_uInt32 nPos, Id nId, OUString& rIgnoreFirst)
     348                 :            : {
     349         [ +  - ]:         21 :     sal_uInt32 nCurrent = Strm().Tell();
     350                 :            :     // Seek to header position, parse, then seek back.
     351 [ +  - ][ +  - ]:         21 :     RTFDocumentImpl::Pointer_t pImpl(new RTFDocumentImpl(m_xContext, m_xInputStream, m_xDstDoc, m_xFrame, m_xStatusIndicator));
                 [ +  - ]
     352                 :         21 :     pImpl->setSuperstream(this);
     353                 :         21 :     pImpl->setIgnoreFirst(rIgnoreFirst);
     354         [ +  + ]:         21 :     if (!m_aAuthor.isEmpty())
     355                 :            :     {
     356                 :          6 :         pImpl->setAuthor(m_aAuthor);
     357                 :          6 :         m_aAuthor = OUString();
     358                 :            :     }
     359         [ +  + ]:         21 :     if (!m_aAuthorInitials.isEmpty())
     360                 :            :     {
     361                 :          6 :         pImpl->setAuthorInitials(m_aAuthorInitials);
     362                 :          6 :         m_aAuthorInitials = OUString();
     363                 :            :     }
     364         [ +  - ]:         21 :     pImpl->seek(nPos);
     365                 :            :     SAL_INFO("writerfilter", "substream start");
     366 [ +  - ][ +  - ]:         21 :     Mapper().substream(nId, pImpl);
                 [ +  - ]
     367                 :            :     SAL_INFO("writerfilter", "substream end");
     368 [ +  - ][ +  - ]:         21 :     Strm().Seek(nCurrent);
     369         [ +  - ]:         21 :     nPos = 0;
     370                 :         21 : }
     371                 :            : 
     372                 :      14361 : void RTFDocumentImpl::checkFirstRun()
     373                 :            : {
     374         [ +  + ]:      14361 :     if (m_bFirstRun)
     375                 :            :     {
     376                 :            :         // output settings table
     377 [ +  - ][ +  - ]:        327 :         writerfilter::Reference<Properties>::Pointer_t const pProp(new RTFReferenceProperties(m_aSettingsTableAttributes, m_aSettingsTableSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
     378         [ +  - ]:        327 :         RTFReferenceTable::Entries_t aSettingsTableEntries;
     379 [ +  - ][ +  - ]:        327 :         aSettingsTableEntries.insert(make_pair(0, pProp));
                 [ +  - ]
     380 [ +  - ][ +  - ]:        327 :         writerfilter::Reference<Table>::Pointer_t const pTable(new RTFReferenceTable(aSettingsTableEntries));
                 [ +  - ]
     381 [ +  - ][ +  - ]:        327 :         Mapper().table(NS_ooxml::LN_settings_settings, pTable);
                 [ +  - ]
     382                 :            :         // start initial paragraph
     383         [ +  + ]:        327 :         if (!m_pSuperstream)
     384         [ +  - ]:        306 :             Mapper().startSectionGroup();
     385         [ +  - ]:        327 :         Mapper().startParagraphGroup();
     386 [ +  - ][ +  - ]:        327 :         m_bFirstRun = false;
     387                 :            :     }
     388                 :      14361 : }
     389                 :            : 
     390                 :        138 : bool RTFDocumentImpl::getFirstRun()
     391                 :            : {
     392                 :        138 :     return m_bFirstRun;
     393                 :            : }
     394                 :            : 
     395                 :         12 : void RTFDocumentImpl::setNeedPar(bool bNeedPar)
     396                 :            : {
     397                 :         12 :     m_bNeedPar = bNeedPar;
     398                 :         12 : }
     399                 :            : 
     400                 :      14049 : void RTFDocumentImpl::checkNeedPap()
     401                 :            : {
     402         [ +  + ]:      14049 :     if (m_bNeedPap)
     403                 :            :     {
     404                 :       1092 :         m_bNeedPap = false; // reset early, so we can avoid recursion when calling ourselves
     405         [ +  + ]:       1092 :         if (!m_pCurrentBuffer)
     406                 :            :         {
     407                 :            :             writerfilter::Reference<Properties>::Pointer_t const pParagraphProperties(
     408 [ +  - ][ +  - ]:       2493 :                     new RTFReferenceProperties(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms)
                 [ +  - ]
     409 [ +  - ][ +  - ]:       2493 :                     );
         [ +  - ][ +  - ]
     410                 :            : 
     411                 :            :             // Writer will ignore a page break before a text frame, so guard it with empty paragraphs
     412         [ +  - ]:        831 :             bool hasBreakBeforeFrame = m_aStates.top().aFrame.hasProperties() &&
     413 [ +  - ][ +  - ]:        831 :                 m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PFPageBreakBefore).get();
         [ -  + ][ +  + ]
         [ +  - ][ #  # ]
                 [ +  + ]
     414         [ -  + ]:        831 :             if (hasBreakBeforeFrame)
     415                 :            :             {
     416         [ #  # ]:          0 :                 dispatchSymbol(RTF_PAR);
     417                 :          0 :                 m_bNeedPap = false;
     418                 :            :             }
     419 [ +  - ][ +  - ]:        831 :             Mapper().props(pParagraphProperties);
                 [ +  - ]
     420         [ -  + ]:        831 :             if (hasBreakBeforeFrame)
     421         [ #  # ]:          0 :                 dispatchSymbol(RTF_PAR);
     422                 :            : 
     423 [ +  - ][ +  + ]:        831 :             if (m_aStates.top().aFrame.hasProperties())
     424                 :            :             {
     425                 :            :                 writerfilter::Reference<Properties>::Pointer_t const pFrameProperties(
     426 [ +  - ][ +  - ]:         24 :                         new RTFReferenceProperties(RTFSprms(), m_aStates.top().aFrame.getSprms()));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     427 [ +  - ][ +  - ]:         24 :                 Mapper().props(pFrameProperties);
         [ +  - ][ +  - ]
     428         [ +  - ]:        831 :             }
     429                 :            :         }
     430                 :            :         else
     431                 :            :         {
     432 [ +  - ][ +  - ]:        261 :             RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     433 [ +  - ][ +  - ]:        261 :             m_pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue));
         [ +  - ][ +  - ]
     434                 :            :         }
     435                 :            :     }
     436                 :      14049 : }
     437                 :            : 
     438                 :      12483 : void RTFDocumentImpl::runProps()
     439                 :            : {
     440         [ +  + ]:      12483 :     if (!m_pCurrentBuffer)
     441                 :            :     {
     442                 :            :         writerfilter::Reference<Properties>::Pointer_t const pProperties(
     443 [ +  - ][ +  - ]:      36099 :                 new RTFReferenceProperties(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms)
                 [ +  - ]
     444 [ +  - ][ +  - ]:      36099 :                 );
         [ +  - ][ +  - ]
     445 [ +  - ][ +  - ]:      12033 :         Mapper().props(pProperties);
         [ +  - ][ +  - ]
     446                 :            :     }
     447                 :            :     else
     448                 :            :     {
     449 [ +  - ][ +  - ]:        450 :         RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     450 [ +  - ][ +  - ]:        450 :         m_pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue));
         [ +  - ][ +  - ]
     451                 :            :     }
     452                 :      12483 : }
     453                 :            : 
     454                 :       1338 : void RTFDocumentImpl::runBreak()
     455                 :            : {
     456                 :       1338 :     sal_uInt8 sBreak[] = { 0xd };
     457         [ +  - ]:       1338 :     Mapper().text(sBreak, 1);
     458                 :       1338 :     m_bNeedCr = false;
     459                 :       1338 : }
     460                 :            : 
     461                 :        351 : void RTFDocumentImpl::tableBreak()
     462                 :            : {
     463                 :        351 :     runBreak();
     464                 :        351 :     Mapper().endParagraphGroup();
     465                 :        351 :     Mapper().startParagraphGroup();
     466                 :        351 : }
     467                 :            : 
     468                 :        987 : void RTFDocumentImpl::parBreak()
     469                 :            : {
     470                 :        987 :     checkFirstRun();
     471                 :        987 :     checkNeedPap();
     472                 :            :     // end previous paragraph
     473                 :        987 :     Mapper().startCharacterGroup();
     474                 :        987 :     runBreak();
     475                 :        987 :     Mapper().endCharacterGroup();
     476                 :        987 :     Mapper().endParagraphGroup();
     477                 :            : 
     478                 :            :     // start new one
     479                 :        987 :     Mapper().startParagraphGroup();
     480                 :        987 : }
     481                 :            : 
     482                 :        327 : void RTFDocumentImpl::sectBreak(bool bFinal = false)
     483                 :            : {
     484                 :            :     // If there is no paragraph in this section, then insert a dummy one, as required by Writer
     485         [ +  + ]:        327 :     if (m_bNeedPar)
     486         [ +  - ]:         24 :         dispatchSymbol(RTF_PAR);
     487                 :            :     // It's allowed to not have a non-table paragraph at the end of an RTF doc, add it now if required.
     488 [ -  + ][ #  # ]:        327 :     if (m_bNeedFinalPar && bFinal)
     489                 :            :     {
     490         [ #  # ]:          0 :         dispatchFlag(RTF_PARD);
     491         [ #  # ]:          0 :         dispatchSymbol(RTF_PAR);
     492                 :            :     }
     493 [ +  - ][ +  + ]:        339 :     while (m_nHeaderFooterPositions.size())
     494                 :            :     {
     495         [ +  - ]:         12 :         std::pair<Id, sal_uInt32> aPair = m_nHeaderFooterPositions.front();
     496         [ +  - ]:         12 :         m_nHeaderFooterPositions.pop();
     497         [ +  - ]:         12 :         resolveSubstream(aPair.second, aPair.first);
     498                 :            :     }
     499                 :            : 
     500 [ +  - ][ +  - ]:        327 :     RTFValue::Pointer_t pBreak = m_aStates.top().aSectionSprms.find(NS_sprm::LN_SBkc);
     501                 :            :     // In case the last section is a continous one, we don't need to output a section break.
     502 [ +  + ][ +  + ]:        327 :     if (bFinal && pBreak.get() && !pBreak->getInt())
         [ +  - ][ +  + ]
                 [ +  + ]
     503 [ +  - ][ +  - ]:         96 :         m_aStates.top().aSectionSprms.erase(NS_sprm::LN_SBkc);
     504                 :            : 
     505                 :            :     // Section properties are a paragraph sprm.
     506 [ +  - ][ +  - ]:        327 :     RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aSectionAttributes, m_aStates.top().aSectionSprms));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     507         [ +  - ]:        327 :     RTFSprms aAttributes;
     508         [ +  - ]:        327 :     RTFSprms aSprms;
     509 [ +  - ][ +  - ]:        327 :     aSprms.set(NS_ooxml::LN_CT_PPr_sectPr, pValue);
                 [ +  - ]
     510                 :            :     writerfilter::Reference<Properties>::Pointer_t const pProperties(
     511         [ +  - ]:        327 :             new RTFReferenceProperties(aAttributes, aSprms)
     512 [ +  - ][ +  - ]:        654 :             );
         [ +  - ][ +  - ]
     513                 :            :     // The trick is that we send properties of the previous section right now, which will be exactly what dmapper expects.
     514 [ +  - ][ +  - ]:        327 :     Mapper().props(pProperties);
                 [ +  - ]
     515         [ +  - ]:        327 :     Mapper().endParagraphGroup();
     516         [ +  + ]:        327 :     if (!m_pSuperstream)
     517         [ +  - ]:        306 :         Mapper().endSectionGroup();
     518         [ +  + ]:        327 :     if (!bFinal)
     519                 :            :     {
     520         [ +  - ]:          3 :         Mapper().startSectionGroup();
     521         [ +  - ]:          3 :         Mapper().startParagraphGroup();
     522                 :            :     }
     523 [ +  - ][ +  - ]:        327 :     m_bNeedPar = true;
                 [ +  - ]
     524                 :        327 : }
     525                 :            : 
     526                 :         21 : void RTFDocumentImpl::seek(sal_uInt32 nPos)
     527                 :            : {
     528                 :         21 :     Strm().Seek(nPos);
     529                 :         21 : }
     530                 :            : 
     531                 :        402 : sal_uInt32 RTFDocumentImpl::getColorTable(sal_uInt32 nIndex)
     532                 :            : {
     533         [ +  + ]:        402 :     if (nIndex < m_aColorTable.size())
     534                 :        372 :         return m_aColorTable[nIndex];
     535                 :        402 :     return 0;
     536                 :            : }
     537                 :            : 
     538                 :       3219 : rtl_TextEncoding RTFDocumentImpl::getEncoding(sal_uInt32 nFontIndex)
     539                 :            : {
     540         [ +  + ]:       3219 :     if (!m_pSuperstream)
     541                 :            :     {
     542         [ +  - ]:       3213 :         std::map<int, rtl_TextEncoding>::iterator it = m_aFontEncodings.find(nFontIndex);
     543 [ +  - ][ +  + ]:       3213 :         if (it != m_aFontEncodings.end())
     544         [ +  - ]:       1935 :             return it->second;
     545 [ +  - ][ +  - ]:       3213 :         return msfilter::util::getBestTextEncodingFromLocale(Application::GetSettings().GetLocale());
                 [ +  - ]
     546                 :            :     }
     547                 :            :     else
     548                 :       3219 :         return m_pSuperstream->getEncoding(nFontIndex);
     549                 :            : }
     550                 :            : 
     551                 :       4209 : int RTFDocumentImpl::getFontIndex(int nIndex)
     552                 :            : {
     553         [ +  + ]:       4209 :     if (!m_pSuperstream)
     554 [ +  - ][ +  - ]:       4206 :         return std::find(m_aFontIndexes.begin(), m_aFontIndexes.end(), nIndex) - m_aFontIndexes.begin();
     555                 :            :     else
     556                 :       4209 :         return m_pSuperstream->getFontIndex(nIndex);
     557                 :            : }
     558                 :            : 
     559                 :        792 : RTFParserState& RTFDocumentImpl::getDefaultState()
     560                 :            : {
     561         [ +  + ]:        792 :     if (!m_pSuperstream)
     562                 :        774 :         return m_aDefaultState;
     563                 :            :     else
     564                 :        792 :         return m_pSuperstream->getDefaultState();
     565                 :            : }
     566                 :            : 
     567                 :        336 : void RTFDocumentImpl::resolve(Stream & rMapper)
     568                 :            : {
     569                 :        336 :     m_pMapperStream = &rMapper;
     570   [ +  -  +  -  :        336 :     switch (m_pTokenizer->resolveParse())
                -  -  - ]
     571                 :            :     {
     572                 :            :         case ERROR_OK:
     573                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": finished without errors");
     574                 :        327 :             break;
     575                 :            :         case ERROR_GROUP_UNDER:
     576                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": unmatched '}'");
     577                 :          0 :             break;
     578                 :            :         case ERROR_GROUP_OVER:
     579                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": unmatched '{'");
     580         [ +  - ]:          6 :             throw io::UnexpectedEOFException();
     581                 :            :             break;
     582                 :            :         case ERROR_EOF:
     583                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": unexpected end of file");
     584         [ #  # ]:          0 :             throw io::UnexpectedEOFException();
     585                 :            :             break;
     586                 :            :         case ERROR_HEX_INVALID:
     587                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": invalid hex char");
     588         [ #  # ]:          0 :             throw io::WrongFormatException();
     589                 :            :             break;
     590                 :            :         case ERROR_CHAR_OVER:
     591                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": characters after last '}'");
     592                 :          0 :             break;
     593                 :            :     }
     594                 :        327 : }
     595                 :            : 
     596                 :         18 : int RTFDocumentImpl::resolvePict(bool bInline)
     597                 :            : {
     598         [ +  - ]:         18 :     SvMemoryStream aStream;
     599                 :         18 :     SvStream *pStream = 0;
     600                 :            : 
     601         [ +  + ]:         18 :     if (!m_pBinaryData.get())
     602                 :            :     {
     603                 :         15 :         pStream = &aStream;
     604                 :         15 :         int b = 0, count = 2;
     605                 :            : 
     606                 :            :         // Feed the destination text to a stream.
     607 [ +  - ][ +  - ]:         15 :         OString aStr = OUStringToOString(m_aStates.top().aDestinationText.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US);
                 [ +  - ]
     608                 :         15 :         const char *str = aStr.getStr();
     609         [ +  + ]:       7899 :         for (int i = 0; i < aStr.getLength(); ++i)
     610                 :            :         {
     611                 :       7884 :             char ch = str[i];
     612 [ +  - ][ +  - ]:       7884 :             if (ch != 0x0d && ch != 0x0a)
     613                 :            :             {
     614                 :       7884 :                 b = b << 4;
     615         [ +  - ]:       7884 :                 sal_Int8 parsed = m_pTokenizer->asHex(ch);
     616         [ -  + ]:       7884 :                 if (parsed == -1)
     617                 :          0 :                     return ERROR_HEX_INVALID;
     618                 :       7884 :                 b += parsed;
     619                 :       7884 :                 count--;
     620         [ +  + ]:       7884 :                 if (!count)
     621                 :            :                 {
     622         [ +  - ]:       3942 :                     aStream << (char)b;
     623                 :       3942 :                     count = 2;
     624                 :       3942 :                     b = 0;
     625                 :            :                 }
     626                 :            :             }
     627         [ +  - ]:         15 :         }
     628                 :            :     }
     629                 :            :     else
     630                 :          3 :         pStream = m_pBinaryData.get();
     631                 :            : 
     632         [ +  + ]:         18 :     if (!pStream->Tell())
     633                 :            :         // No destination text? Then we'll get it later.
     634                 :          3 :         return 0;
     635                 :            : 
     636                 :            :     // Store, and get its URL.
     637         [ +  - ]:         15 :     pStream->Seek(0);
     638 [ +  - ][ +  - ]:         15 :     uno::Reference<io::XInputStream> xInputStream(new utl::OInputStreamWrapper(pStream));
                 [ +  - ]
     639                 :         15 :     WMF_EXTERNALHEADER aExtHeader;
     640         [ +  - ]:         15 :     aExtHeader.mapMode = m_aStates.top().aPicture.eWMetafile;
     641         [ +  - ]:         15 :     aExtHeader.xExt = m_aStates.top().aPicture.nWidth;
     642         [ +  - ]:         15 :     aExtHeader.yExt = m_aStates.top().aPicture.nHeight;
     643         [ +  - ]:         15 :     OUString aGraphicUrl = m_pGraphicHelper->importGraphicObject(xInputStream, &aExtHeader);
     644                 :            : 
     645 [ +  - ][ +  + ]:         15 :     if (m_aStates.top().aPicture.nStyle == BMPSTYLE_PNG)
     646                 :            :     {
     647                 :            :         // In case of PNG, the real size is known, don't use the values
     648                 :            :         // provided by picw and pich.
     649         [ +  - ]:         12 :         OString aURLBS(OUStringToOString(aGraphicUrl, RTL_TEXTENCODING_UTF8));
     650                 :         12 :         const char aURLBegin[] = "vnd.sun.star.GraphicObject:";
     651         [ +  - ]:         12 :         if (aURLBS.compareTo(aURLBegin, RTL_CONSTASCII_LENGTH(aURLBegin)) == 0)
     652                 :            :         {
     653 [ +  - ][ +  - ]:         12 :             Graphic aGraphic = GraphicObject(aURLBS.copy(RTL_CONSTASCII_LENGTH(aURLBegin))).GetTransformedGraphic();
                 [ +  - ]
     654         [ +  - ]:         12 :             Size aSize(aGraphic.GetPrefSize());
     655         [ +  - ]:         12 :             MapMode aMap(MAP_100TH_MM);
     656 [ +  - ][ +  - ]:         12 :             aSize = Application::GetDefaultDevice()->PixelToLogic( aSize, aMap );
     657         [ +  - ]:         12 :             m_aStates.top().aPicture.nWidth = aSize.Width();
     658 [ +  - ][ +  - ]:         12 :             m_aStates.top().aPicture.nHeight = aSize.Height();
                 [ +  - ]
     659                 :         12 :         }
     660                 :            :     }
     661                 :            : 
     662                 :            :     // Wrap it in an XShape.
     663                 :         15 :     uno::Reference<drawing::XShape> xShape;
     664         [ +  - ]:         15 :     if (m_xModelFactory.is())
     665 [ +  - ][ +  - ]:         15 :         xShape.set(m_xModelFactory->createInstance("com.sun.star.drawing.GraphicObjectShape"), uno::UNO_QUERY);
                 [ +  - ]
     666         [ +  - ]:         15 :     uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
     667         [ +  - ]:         15 :     uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier( m_xDstDoc, uno::UNO_QUERY);
     668         [ +  - ]:         15 :     if ( xDrawSupplier.is() )
     669                 :            :     {
     670 [ +  - ][ +  - ]:         15 :         uno::Reference< drawing::XShapes > xShapes( xDrawSupplier->getDrawPage(), uno::UNO_QUERY );
                 [ +  - ]
     671         [ +  - ]:         15 :         if ( xShapes.is() )
     672 [ +  - ][ +  - ]:         15 :             xShapes->add( xShape );
     673                 :            :     }
     674         [ -  + ]:         15 :     if (m_bObject)
     675                 :            :     {
     676                 :            :         // Set bitmap
     677         [ #  # ]:          0 :         beans::PropertyValues aMediaProperties(1);
     678         [ #  # ]:          0 :         aMediaProperties[0].Name = "URL";
     679 [ #  # ][ #  # ]:          0 :         aMediaProperties[0].Value <<= aGraphicUrl;
     680         [ #  # ]:          0 :         uno::Reference<graphic::XGraphicProvider> xGraphicProvider(graphic::GraphicProvider::create(m_xContext));
     681 [ #  # ][ #  # ]:          0 :         uno::Reference<graphic::XGraphic> xGraphic = xGraphicProvider->queryGraphic(aMediaProperties);
     682 [ #  # ][ #  # ]:          0 :         xPropertySet->setPropertyValue("Graphic", uno::Any(xGraphic));
                 [ #  # ]
     683                 :            : 
     684                 :            :         // Set the object size
     685                 :          0 :         awt::Size aSize;
     686 [ #  # ][ #  # ]:          0 :         aSize.Width = (m_aStates.top().aPicture.nGoalWidth ? m_aStates.top().aPicture.nGoalWidth : m_aStates.top().aPicture.nWidth);
         [ #  # ][ #  # ]
     687 [ #  # ][ #  # ]:          0 :         aSize.Height = (m_aStates.top().aPicture.nGoalHeight ? m_aStates.top().aPicture.nGoalHeight : m_aStates.top().aPicture.nHeight);
         [ #  # ][ #  # ]
     688 [ #  # ][ #  # ]:          0 :         xShape->setSize( aSize );
     689                 :            : 
     690 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pShapeValue(new RTFValue(xShape));
                 [ #  # ]
     691 [ #  # ][ #  # ]:          0 :         m_aObjectAttributes.set(NS_ooxml::LN_shape, pShapeValue);
                 [ #  # ]
     692 [ #  # ][ #  # ]:          0 :         return 0;
     693                 :            :     }
     694         [ +  - ]:         15 :     if (xPropertySet.is())
     695 [ +  - ][ +  - ]:         15 :         xPropertySet->setPropertyValue("GraphicURL", uno::Any(aGraphicUrl));
                 [ +  - ]
     696                 :            : 
     697                 :            :     // Send it to the dmapper.
     698         [ +  - ]:         15 :     RTFSprms aSprms;
     699         [ +  - ]:         15 :     RTFSprms aAttributes;
     700                 :            :     // shape attribute
     701         [ +  - ]:         15 :     RTFSprms aPicAttributes;
     702 [ +  - ][ +  - ]:         15 :     RTFValue::Pointer_t pShapeValue(new RTFValue(xShape));
                 [ +  - ]
     703 [ +  - ][ +  - ]:         15 :     aPicAttributes.set(NS_ooxml::LN_shape, pShapeValue);
                 [ +  - ]
     704                 :            :     // pic sprm
     705         [ +  - ]:         15 :     RTFSprms aGraphicDataAttributes;
     706         [ +  - ]:         15 :     RTFSprms aGraphicDataSprms;
     707 [ +  - ][ +  - ]:         15 :     RTFValue::Pointer_t pPicValue(new RTFValue(aPicAttributes));
         [ +  - ][ +  - ]
     708 [ +  - ][ +  - ]:         15 :     aGraphicDataSprms.set(NS_ooxml::LN_pic_pic, pPicValue);
                 [ +  - ]
     709                 :            :     // graphicData sprm
     710         [ +  - ]:         15 :     RTFSprms aGraphicAttributes;
     711         [ +  - ]:         15 :     RTFSprms aGraphicSprms;
     712 [ +  - ][ +  - ]:         15 :     RTFValue::Pointer_t pGraphicDataValue(new RTFValue(aGraphicDataAttributes, aGraphicDataSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
     713 [ +  - ][ +  - ]:         15 :     aGraphicSprms.set(NS_ooxml::LN_CT_GraphicalObject_graphicData, pGraphicDataValue);
                 [ +  - ]
     714                 :            :     // graphic sprm
     715 [ +  - ][ +  - ]:         15 :     RTFValue::Pointer_t pGraphicValue(new RTFValue(aGraphicAttributes, aGraphicSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
     716                 :            :     // extent sprm
     717         [ +  - ]:         15 :     RTFSprms aExtentAttributes;
     718                 :            :     int nXExt, nYExt;
     719 [ +  - ][ +  + ]:         15 :     nXExt = (m_aStates.top().aPicture.nGoalWidth ? m_aStates.top().aPicture.nGoalWidth : m_aStates.top().aPicture.nWidth);
         [ +  - ][ +  - ]
     720 [ +  - ][ +  + ]:         15 :     nYExt = (m_aStates.top().aPicture.nGoalHeight ? m_aStates.top().aPicture.nGoalHeight : m_aStates.top().aPicture.nHeight);
         [ +  - ][ +  - ]
     721 [ +  - ][ +  + ]:         15 :     if (m_aStates.top().aPicture.nScaleX != 100)
     722 [ +  - ][ +  - ]:          9 :         nXExt = (((long)m_aStates.top().aPicture.nScaleX) * ( nXExt - ( m_aStates.top().aPicture.nCropL + m_aStates.top().aPicture.nCropR ))) / 100L;
                 [ +  - ]
     723 [ +  - ][ +  + ]:         15 :     if (m_aStates.top().aPicture.nScaleY != 100)
     724 [ +  - ][ +  - ]:          9 :         nYExt = (((long)m_aStates.top().aPicture.nScaleY) * ( nYExt - ( m_aStates.top().aPicture.nCropT + m_aStates.top().aPicture.nCropB ))) / 100L;
                 [ +  - ]
     725 [ +  - ][ +  - ]:         15 :     RTFValue::Pointer_t pXExtValue(new RTFValue(nXExt));
                 [ +  - ]
     726 [ +  - ][ +  - ]:         15 :     RTFValue::Pointer_t pYExtValue(new RTFValue(nYExt));
                 [ +  - ]
     727 [ +  - ][ +  - ]:         15 :     aExtentAttributes.set(NS_rtf::LN_XEXT, pXExtValue);
                 [ +  - ]
     728 [ +  - ][ +  - ]:         15 :     aExtentAttributes.set(NS_rtf::LN_YEXT, pYExtValue);
                 [ +  - ]
     729 [ +  - ][ +  - ]:         15 :     RTFValue::Pointer_t pExtentValue(new RTFValue(aExtentAttributes));
         [ +  - ][ +  - ]
     730                 :            :     // docpr sprm
     731         [ +  - ]:         15 :     RTFSprms aDocprAttributes;
     732 [ +  - ][ +  - ]:         18 :     for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes.begin(); i != m_aStates.top().aCharacterAttributes.end(); ++i)
         [ +  - ][ +  + ]
     733 [ +  - ][ -  + ]:          3 :         if (i->first == NS_ooxml::LN_CT_NonVisualDrawingProps_name || i->first == NS_ooxml::LN_CT_NonVisualDrawingProps_descr)
                 [ -  + ]
     734 [ #  # ][ #  # ]:          0 :             aDocprAttributes.set(i->first, i->second);
                 [ #  # ]
     735 [ +  - ][ +  - ]:         15 :     RTFValue::Pointer_t pDocprValue(new RTFValue(aDocprAttributes));
         [ +  - ][ +  - ]
     736         [ +  + ]:         15 :     if (bInline)
     737                 :            :     {
     738         [ +  - ]:         12 :         RTFSprms aInlineAttributes;
     739         [ +  - ]:         12 :         RTFSprms aInlineSprms;
     740 [ +  - ][ +  - ]:         12 :         aInlineSprms.set(NS_ooxml::LN_CT_Inline_extent, pExtentValue);
                 [ +  - ]
     741 [ +  - ][ +  - ]:         12 :         aInlineSprms.set(NS_ooxml::LN_CT_Inline_docPr, pDocprValue);
                 [ +  - ]
     742 [ +  - ][ +  - ]:         12 :         aInlineSprms.set(NS_ooxml::LN_graphic_graphic, pGraphicValue);
                 [ +  - ]
     743                 :            :         // inline sprm
     744 [ +  - ][ +  - ]:         12 :         RTFValue::Pointer_t pValue(new RTFValue(aInlineAttributes, aInlineSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
     745 [ +  - ][ +  - ]:         12 :         aSprms.set(NS_ooxml::LN_inline_inline, pValue);
         [ +  - ][ +  - ]
     746                 :            :     }
     747                 :            :     else // anchored
     748                 :            :     {
     749                 :            :         // wrap sprm
     750         [ +  - ]:          3 :         RTFSprms aAnchorWrapAttributes;
     751 [ +  - ][ +  - ]:          6 :         for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes.begin(); i != m_aStates.top().aCharacterAttributes.end(); ++i)
         [ +  - ][ +  + ]
     752         [ +  - ]:          3 :             if (i->first == NS_ooxml::LN_CT_WrapSquare_wrapText)
     753 [ +  - ][ +  - ]:          3 :                 aAnchorWrapAttributes.set(i->first, i->second);
                 [ +  - ]
     754 [ +  - ][ +  - ]:          3 :         RTFValue::Pointer_t pAnchorWrapValue(new RTFValue(aAnchorWrapAttributes));
         [ +  - ][ +  - ]
     755         [ +  - ]:          3 :         RTFSprms aAnchorAttributes;
     756         [ +  - ]:          3 :         RTFSprms aAnchorSprms;
     757 [ +  - ][ +  - ]:          3 :         aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_extent, pExtentValue);
                 [ +  - ]
     758         [ +  - ]:          3 :         if (aAnchorWrapAttributes.size())
     759 [ +  - ][ +  - ]:          3 :             aAnchorSprms.set(NS_ooxml::LN_EG_WrapType_wrapSquare, pAnchorWrapValue);
                 [ +  - ]
     760 [ +  - ][ +  - ]:          3 :         aAnchorSprms.set(NS_ooxml::LN_CT_Anchor_docPr, pDocprValue);
                 [ +  - ]
     761 [ +  - ][ +  - ]:          3 :         aAnchorSprms.set(NS_ooxml::LN_graphic_graphic, pGraphicValue);
                 [ +  - ]
     762                 :            :         // anchor sprm
     763 [ +  - ][ +  - ]:          3 :         RTFValue::Pointer_t pValue(new RTFValue(aAnchorAttributes, aAnchorSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
     764 [ +  - ][ +  - ]:          3 :         aSprms.set(NS_ooxml::LN_anchor_anchor, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
     765                 :            :     }
     766 [ +  - ][ +  - ]:         15 :     writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes, aSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
     767         [ +  - ]:         15 :     checkFirstRun();
     768         [ +  + ]:         15 :     if (!m_pCurrentBuffer)
     769 [ +  - ][ +  - ]:          9 :         Mapper().props(pProperties);
                 [ +  - ]
     770                 :            :     else
     771                 :            :     {
     772 [ +  - ][ +  - ]:          6 :         RTFValue::Pointer_t pValue(new RTFValue(aAttributes, aSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
     773 [ +  - ][ +  - ]:          6 :         m_pCurrentBuffer->push_back(make_pair(BUFFER_PROPS, pValue));
         [ +  - ][ +  - ]
     774                 :            :     }
     775                 :            : 
     776 [ +  - ][ +  - ]:         18 :     return 0;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     777                 :            : }
     778                 :            : 
     779                 :      83004 : int RTFDocumentImpl::resolveChars(char ch)
     780                 :            : {
     781 [ +  - ][ +  + ]:      83004 :     if (m_aStates.top().nInternalState == INTERNAL_BIN)
     782                 :            :     {
     783 [ +  - ][ +  - ]:          3 :         m_pBinaryData.reset(new SvMemoryStream());
                 [ +  - ]
     784         [ +  - ]:          3 :         *m_pBinaryData << ch;
     785 [ +  - ][ +  + ]:      65988 :         for (int i = 0; i < m_aStates.top().nBinaryToRead - 1; ++i)
     786                 :            :         {
     787 [ +  - ][ +  - ]:      65985 :             Strm() >> ch;
     788         [ +  - ]:      65985 :             *m_pBinaryData << ch;
     789                 :            :         }
     790         [ +  - ]:          3 :         m_aStates.top().nInternalState = INTERNAL_NORMAL;
     791                 :          3 :         return 0;
     792                 :            :     }
     793                 :            : 
     794 [ +  - ][ +  + ]:      83001 :     if (m_aStates.top().nInternalState != INTERNAL_HEX)
     795         [ +  - ]:      12930 :         checkUnicode(false, true);
     796                 :            : 
     797                 :      83001 :     OStringBuffer aBuf;
     798                 :            : 
     799                 :      83001 :     bool bUnicodeChecked = false;
     800                 :      83001 :     bool bSkipped = false;
     801 [ +  - ][ +  - ]:    2154456 :     while(!Strm().IsEof() && ch != '{' && ch != '}' && ch != '\\')
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
     802                 :            :     {
     803 [ +  - ][ +  + ]:    2141523 :         if (m_aStates.top().nInternalState == INTERNAL_HEX || (ch != 0x0d && ch != 0x0a))
         [ +  + ][ +  + ]
                 [ +  + ]
     804                 :            :         {
     805 [ +  - ][ +  + ]:    2125830 :             if (m_aStates.top().nCharsToSkip == 0)
     806                 :            :             {
     807         [ +  + ]:    2125545 :                 if (!bUnicodeChecked)
     808                 :            :                 {
     809         [ +  - ]:      82713 :                     checkUnicode(true, false);
     810                 :      82713 :                     bUnicodeChecked = true;
     811                 :            :                 }
     812         [ +  - ]:    2125545 :                 aBuf.append(ch);
     813                 :            :             }
     814                 :            :             else
     815                 :            :             {
     816                 :        285 :                 bSkipped = true;
     817         [ +  - ]:        285 :                 m_aStates.top().nCharsToSkip--;
     818                 :            :             }
     819                 :            :         }
     820                 :            :         // read a single char if we're in hex mode
     821 [ +  - ][ +  + ]:    2141523 :         if (m_aStates.top().nInternalState == INTERNAL_HEX)
     822                 :      70068 :             break;
     823 [ +  - ][ +  - ]:    2071455 :         Strm() >> ch;
     824                 :            :     }
     825 [ +  - ][ +  + ]:      83001 :     if (m_aStates.top().nInternalState != INTERNAL_HEX && !Strm().IsEof())
         [ +  - ][ +  - ]
                 [ +  + ]
     826 [ +  - ][ +  - ]:      12930 :         Strm().SeekRel(-1);
     827                 :            : 
     828 [ +  - ][ +  + ]:      83001 :     if (m_aStates.top().nInternalState == INTERNAL_HEX && m_aStates.top().nDestinationState != DESTINATION_LEVELNUMBERS)
         [ +  - ][ +  + ]
                 [ +  + ]
     829                 :            :     {
     830         [ +  + ]:      70026 :         if (!bSkipped)
     831         [ +  - ]:      69813 :             m_aHexBuffer.append(ch);
     832                 :      70026 :         return 0;
     833                 :            :     }
     834                 :            : 
     835 [ +  - ][ +  + ]:      12975 :     if (m_aStates.top().nDestinationState == DESTINATION_SKIP)
     836                 :       1404 :         return 0;
     837                 :      11571 :     OString aStr = aBuf.makeStringAndClear();
     838 [ +  + ][ +  - ]:      11571 :     if (m_aStates.top().nDestinationState == DESTINATION_LEVELNUMBERS)
     839                 :            :     {
     840         [ +  + ]:         75 :         if (aStr.toChar() != ';')
     841 [ +  - ][ +  - ]:         45 :             m_aStates.top().aLevelNumbers.push_back(sal_Int32(ch));
     842                 :         75 :         return 0;
     843                 :            :     }
     844                 :            : 
     845 [ +  - ][ +  - ]:      11496 :     OUString aOUStr(OStringToOUString(aStr, m_aStates.top().nCurrentEncoding));
     846                 :            :     SAL_INFO("writerfilter", OSL_THIS_FUNC << ": collected '" << aOUStr << "'");
     847                 :            : 
     848 [ +  - ][ +  + ]:      11496 :     if (m_aStates.top().nDestinationState == DESTINATION_COLORTABLE)
     849                 :            :     {
     850                 :            :         // we hit a ';' at the end of each color entry
     851 [ +  - ][ +  - ]:        432 :         sal_uInt32 color = (m_aStates.top().aCurrentColor.nRed << 16) | ( m_aStates.top().aCurrentColor.nGreen << 8)
     852         [ +  - ]:        432 :             | m_aStates.top().aCurrentColor.nBlue;
     853         [ +  - ]:        432 :         m_aColorTable.push_back(color);
     854                 :            :         // set components back to zero
     855         [ +  - ]:        432 :         m_aStates.top().aCurrentColor = RTFColorTableEntry();
     856                 :            :     }
     857         [ +  + ]:      11064 :     else if (!aOUStr.isEmpty())
     858         [ +  - ]:      10992 :         text(aOUStr);
     859                 :            : 
     860                 :      83004 :     return 0;
     861                 :            : }
     862                 :            : 
     863                 :        876 : bool RTFFrame::inFrame()
     864                 :            : {
     865                 :            :     return nW > 0
     866                 :            :         || nH > 0
     867                 :            :         || nX > 0
     868 [ +  + ][ +  - ]:        876 :         || nY > 0;
         [ +  - ][ -  + ]
     869                 :            : }
     870                 :            : 
     871                 :         72 : void RTFDocumentImpl::singleChar(sal_uInt8 nValue, bool bRunProps)
     872                 :            : {
     873                 :         72 :     sal_uInt8 sValue[] = { nValue };
     874         [ +  - ]:         72 :     if (!m_pCurrentBuffer)
     875                 :            :     {
     876         [ +  - ]:         72 :         Mapper().startCharacterGroup();
     877                 :            :         // Should we send run properties?
     878         [ +  + ]:         72 :         if (bRunProps)
     879         [ +  - ]:          6 :             runProps();
     880         [ +  - ]:         72 :         Mapper().text(sValue, 1);
     881         [ +  - ]:         72 :         Mapper().endCharacterGroup();
     882                 :            :     }
     883                 :            :     else
     884                 :            :     {
     885 [ #  # ][ #  # ]:          0 :         m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, RTFValue::Pointer_t()));
         [ #  # ][ #  # ]
                 [ #  # ]
     886 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pValue(new RTFValue(*sValue));
                 [ #  # ]
     887 [ #  # ][ #  # ]:          0 :         m_pCurrentBuffer->push_back(make_pair(BUFFER_TEXT, pValue));
                 [ #  # ]
     888 [ #  # ][ #  # ]:          0 :         m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, RTFValue::Pointer_t()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     889                 :            :     }
     890                 :         72 : }
     891                 :            : 
     892                 :      18048 : void RTFDocumentImpl::text(OUString& rString)
     893                 :            : {
     894                 :      18048 :     bool bRet = true;
     895      [ +  +  + ]:      18048 :     switch (m_aStates.top().nDestinationState)
     896                 :            :     {
     897                 :            :         case DESTINATION_FONTTABLE:
     898                 :            :         case DESTINATION_FONTENTRY:
     899                 :            :         case DESTINATION_STYLESHEET:
     900                 :            :         case DESTINATION_STYLEENTRY:
     901                 :            :         case DESTINATION_REVISIONTABLE:
     902                 :            :         case DESTINATION_REVISIONENTRY:
     903                 :            :             {
     904                 :            :                 // ; is the end of the entry
     905                 :       2397 :                 bool bEnd = false;
     906         [ +  + ]:       2397 :                 if (rString.endsWithAsciiL(";", 1))
     907                 :            :                 {
     908                 :       2082 :                     rString = rString.copy(0, rString.getLength() - 1);
     909                 :       2082 :                     bEnd = true;
     910                 :            :                 }
     911                 :       2397 :                 m_aStates.top().aDestinationText.append(rString);
     912         [ +  + ]:       2397 :                 if (bEnd)
     913                 :            :                 {
     914   [ +  +  +  - ]:       2082 :                     switch (m_aStates.top().nDestinationState)
     915                 :            :                     {
     916                 :            :                         case DESTINATION_FONTTABLE:
     917                 :            :                         case DESTINATION_FONTENTRY:
     918                 :            :                             {
     919 [ +  - ][ +  - ]:       1326 :                                 RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aDestinationText.makeStringAndClear()));
         [ +  - ][ +  - ]
                 [ +  - ]
     920 [ +  - ][ +  - ]:       1326 :                                 m_aStates.top().aTableAttributes.set(NS_rtf::LN_XSZFFN, pValue);
         [ +  - ][ +  - ]
     921                 :            : 
     922                 :            :                                 writerfilter::Reference<Properties>::Pointer_t const pProp(
     923 [ +  - ][ +  - ]:       3978 :                                         new RTFReferenceProperties(m_aStates.top().aTableAttributes, m_aStates.top().aTableSprms)
                 [ +  - ]
     924 [ +  - ][ +  - ]:       3978 :                                         );
         [ +  - ][ +  - ]
     925                 :            : 
     926                 :            :                                 //See fdo#47347 initial invalid font entry properties are inserted first,
     927                 :            :                                 //so when we attempt to insert the correct ones, there's already an
     928                 :            :                                 //entry in the map for them, so the new ones aren't inserted.
     929         [ +  - ]:       1326 :                                 RTFReferenceTable::Entries_t::iterator lb = m_aFontTableEntries.lower_bound(m_nCurrentFontIndex);
     930 [ -  + ][ #  # ]:       1326 :                                 if (lb != m_aFontTableEntries.end() && !(m_aFontTableEntries.key_comp()(m_nCurrentFontIndex, lb->first)))
         [ #  # ][ #  # ]
         [ -  + ][ +  - ]
           [ -  +  #  #  
                   #  # ]
     931         [ #  # ]:          0 :                                     lb->second = pProp;
     932                 :            :                                 else
     933 [ +  - ][ +  - ]:       1326 :                                     m_aFontTableEntries.insert(lb, make_pair(m_nCurrentFontIndex, pProp));
         [ +  - ][ +  - ]
                 [ +  - ]
     934                 :            :                             }
     935                 :       1326 :                             break;
     936                 :            :                         case DESTINATION_STYLESHEET:
     937                 :            :                         case DESTINATION_STYLEENTRY:
     938                 :            :                             {
     939 [ +  - ][ +  - ]:        753 :                                 RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aDestinationText.makeStringAndClear()));
         [ +  - ][ +  - ]
                 [ +  - ]
     940 [ +  - ][ +  - ]:        753 :                                 m_aStates.top().aTableAttributes.set(NS_rtf::LN_XSTZNAME1, pValue);
         [ +  - ][ +  - ]
     941                 :            : 
     942                 :            :                                 writerfilter::Reference<Properties>::Pointer_t const pProp(
     943         [ +  - ]:        753 :                                         new RTFReferenceProperties(mergeAttributes(), mergeSprms())
     944 [ +  - ][ +  - ]:       1506 :                                         );
         [ +  - ][ +  - ]
     945 [ +  - ][ +  - ]:        753 :                                 m_aStyleTableEntries.insert(make_pair(m_nCurrentStyleIndex, pProp));
         [ +  - ][ +  - ]
                 [ +  - ]
     946                 :            :                             }
     947                 :        753 :                             break;
     948                 :            :                         case DESTINATION_REVISIONTABLE:
     949                 :            :                         case DESTINATION_REVISIONENTRY:
     950         [ +  - ]:          3 :                             m_aAuthors[m_aAuthors.size()] = m_aStates.top().aDestinationText.makeStringAndClear();
     951                 :          3 :                             break;
     952                 :          0 :                         default: break;
     953                 :            :                     }
     954                 :       2082 :                     resetAttributes();
     955                 :       2082 :                     resetSprms();
     956                 :            :                 }
     957                 :            :             }
     958                 :       2397 :             break;
     959                 :            :         case DESTINATION_LEVELTEXT:
     960                 :            :         case DESTINATION_SHAPEPROPERTYNAME:
     961                 :            :         case DESTINATION_SHAPEPROPERTYVALUE:
     962                 :            :         case DESTINATION_BOOKMARKEND:
     963                 :            :         case DESTINATION_PICT:
     964                 :            :         case DESTINATION_SHAPEPROPERTYVALUEPICT:
     965                 :            :         case DESTINATION_FORMFIELDNAME:
     966                 :            :         case DESTINATION_FORMFIELDLIST:
     967                 :            :         case DESTINATION_DATAFIELD:
     968                 :            :         case DESTINATION_AUTHOR:
     969                 :            :         case DESTINATION_KEYWORDS:
     970                 :            :         case DESTINATION_OPERATOR:
     971                 :            :         case DESTINATION_COMPANY:
     972                 :            :         case DESTINATION_COMMENT:
     973                 :            :         case DESTINATION_OBJDATA:
     974                 :            :         case DESTINATION_ANNOTATIONDATE:
     975                 :            :         case DESTINATION_ANNOTATIONAUTHOR:
     976                 :            :         case DESTINATION_FALT:
     977                 :            :         case DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER:
     978                 :            :         case DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE:
     979                 :            :         case DESTINATION_TITLE:
     980                 :            :         case DESTINATION_SUBJECT:
     981                 :            :         case DESTINATION_DOCCOMM:
     982                 :            :         case DESTINATION_ATNID:
     983                 :            :         case DESTINATION_MR:
     984                 :            :         case DESTINATION_MCHR:
     985                 :            :         case DESTINATION_MPOS:
     986                 :            :         case DESTINATION_MVERTJC:
     987                 :            :         case DESTINATION_MSTRIKEH:
     988                 :            :         case DESTINATION_MDEGHIDE:
     989                 :            :         case DESTINATION_MBEGCHR:
     990                 :            :         case DESTINATION_MSEPCHR:
     991                 :            :         case DESTINATION_MENDCHR:
     992                 :            :         case DESTINATION_MSUBHIDE:
     993                 :            :         case DESTINATION_MSUPHIDE:
     994                 :            :         case DESTINATION_MTYPE:
     995                 :            :         case DESTINATION_MGROW:
     996                 :       3426 :             m_aStates.top().aDestinationText.append(rString);
     997                 :       3426 :             break;
     998                 :      12225 :         default: bRet = false; break;
     999                 :            :     }
    1000         [ +  + ]:      18048 :     if (bRet)
    1001                 :       5823 :         return;
    1002                 :            : 
    1003 [ -  + ][ #  # ]:      12225 :     if (!m_aIgnoreFirst.isEmpty() && m_aIgnoreFirst.equals(rString))
                 [ -  + ]
    1004                 :            :     {
    1005                 :          0 :         m_aIgnoreFirst = OUString();
    1006                 :          0 :         return;
    1007                 :            :     }
    1008                 :            : 
    1009                 :      12225 :     checkFirstRun();
    1010                 :      12225 :     checkNeedPap();
    1011                 :            : 
    1012                 :            :     // Don't return earlier, a bookmark start has to be in a paragraph group.
    1013         [ -  + ]:      12225 :     if (m_aStates.top().nDestinationState == DESTINATION_BOOKMARKSTART)
    1014                 :            :     {
    1015                 :          0 :         m_aStates.top().aDestinationText.append(rString);
    1016                 :          0 :         return;
    1017                 :            :     }
    1018                 :            : 
    1019 [ +  + ][ +  - ]:      12225 :     if (!m_pCurrentBuffer && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE)
                 [ +  + ]
    1020                 :      11784 :         Mapper().startCharacterGroup();
    1021         [ +  - ]:        441 :     else if (m_pCurrentBuffer)
    1022                 :            :     {
    1023         [ +  - ]:        441 :         RTFValue::Pointer_t pValue;
    1024 [ +  - ][ +  - ]:        441 :         m_pCurrentBuffer->push_back(make_pair(BUFFER_STARTRUN, pValue));
         [ +  - ][ +  - ]
    1025                 :            :     }
    1026   [ +  +  +  +  :      12282 :     if (m_aStates.top().nDestinationState == DESTINATION_NORMAL
           -  + ][ +  + ]
    1027                 :         30 :             || m_aStates.top().nDestinationState == DESTINATION_FIELDRESULT
    1028                 :         27 :             || m_aStates.top().nDestinationState == DESTINATION_SHAPETEXT)
    1029                 :      12198 :         runProps();
    1030         [ +  + ]:      12225 :     if (!m_pCurrentBuffer)
    1031                 :      11784 :         Mapper().utext(reinterpret_cast<sal_uInt8 const*>(rString.getStr()), rString.getLength());
    1032                 :            :     else
    1033                 :            :     {
    1034 [ +  - ][ +  - ]:        441 :         RTFValue::Pointer_t pValue(new RTFValue(rString));
                 [ +  - ]
    1035 [ +  - ][ +  - ]:        441 :         m_pCurrentBuffer->push_back(make_pair(BUFFER_UTEXT, pValue));
         [ +  - ][ +  - ]
    1036                 :            :     }
    1037                 :      12225 :     m_bNeedCr = true;
    1038 [ +  + ][ +  - ]:      12225 :     if (!m_pCurrentBuffer && m_aStates.top().nDestinationState != DESTINATION_FOOTNOTE)
                 [ +  + ]
    1039                 :      11784 :         Mapper().endCharacterGroup();
    1040         [ +  - ]:        441 :     else if(m_pCurrentBuffer)
    1041                 :            :     {
    1042         [ +  - ]:        441 :         RTFValue::Pointer_t pValue;
    1043 [ +  - ][ +  - ]:      18048 :         m_pCurrentBuffer->push_back(make_pair(BUFFER_ENDRUN, pValue));
         [ +  - ][ +  - ]
    1044                 :            :     }
    1045                 :            : }
    1046                 :            : 
    1047                 :        537 : void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer)
    1048                 :            : {
    1049         [ +  + ]:       2664 :     while (rBuffer.size())
    1050                 :            :     {
    1051 [ +  - ][ +  - ]:       2412 :         std::pair<RTFBufferTypes, RTFValue::Pointer_t> aPair = rBuffer.front();
    1052         [ +  - ]:       2412 :         rBuffer.pop_front();
    1053         [ +  + ]:       2412 :         if (aPair.first == BUFFER_PROPS)
    1054                 :            :         {
    1055                 :            :             writerfilter::Reference<Properties>::Pointer_t const pProp(
    1056 [ +  - ][ +  - ]:       2385 :                     new RTFReferenceProperties(aPair.second->getAttributes(), aPair.second->getSprms())
                 [ +  - ]
    1057 [ +  - ][ +  - ]:       2385 :                     );
         [ +  - ][ +  - ]
    1058 [ +  - ][ +  - ]:        795 :             Mapper().props(pProp);
         [ +  - ][ +  - ]
    1059                 :            :         }
    1060         [ +  + ]:       1617 :         else if (aPair.first == BUFFER_CELLEND)
    1061                 :            :         {
    1062 [ +  - ][ +  - ]:        285 :             RTFValue::Pointer_t pValue(new RTFValue(1));
                 [ +  - ]
    1063 [ +  - ][ +  - ]:        285 :             m_aStates.top().aTableCellSprms.set(NS_sprm::LN_PCell, pValue);
         [ +  - ][ +  - ]
    1064                 :            :             writerfilter::Reference<Properties>::Pointer_t const pTableCellProperties(
    1065 [ +  - ][ +  - ]:        855 :                     new RTFReferenceProperties(m_aStates.top().aTableCellAttributes, m_aStates.top().aTableCellSprms)
                 [ +  - ]
    1066 [ +  - ][ +  - ]:        855 :                     );
         [ +  - ][ +  - ]
    1067 [ +  - ][ +  - ]:        285 :             Mapper().props(pTableCellProperties);
                 [ +  - ]
    1068         [ +  - ]:        285 :             tableBreak();
    1069 [ +  - ][ +  - ]:        285 :             break;
    1070                 :            :         }
    1071         [ +  + ]:       1332 :         else if (aPair.first == BUFFER_STARTRUN)
    1072         [ +  - ]:        441 :             Mapper().startCharacterGroup();
    1073         [ -  + ]:        891 :         else if (aPair.first == BUFFER_TEXT)
    1074                 :            :         {
    1075         [ #  # ]:          0 :             sal_uInt8 nValue = aPair.second->getInt();
    1076         [ #  # ]:          0 :             Mapper().text(&nValue, 1);
    1077                 :            :         }
    1078         [ +  + ]:        891 :         else if (aPair.first == BUFFER_UTEXT)
    1079                 :            :         {
    1080         [ +  - ]:        441 :             OUString aString(aPair.second->getString());
    1081         [ +  - ]:        441 :             Mapper().utext(reinterpret_cast<sal_uInt8 const*>(aString.getStr()), aString.getLength());
    1082                 :            :         }
    1083         [ +  + ]:        450 :         else if (aPair.first == BUFFER_ENDRUN)
    1084         [ +  - ]:        441 :             Mapper().endCharacterGroup();
    1085         [ +  - ]:          9 :         else if (aPair.first == BUFFER_PAR)
    1086         [ +  - ]:       2127 :             parBreak();
    1087                 :            :         else
    1088                 :            :             SAL_WARN("writerfilter", "should not happen");
    1089 [ +  - ][ +  + ]:       2412 :     }
    1090                 :            : 
    1091                 :        537 : }
    1092                 :            : 
    1093                 :       8187 : int RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
    1094                 :            : {
    1095         [ +  - ]:       8187 :     checkUnicode();
    1096         [ +  - ]:       8187 :     RTFSkipDestination aSkip(*this);
    1097   [ +  +  +  +  :       8187 :     switch (nKeyword)
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  -  +  +  
          +  +  +  -  +  
          +  -  -  +  +  
          -  -  -  -  -  
          +  +  +  +  +  
          +  +  +  +  -  
          -  -  +  +  +  
          -  +  +  +  -  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                +  +  + ]
    1098                 :            :     {
    1099                 :            :         case RTF_RTF:
    1100                 :        312 :             break;
    1101                 :            :         case RTF_FONTTBL:
    1102         [ +  - ]:        150 :             m_aStates.top().nDestinationState = DESTINATION_FONTTABLE;
    1103                 :        150 :             break;
    1104                 :            :         case RTF_COLORTBL:
    1105         [ +  - ]:        102 :             m_aStates.top().nDestinationState = DESTINATION_COLORTABLE;
    1106                 :        102 :             break;
    1107                 :            :         case RTF_STYLESHEET:
    1108         [ +  - ]:        114 :             m_aStates.top().nDestinationState = DESTINATION_STYLESHEET;
    1109                 :        114 :             break;
    1110                 :            :         case RTF_FIELD:
    1111         [ +  - ]:         18 :             m_aStates.top().nDestinationState = DESTINATION_FIELD;
    1112                 :         18 :             break;
    1113                 :            :         case RTF_FLDINST:
    1114                 :            :             {
    1115                 :            :                 // Look for the field type
    1116         [ +  - ]:         18 :                 sal_Int32 nPos = Strm().Tell();
    1117                 :         18 :                 OStringBuffer aBuf;
    1118                 :         18 :                 char ch = 0;
    1119                 :         18 :                 bool bFoundCode = false;
    1120                 :         18 :                 bool bInKeyword = false;
    1121 [ +  + ][ +  - ]:        165 :                 while (!bFoundCode && ch != '}')
                 [ +  + ]
    1122                 :            :                 {
    1123 [ +  - ][ +  - ]:        147 :                     Strm() >> ch;
    1124         [ +  + ]:        147 :                     if ('\\' == ch)
    1125                 :          9 :                         bInKeyword = true;
    1126 [ +  + ][ +  + ]:        147 :                     if (!bInKeyword  && isalnum(ch))
    1127         [ +  - ]:         75 :                         aBuf.append(ch);
    1128 [ +  + ][ +  + ]:         72 :                     else if (bInKeyword && isspace(ch))
    1129                 :          3 :                         bInKeyword = false;
    1130 [ +  + ][ +  + ]:        147 :                     if (aBuf.getLength() > 0 && !isalnum(ch))
                 [ +  + ]
    1131                 :         18 :                         bFoundCode = true;
    1132                 :            :                 }
    1133 [ +  - ][ +  - ]:         18 :                 Strm().Seek(nPos);
    1134                 :            : 
    1135                 :            :                 // Form data should be handled only for form fields if any
    1136         [ -  + ]:         18 :                 if (aBuf.toString().indexOf(OString("FORM")) != -1 )
    1137                 :          0 :                     m_bFormField = true;
    1138                 :            : 
    1139         [ +  - ]:         18 :                 singleChar(0x13);
    1140         [ +  - ]:         18 :                 m_aStates.top().nDestinationState = DESTINATION_FIELDINSTRUCTION;
    1141                 :            :             }
    1142                 :         18 :             break;
    1143                 :            :         case RTF_FLDRSLT:
    1144         [ +  - ]:         15 :             m_aStates.top().nDestinationState = DESTINATION_FIELDRESULT;
    1145                 :         15 :             break;
    1146                 :            :         case RTF_LISTTABLE:
    1147         [ +  - ]:         15 :             m_aStates.top().nDestinationState = DESTINATION_LISTTABLE;
    1148                 :         15 :             break;
    1149                 :            :         case RTF_LIST:
    1150         [ +  - ]:         15 :             m_aStates.top().nDestinationState = DESTINATION_LISTENTRY;
    1151                 :         15 :             break;
    1152                 :            :         case RTF_LISTOVERRIDETABLE:
    1153         [ +  - ]:         15 :             m_aStates.top().nDestinationState = DESTINATION_LISTOVERRIDETABLE;
    1154                 :         15 :             break;
    1155                 :            :         case RTF_LISTOVERRIDE:
    1156         [ +  - ]:         15 :             m_aStates.top().nDestinationState = DESTINATION_LISTOVERRIDEENTRY;
    1157                 :         15 :             break;
    1158                 :            :         case RTF_LISTLEVEL:
    1159         [ +  - ]:         24 :             m_aStates.top().nDestinationState = DESTINATION_LISTLEVEL;
    1160                 :         24 :             break;
    1161                 :            :         case RTF_LEVELTEXT:
    1162         [ +  - ]:         30 :             m_aStates.top().nDestinationState = DESTINATION_LEVELTEXT;
    1163                 :         30 :             break;
    1164                 :            :         case RTF_LEVELNUMBERS:
    1165         [ +  - ]:         30 :             m_aStates.top().nDestinationState = DESTINATION_LEVELNUMBERS;
    1166                 :         30 :             break;
    1167                 :            :         case RTF_SHPPICT:
    1168 [ +  - ][ +  - ]:          6 :             m_aStates.top().resetFrame();
    1169         [ +  - ]:          6 :             m_aStates.top().nDestinationState = DESTINATION_SHPPICT;
    1170                 :          6 :             break;
    1171                 :            :         case RTF_PICT:
    1172 [ +  - ][ +  + ]:         15 :             if (m_aStates.top().nDestinationState != DESTINATION_SHAPEPROPERTYVALUE)
    1173         [ +  - ]:         12 :                 m_aStates.top().nDestinationState = DESTINATION_PICT; // as character
    1174                 :            :             else
    1175         [ +  - ]:          3 :                 m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYVALUEPICT; // anchored inside a shape
    1176                 :         15 :             break;
    1177                 :            :         case RTF_PICPROP:
    1178         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_PICPROP;
    1179                 :          0 :             break;
    1180                 :            :         case RTF_SP:
    1181         [ +  - ]:        366 :             m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTY;
    1182                 :        366 :             break;
    1183                 :            :         case RTF_SN:
    1184         [ +  - ]:        366 :             m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYNAME;
    1185                 :        366 :             break;
    1186                 :            :         case RTF_SV:
    1187         [ +  - ]:        366 :             m_aStates.top().nDestinationState = DESTINATION_SHAPEPROPERTYVALUE;
    1188                 :        366 :             break;
    1189                 :            :         case RTF_SHP:
    1190         [ +  - ]:         39 :             m_aStates.top().nDestinationState = DESTINATION_SHAPE;
    1191                 :         39 :             break;
    1192                 :            :         case RTF_SHPINST:
    1193                 :            :             // Don't try to support shapes inside tables for now.
    1194         [ +  - ]:         39 :             if (m_pCurrentBuffer != &m_aTableBuffer)
    1195         [ +  - ]:         39 :                 m_aStates.top().nDestinationState = DESTINATION_SHAPEINSTRUCTION;
    1196                 :            :             else
    1197         [ #  # ]:          0 :                 m_aStates.top().nDestinationState = DESTINATION_SKIP;
    1198                 :         39 :             break;
    1199                 :            :         case RTF_NESTTABLEPROPS:
    1200         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_NESTEDTABLEPROPERTIES;
    1201                 :          0 :             break;
    1202                 :            :         case RTF_HEADER:
    1203                 :            :         case RTF_FOOTER:
    1204                 :            :         case RTF_HEADERL:
    1205                 :            :         case RTF_HEADERR:
    1206                 :            :         case RTF_HEADERF:
    1207                 :            :         case RTF_FOOTERL:
    1208                 :            :         case RTF_FOOTERR:
    1209                 :            :         case RTF_FOOTERF:
    1210         [ +  + ]:         24 :             if (!m_pSuperstream)
    1211                 :            :             {
    1212                 :         12 :                 Id nId = 0;
    1213                 :         12 :                 sal_uInt32 nPos = m_nGroupStartPos - 1;
    1214   [ +  -  -  +  :         12 :                 switch (nKeyword)
             -  -  -  -  
                      - ]
    1215                 :            :                 {
    1216                 :          9 :                     case RTF_HEADER: nId = NS_rtf::LN_headerr; break;
    1217                 :          0 :                     case RTF_FOOTER: nId = NS_rtf::LN_footerr; break;
    1218                 :          0 :                     case RTF_HEADERL: nId = NS_rtf::LN_headerl; break;
    1219                 :          3 :                     case RTF_HEADERR: nId = NS_rtf::LN_headerr; break;
    1220                 :          0 :                     case RTF_HEADERF: nId = NS_rtf::LN_headerf; break;
    1221                 :          0 :                     case RTF_FOOTERL: nId = NS_rtf::LN_footerl; break;
    1222                 :          0 :                     case RTF_FOOTERR: nId = NS_rtf::LN_footerr; break;
    1223                 :          0 :                     case RTF_FOOTERF: nId = NS_rtf::LN_footerf; break;
    1224                 :          0 :                     default: break;
    1225                 :            :                 }
    1226 [ +  - ][ +  - ]:         12 :                 m_nHeaderFooterPositions.push(make_pair(nId, nPos));
    1227         [ +  - ]:         12 :                 m_aStates.top().nDestinationState = DESTINATION_SKIP;
    1228                 :            :             }
    1229                 :         24 :             break;
    1230                 :            :         case RTF_FOOTNOTE:
    1231         [ +  + ]:          6 :             if (!m_pSuperstream)
    1232                 :            :             {
    1233                 :          3 :                 Id nId = NS_rtf::LN_footnote;
    1234                 :            : 
    1235                 :            :                 // Check if this is an endnote.
    1236                 :          3 :                 OStringBuffer aBuf;
    1237                 :            :                 char ch;
    1238         [ +  + ]:         24 :                 for (int i = 0; i < 7; ++i)
    1239                 :            :                 {
    1240 [ +  - ][ +  - ]:         21 :                     Strm() >> ch;
    1241         [ +  - ]:         21 :                     aBuf.append(ch);
    1242                 :            :                 }
    1243                 :          3 :                 OString aKeyword = aBuf.makeStringAndClear();
    1244         [ -  + ]:          3 :                 if (aKeyword.equals("\\ftnalt"))
    1245                 :          0 :                     nId = NS_rtf::LN_endnote;
    1246                 :            : 
    1247                 :          3 :                 m_bHasFootnote = true;
    1248         [ -  + ]:          3 :                 if (m_pCurrentBuffer == &m_aSuperBuffer)
    1249                 :          0 :                     m_pCurrentBuffer = 0;
    1250                 :          3 :                 bool bCustomMark = false;
    1251                 :          3 :                 OUString aCustomMark;
    1252         [ -  + ]:          3 :                 while (m_aSuperBuffer.size())
    1253                 :            :                 {
    1254 [ #  # ][ #  # ]:          0 :                     std::pair<RTFBufferTypes, RTFValue::Pointer_t> aPair = m_aSuperBuffer.front();
    1255         [ #  # ]:          0 :                     m_aSuperBuffer.pop_front();
    1256         [ #  # ]:          0 :                     if (aPair.first == BUFFER_UTEXT)
    1257                 :            :                     {
    1258         [ #  # ]:          0 :                         aCustomMark = aPair.second->getString();
    1259                 :          0 :                         bCustomMark = true;
    1260                 :            :                     }
    1261         [ #  # ]:          0 :                 }
    1262         [ +  - ]:          3 :                 m_aStates.top().nDestinationState = DESTINATION_FOOTNOTE;
    1263         [ -  + ]:          3 :                 if (bCustomMark)
    1264         [ #  # ]:          0 :                     Mapper().startCharacterGroup();
    1265         [ +  - ]:          3 :                 resolveSubstream(m_nGroupStartPos - 1, nId, aCustomMark);
    1266         [ -  + ]:          3 :                 if (bCustomMark)
    1267                 :            :                 {
    1268         [ #  # ]:          0 :                     m_aStates.top().aCharacterAttributes.clear();
    1269         [ #  # ]:          0 :                     m_aStates.top().aCharacterSprms.clear();
    1270 [ #  # ][ #  # ]:          0 :                     RTFValue::Pointer_t pValue(new RTFValue(1));
                 [ #  # ]
    1271 [ #  # ][ #  # ]:          0 :                     m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_FtnEdnRef_customMarkFollows, pValue);
         [ #  # ][ #  # ]
    1272         [ #  # ]:          0 :                     text(aCustomMark);
    1273 [ #  # ][ #  # ]:          0 :                     Mapper().endCharacterGroup();
    1274                 :            :                 }
    1275         [ +  - ]:          3 :                 m_aStates.top().nDestinationState = DESTINATION_SKIP;
    1276                 :            :             }
    1277                 :          6 :             break;
    1278                 :            :         case RTF_BKMKSTART:
    1279         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_BOOKMARKSTART;
    1280                 :          0 :             break;
    1281                 :            :         case RTF_BKMKEND:
    1282         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_BOOKMARKEND;
    1283                 :          0 :             break;
    1284                 :            :         case RTF_REVTBL:
    1285         [ +  - ]:          3 :             m_aStates.top().nDestinationState = DESTINATION_REVISIONTABLE;
    1286                 :          3 :             break;
    1287                 :            :         case RTF_ANNOTATION:
    1288         [ +  + ]:         12 :             if (!m_pSuperstream)
    1289                 :            :             {
    1290         [ +  - ]:          6 :                 resolveSubstream(m_nGroupStartPos - 1, NS_rtf::LN_annotation);
    1291         [ +  - ]:          6 :                 m_aStates.top().nDestinationState = DESTINATION_SKIP;
    1292                 :            :             }
    1293                 :            :             else
    1294                 :            :             {
    1295                 :            :                 // If there is an author set, emit it now.
    1296 [ -  + ][ #  # ]:          6 :                 if (!m_aAuthor.isEmpty() || !m_aAuthorInitials.isEmpty())
                 [ +  - ]
    1297                 :            :                 {
    1298         [ +  - ]:          6 :                     RTFSprms aAttributes;
    1299         [ +  - ]:          6 :                     if (!m_aAuthor.isEmpty())
    1300                 :            :                     {
    1301 [ +  - ][ +  - ]:          6 :                         RTFValue::Pointer_t pValue(new RTFValue(m_aAuthor));
                 [ +  - ]
    1302 [ +  - ][ +  - ]:          6 :                         aAttributes.set(NS_ooxml::LN_CT_TrackChange_author, pValue);
         [ +  - ][ +  - ]
    1303                 :            :                     }
    1304         [ +  - ]:          6 :                     if (!m_aAuthorInitials.isEmpty())
    1305                 :            :                     {
    1306 [ +  - ][ +  - ]:          6 :                         RTFValue::Pointer_t pValue(new RTFValue(m_aAuthorInitials));
                 [ +  - ]
    1307 [ +  - ][ +  - ]:          6 :                         aAttributes.set(NS_ooxml::LN_CT_Comment_initials, pValue);
         [ +  - ][ +  - ]
    1308                 :            :                     }
    1309 [ +  - ][ +  - ]:          6 :                     writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes));
         [ +  - ][ +  - ]
    1310 [ +  - ][ +  - ]:          6 :                     Mapper().props(pProperties);
         [ +  - ][ +  - ]
    1311                 :            :                 }
    1312                 :            :             }
    1313                 :         12 :             break;
    1314                 :            :         case RTF_SHPTXT:
    1315         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_SHAPETEXT;
    1316         [ #  # ]:          0 :             dispatchFlag(RTF_PARD);
    1317                 :          0 :             m_bNeedPap = true;
    1318                 :            :             OSL_ENSURE(!m_aShapetextBuffer.size(), "shapetext buffer is not empty");
    1319                 :          0 :             m_pCurrentBuffer = &m_aShapetextBuffer;
    1320                 :          0 :             break;
    1321                 :            :         case RTF_FORMFIELD:
    1322 [ #  # ][ #  # ]:          0 :             if (m_aStates.top().nDestinationState == DESTINATION_FIELDINSTRUCTION)
    1323         [ #  # ]:          0 :                 m_aStates.top().nDestinationState = DESTINATION_FORMFIELD;
    1324                 :          0 :             break;
    1325                 :            :         case RTF_FFNAME:
    1326         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_FORMFIELDNAME;
    1327                 :          0 :             break;
    1328                 :            :         case RTF_FFL:
    1329         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_FORMFIELDLIST;
    1330                 :          0 :             break;
    1331                 :            :         case RTF_DATAFIELD:
    1332         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_DATAFIELD;
    1333                 :          0 :             break;
    1334                 :            :         case RTF_INFO:
    1335         [ +  - ]:        108 :             m_aStates.top().nDestinationState = DESTINATION_INFO;
    1336                 :        108 :             break;
    1337                 :            :         case RTF_CREATIM:
    1338         [ +  - ]:         87 :             m_aStates.top().nDestinationState = DESTINATION_CREATIONTIME;
    1339                 :         87 :             break;
    1340                 :            :         case RTF_REVTIM:
    1341         [ +  - ]:         87 :             m_aStates.top().nDestinationState = DESTINATION_REVISIONTIME;
    1342                 :         87 :             break;
    1343                 :            :         case RTF_PRINTIM:
    1344         [ +  - ]:         81 :             m_aStates.top().nDestinationState = DESTINATION_PRINTTIME;
    1345                 :         81 :             break;
    1346                 :            :         case RTF_AUTHOR:
    1347         [ +  - ]:          9 :             m_aStates.top().nDestinationState = DESTINATION_AUTHOR;
    1348                 :          9 :             break;
    1349                 :            :         case RTF_KEYWORDS:
    1350         [ +  - ]:          6 :             m_aStates.top().nDestinationState = DESTINATION_KEYWORDS;
    1351                 :          6 :             break;
    1352                 :            :         case RTF_OPERATOR:
    1353         [ +  - ]:          9 :             m_aStates.top().nDestinationState = DESTINATION_OPERATOR;
    1354                 :          9 :             break;
    1355                 :            :         case RTF_COMPANY:
    1356         [ +  - ]:          9 :             m_aStates.top().nDestinationState = DESTINATION_COMPANY;
    1357                 :          9 :             break;
    1358                 :            :         case RTF_COMMENT:
    1359         [ +  - ]:         84 :             m_aStates.top().nDestinationState = DESTINATION_COMMENT;
    1360                 :         84 :             break;
    1361                 :            :         case RTF_OBJECT:
    1362         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_OBJECT;
    1363                 :          0 :             m_bObject = true;
    1364                 :          0 :             break;
    1365                 :            :         case RTF_OBJDATA:
    1366         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_OBJDATA;
    1367                 :          0 :             break;
    1368                 :            :         case RTF_RESULT:
    1369         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_RESULT;
    1370                 :          0 :             break;
    1371                 :            :         case RTF_ATNDATE:
    1372         [ +  - ]:          6 :             m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONDATE;
    1373                 :          6 :             break;
    1374                 :            :         case RTF_ATNAUTHOR:
    1375         [ +  - ]:          6 :             m_aStates.top().nDestinationState = DESTINATION_ANNOTATIONAUTHOR;
    1376                 :          6 :             break;
    1377                 :            :         case RTF_FALT:
    1378         [ +  - ]:        303 :             m_aStates.top().nDestinationState = DESTINATION_FALT;
    1379                 :        303 :             break;
    1380                 :            :         case RTF_FLYMAINCNT:
    1381         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_FLYMAINCONTENT;
    1382                 :          0 :             break;
    1383                 :            :         case RTF_LISTTEXT:
    1384                 :            :             // Should be ignored by any reader that understands Word 97 through Word 2007 numbering.
    1385                 :            :         case RTF_NONESTTABLES:
    1386                 :            :             // This destination should be ignored by readers that support nested tables.
    1387         [ +  - ]:         15 :             m_aStates.top().nDestinationState = DESTINATION_SKIP;
    1388                 :         15 :             break;
    1389                 :            :         case RTF_DO:
    1390         [ +  - ]:          3 :             m_aStates.top().nDestinationState = DESTINATION_DRAWINGOBJECT;
    1391                 :          3 :             break;
    1392                 :            :         case RTF_PN:
    1393         [ +  - ]:         12 :             m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING;
    1394                 :         12 :             break;
    1395                 :            :         case RTF_PNTEXT:
    1396                 :            :             // This destination should be ignored by readers that support paragraph numbering.
    1397         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_SKIP;
    1398                 :          0 :             break;
    1399                 :            :         case RTF_PNTXTA:
    1400         [ +  - ]:          9 :             m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER;
    1401                 :          9 :             break;
    1402                 :            :         case RTF_PNTXTB:
    1403         [ +  - ]:          9 :             m_aStates.top().nDestinationState = DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE;
    1404                 :          9 :             break;
    1405                 :            :         case RTF_TITLE:
    1406         [ +  - ]:         12 :             m_aStates.top().nDestinationState = DESTINATION_TITLE;
    1407                 :         12 :             break;
    1408                 :            :         case RTF_SUBJECT:
    1409         [ +  - ]:          9 :             m_aStates.top().nDestinationState = DESTINATION_SUBJECT;
    1410                 :          9 :             break;
    1411                 :            :         case RTF_DOCCOMM:
    1412         [ +  - ]:          6 :             m_aStates.top().nDestinationState = DESTINATION_DOCCOMM;
    1413                 :          6 :             break;
    1414                 :            :         case RTF_ATRFSTART:
    1415                 :            :         case RTF_ATRFEND:
    1416                 :            :             {
    1417                 :            :                 // We could send the real value here, but that would make the
    1418                 :            :                 // tokenizer more complicated, and dmapper doesn't read the
    1419                 :            :                 // result anyway.
    1420 [ +  - ][ +  - ]:         12 :                 RTFValue::Pointer_t pValue(new RTFValue(0));
                 [ +  - ]
    1421         [ +  - ]:         12 :                 m_aStates.top().nDestinationState = DESTINATION_SKIP;
    1422                 :            : 
    1423         [ +  - ]:         12 :                 RTFSprms aAttributes;
    1424         [ +  + ]:         12 :                 if (nKeyword == RTF_ATRFSTART)
    1425 [ +  - ][ +  - ]:          6 :                     aAttributes.set(NS_ooxml::LN_EG_RangeMarkupElements_commentRangeStart, pValue);
                 [ +  - ]
    1426                 :            :                 else
    1427 [ +  - ][ +  - ]:          6 :                     aAttributes.set(NS_ooxml::LN_EG_RangeMarkupElements_commentRangeEnd, pValue);
                 [ +  - ]
    1428 [ +  - ][ +  - ]:         12 :                 writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAttributes));
         [ +  - ][ +  - ]
    1429 [ +  - ][ +  - ]:         12 :                 Mapper().props(pProperties);
         [ +  - ][ +  - ]
                 [ +  - ]
    1430                 :            :             }
    1431                 :         12 :             break;
    1432                 :            :         case RTF_ATNID:
    1433         [ +  - ]:          6 :             m_aStates.top().nDestinationState = DESTINATION_ATNID;
    1434                 :          6 :             break;
    1435                 :            :         case RTF_MMATH:
    1436                 :            :         case RTF_MOMATHPARA:
    1437                 :            :             // Nothing to do here (just enter the destination) till RTF_MMATHPR is implemented.
    1438                 :        258 :             break;
    1439         [ +  - ]:       1461 :         case RTF_MR: m_aStates.top().nDestinationState = DESTINATION_MR; break;
    1440         [ +  - ]:        114 :         case RTF_MCHR: m_aStates.top().nDestinationState = DESTINATION_MCHR; break;
    1441         [ +  - ]:         12 :         case RTF_MPOS: m_aStates.top().nDestinationState = DESTINATION_MPOS; break;
    1442         [ +  - ]:          9 :         case RTF_MVERTJC: m_aStates.top().nDestinationState = DESTINATION_MVERTJC; break;
    1443         [ +  - ]:          6 :         case RTF_MSTRIKEH: m_aStates.top().nDestinationState = DESTINATION_MSTRIKEH; break;
    1444         [ +  - ]:         12 :         case RTF_MDEGHIDE: m_aStates.top().nDestinationState = DESTINATION_MDEGHIDE; break;
    1445         [ +  - ]:         18 :         case RTF_MTYPE: m_aStates.top().nDestinationState = DESTINATION_MTYPE; break;
    1446         [ +  - ]:          6 :         case RTF_MGROW: m_aStates.top().nDestinationState = DESTINATION_MGROW; break;
    1447                 :            :         case RTF_MHIDETOP:
    1448                 :            :         case RTF_MHIDEBOT:
    1449                 :            :         case RTF_MHIDELEFT:
    1450                 :            :         case RTF_MHIDERIGHT:
    1451                 :            :             // SmOoxmlImport::handleBorderBox will ignore these anyway, so silently ignore for now.
    1452         [ +  - ]:         24 :             m_aStates.top().nDestinationState = DESTINATION_SKIP;
    1453                 :         24 :             break;
    1454         [ +  - ]:          6 :         case RTF_MSUBHIDE: m_aStates.top().nDestinationState = DESTINATION_MSUBHIDE; break;
    1455         [ +  - ]:          6 :         case RTF_MSUPHIDE: m_aStates.top().nDestinationState = DESTINATION_MSUPHIDE; break;
    1456         [ +  - ]:         96 :         case RTF_MBEGCHR: m_aStates.top().nDestinationState = DESTINATION_MBEGCHR; break;
    1457         [ +  - ]:          9 :         case RTF_MSEPCHR: m_aStates.top().nDestinationState = DESTINATION_MSEPCHR; break;
    1458         [ +  - ]:         96 :         case RTF_MENDCHR: m_aStates.top().nDestinationState = DESTINATION_MENDCHR; break;
    1459 [ +  - ][ +  - ]:        174 :         OPEN_M_TOKEN(OMATH, oMath);
    1460 [ +  - ][ +  - ]:        102 :         OPEN_M_TOKEN(F, f);
    1461 [ +  - ][ +  - ]:         60 :         OPEN_M_TOKEN(FPR, fPr);
    1462 [ +  - ][ +  - ]:        324 :         OPEN_M_TOKEN(CTRLPR, ctrlPr);
    1463 [ +  - ][ +  - ]:        102 :         OPEN_M_TOKEN(NUM, num);
    1464 [ +  - ][ +  - ]:        102 :         OPEN_M_TOKEN(DEN, den);
    1465 [ +  - ][ +  - ]:         72 :         OPEN_M_TOKEN(ACC, acc);
    1466 [ +  - ][ +  - ]:         72 :         OPEN_M_TOKEN(ACCPR, accPr);
    1467 [ +  - ][ +  - ]:          6 :         OPEN_M_TOKEN(BAR, bar);
    1468 [ +  - ][ +  - ]:          6 :         OPEN_M_TOKEN(BARPR, barPr);
    1469 [ +  - ][ +  - ]:        588 :         OPEN_M_TOKEN(E, e);
    1470 [ +  - ][ +  - ]:        135 :         OPEN_M_TOKEN(D, d);
    1471 [ +  - ][ +  - ]:        135 :         OPEN_M_TOKEN(DPR, dPr);
    1472 [ +  - ][ +  - ]:         36 :         OPEN_M_TOKEN(FUNC, func);
    1473 [ +  - ][ +  - ]:         33 :         OPEN_M_TOKEN(FUNCPR, funcPr);
    1474 [ +  - ][ +  - ]:         36 :         OPEN_M_TOKEN(FNAME, fName);
    1475 [ +  - ][ +  - ]:         18 :         OPEN_M_TOKEN(LIMLOW, limLow);
    1476 [ +  - ][ +  - ]:          9 :         OPEN_M_TOKEN(LIMLOWPR, limLowPr);
    1477 [ +  - ][ +  - ]:         30 :         OPEN_M_TOKEN(LIM, lim);
    1478 [ +  - ][ +  - ]:          6 :         OPEN_M_TOKEN(M, m);
    1479 [ +  - ][ +  - ]:          3 :         OPEN_M_TOKEN(MPR, mPr);
    1480 [ +  - ][ +  - ]:         12 :         OPEN_M_TOKEN(MR, mr);
    1481 [ +  - ][ +  - ]:         36 :         OPEN_M_TOKEN(NARY, nary);
    1482 [ +  - ][ +  - ]:         36 :         OPEN_M_TOKEN(NARYPR, naryPr);
    1483 [ +  - ][ +  - ]:         84 :         OPEN_M_TOKEN(SUB, sub);
    1484 [ +  - ][ +  - ]:        162 :         OPEN_M_TOKEN(SUP, sup);
    1485 [ +  - ][ +  - ]:         12 :         OPEN_M_TOKEN(LIMUPP, limUpp);
    1486 [ +  - ][ +  - ]:          6 :         OPEN_M_TOKEN(LIMUPPPR, limUppPr);
    1487 [ +  - ][ +  - ]:         12 :         OPEN_M_TOKEN(GROUPCHR, groupChr);
    1488 [ +  - ][ +  - ]:         12 :         OPEN_M_TOKEN(GROUPCHRPR, groupChrPr);
    1489 [ +  - ][ +  - ]:          6 :         OPEN_M_TOKEN(BORDERBOX, borderBox);
    1490 [ +  - ][ +  - ]:          6 :         OPEN_M_TOKEN(BORDERBOXPR, borderBoxPr);
    1491 [ +  - ][ +  - ]:         18 :         OPEN_M_TOKEN(RAD, rad);
    1492 [ +  - ][ +  - ]:         15 :         OPEN_M_TOKEN(RADPR, radPr);
    1493 [ +  - ][ +  - ]:         18 :         OPEN_M_TOKEN(DEG, deg);
    1494 [ +  - ][ +  - ]:         24 :         OPEN_M_TOKEN(SSUB, sSub);
    1495 [ +  - ][ +  - ]:         12 :         OPEN_M_TOKEN(SSUBPR, sSubPr);
    1496 [ +  - ][ +  - ]:        102 :         OPEN_M_TOKEN(SSUP, sSup);
    1497 [ +  - ][ +  - ]:         51 :         OPEN_M_TOKEN(SSUPPR, sSupPr);
    1498 [ +  - ][ +  - ]:         12 :         OPEN_M_TOKEN(SSUBSUP, sSubSup);
    1499 [ +  - ][ +  - ]:          6 :         OPEN_M_TOKEN(SSUBSUPPR, sSubSupPr);
    1500 [ +  - ][ +  - ]:         12 :         OPEN_M_TOKEN(SPRE, sPre);
    1501 [ +  - ][ +  - ]:          6 :         OPEN_M_TOKEN(SPREPR, sPrePr);
    1502 [ +  - ][ +  - ]:          3 :         OPEN_M_TOKEN(BOX, box);
    1503 [ +  - ][ +  - ]:         18 :         OPEN_M_TOKEN(EQARR, eqArr);
    1504                 :            :         default:
    1505                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle destination '" << lcl_RtfToString(nKeyword) << "'");
    1506                 :            :             // Make sure we skip destinations (even without \*) till we don't handle them
    1507         [ +  - ]:        321 :             m_aStates.top().nDestinationState = DESTINATION_SKIP;
    1508         [ +  - ]:        321 :             aSkip.setParsed(false);
    1509                 :        321 :             break;
    1510                 :            :     }
    1511                 :            : 
    1512         [ +  - ]:       8187 :     return 0;
    1513                 :            : }
    1514                 :            : 
    1515                 :      73758 : int RTFDocumentImpl::dispatchSymbol(RTFKeyword nKeyword)
    1516                 :            : {
    1517         [ +  + ]:      73758 :     if (nKeyword != RTF_HEXCHAR)
    1518         [ +  - ]:       3687 :         checkUnicode();
    1519         [ +  - ]:      73758 :     RTFSkipDestination aSkip(*this);
    1520                 :      73758 :     sal_uInt8 cCh = 0;
    1521                 :            : 
    1522                 :            :     // Trivial symbols
    1523   [ +  +  +  +  :      73758 :     switch (nKeyword)
          +  +  +  +  +  
             +  +  +  + ]
    1524                 :            :     {
    1525                 :        153 :         case RTF_LINE: cCh = '\n'; break;
    1526                 :        120 :         case RTF_TAB: cCh = '\t'; break;
    1527                 :         57 :         case RTF_BACKSLASH: cCh = '\\'; break;
    1528                 :         69 :         case RTF_LBRACE: cCh = '{'; break;
    1529                 :         60 :         case RTF_RBRACE: cCh = '}'; break;
    1530                 :         27 :         case RTF_EMDASH: cCh = 151; break;
    1531                 :         30 :         case RTF_ENDASH: cCh = 150; break;
    1532                 :         45 :         case RTF_BULLET: cCh = 149; break;
    1533                 :         48 :         case RTF_LQUOTE: cCh = 145; break;
    1534                 :         39 :         case RTF_RQUOTE: cCh = 146; break;
    1535                 :         66 :         case RTF_LDBLQUOTE: cCh = 147; break;
    1536                 :         27 :         case RTF_RDBLQUOTE: cCh = 148; break;
    1537                 :      73017 :         default: break;
    1538                 :            :     }
    1539         [ +  + ]:      73758 :     if (cCh > 0)
    1540                 :            :     {
    1541         [ +  - ]:        741 :         OUString aStr(OStringToOUString(OString(cCh), RTL_TEXTENCODING_MS_1252));
    1542         [ +  - ]:        741 :         text(aStr);
    1543                 :        741 :         return 0;
    1544                 :            :     }
    1545                 :            : 
    1546   [ +  +  +  +  :      73017 :     switch (nKeyword)
          +  +  +  +  +  
             -  +  +  +  
                      + ]
    1547                 :            :     {
    1548                 :            :         case RTF_IGNORE:
    1549                 :       1479 :             m_bSkipUnknown = true;
    1550         [ +  - ]:       1479 :             aSkip.setReset(false);
    1551                 :       1479 :             return 0;
    1552                 :            :             break;
    1553                 :            :         case RTF_PAR:
    1554                 :            :             {
    1555         [ +  - ]:        837 :                 checkFirstRun();
    1556                 :        837 :                 bool bNeedPap = m_bNeedPap;
    1557         [ +  - ]:        837 :                 checkNeedPap();
    1558         [ +  + ]:        837 :                 if (bNeedPap)
    1559         [ +  - ]:        279 :                     runProps();
    1560         [ +  + ]:        837 :                 if (!m_pCurrentBuffer)
    1561         [ +  - ]:        822 :                     parBreak();
    1562 [ +  - ][ +  - ]:         15 :                 else if (m_aStates.top().nDestinationState != DESTINATION_SHAPETEXT)
    1563                 :            :                 {
    1564         [ +  - ]:         15 :                     RTFValue::Pointer_t pValue;
    1565 [ +  - ][ +  - ]:         15 :                     m_pCurrentBuffer->push_back(make_pair(BUFFER_PAR, pValue));
         [ +  - ][ +  - ]
    1566                 :            :                 }
    1567                 :            :                 // but don't emit properties yet, since they may change till the first text token arrives
    1568                 :        837 :                 m_bNeedPap = true;
    1569 [ +  - ][ +  + ]:        837 :                 if (!m_aStates.top().aFrame.inFrame())
    1570                 :        813 :                     m_bNeedPar = false;
    1571                 :        837 :                 m_bNeedFinalPar = false;
    1572                 :            :             }
    1573                 :        837 :             break;
    1574                 :            :         case RTF_SECT:
    1575         [ +  - ]:          3 :                 sectBreak();
    1576                 :          3 :             break;
    1577                 :            :         case RTF_NOBREAK:
    1578                 :            :             {
    1579                 :         57 :                 OUString aStr(SVT_HARD_SPACE);
    1580         [ +  - ]:         57 :                 text(aStr);
    1581                 :            :             }
    1582                 :         57 :             break;
    1583                 :            :         case RTF_NOBRKHYPH:
    1584                 :            :             {
    1585                 :          6 :                 OUString aStr(SVT_HARD_HYPHEN);
    1586         [ +  - ]:          6 :                 text(aStr);
    1587                 :            :             }
    1588                 :          6 :             break;
    1589                 :            :         case RTF_OPTHYPH:
    1590                 :            :             {
    1591                 :         39 :                 OUString aStr(SVT_SOFT_HYPHEN);
    1592         [ +  - ]:         39 :                 text(aStr);
    1593                 :            :             }
    1594                 :         39 :             break;
    1595                 :            :         case RTF_HEXCHAR:
    1596         [ +  - ]:      70071 :             m_aStates.top().nInternalState = INTERNAL_HEX;
    1597                 :      70071 :             break;
    1598                 :            :         case RTF_CELL:
    1599                 :            :         case RTF_NESTCELL:
    1600                 :            :             {
    1601         [ +  - ]:        285 :                 checkFirstRun();
    1602         [ +  + ]:        285 :                 if (m_bNeedPap)
    1603                 :            :                 {
    1604                 :            :                     // There were no runs in the cell, so we need to send paragraph and character properties here.
    1605 [ +  - ][ +  - ]:         48 :                     RTFValue::Pointer_t pPValue(new RTFValue(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1606 [ +  - ][ +  - ]:         48 :                     m_aTableBuffer.push_back(make_pair(BUFFER_PROPS, pPValue));
                 [ +  - ]
    1607 [ +  - ][ +  - ]:         48 :                     RTFValue::Pointer_t pCValue(new RTFValue(m_aStates.top().aCharacterAttributes, m_aStates.top().aCharacterSprms));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1608 [ +  - ][ +  - ]:         48 :                     m_aTableBuffer.push_back(make_pair(BUFFER_PROPS, pCValue));
         [ +  - ][ +  - ]
                 [ +  - ]
    1609                 :            :                 }
    1610                 :            : 
    1611         [ +  - ]:        285 :                 RTFValue::Pointer_t pValue;
    1612 [ +  - ][ +  - ]:        285 :                 m_aTableBuffer.push_back(make_pair(BUFFER_CELLEND, pValue));
                 [ +  - ]
    1613         [ +  - ]:        285 :                 m_bNeedPap = true;
    1614                 :            :             }
    1615                 :        285 :             break;
    1616                 :            :         case RTF_ROW:
    1617                 :            :         case RTF_NESTROW:
    1618                 :            :             {
    1619 [ +  - ][ +  - ]:         66 :                 if (m_aStates.top().nCells)
    1620                 :            :                 {
    1621                 :            :                     // Make a backup before we start popping elements
    1622 [ +  - ][ +  - ]:         66 :                     m_aStates.top().aTableInheritingCellsSprms = m_aStates.top().aTableCellsSprms;
                 [ +  - ]
    1623 [ +  - ][ +  - ]:         66 :                     m_aStates.top().aTableInheritingCellsAttributes = m_aStates.top().aTableCellsAttributes;
                 [ +  - ]
    1624 [ +  - ][ +  - ]:         66 :                     m_aStates.top().nInheritingCells = m_aStates.top().nCells;
    1625                 :            :                 }
    1626                 :            :                 else
    1627                 :            :                 {
    1628                 :            :                     // No table definition? Then inherit from the previous row
    1629 [ #  # ][ #  # ]:          0 :                     m_aStates.top().aTableCellsSprms = m_aStates.top().aTableInheritingCellsSprms;
                 [ #  # ]
    1630 [ #  # ][ #  # ]:          0 :                     m_aStates.top().aTableCellsAttributes = m_aStates.top().aTableInheritingCellsAttributes;
                 [ #  # ]
    1631 [ #  # ][ #  # ]:          0 :                     m_aStates.top().nCells = m_aStates.top().nInheritingCells;
    1632                 :            :                     // This can't be the first row, and we need cell width only there
    1633 [ #  # ][ #  # ]:          0 :                     while(m_aStates.top().aTableRowSprms.erase(NS_ooxml::LN_CT_TblGridBase_gridCol)) ;
                 [ #  # ]
    1634                 :            :                 }
    1635 [ +  - ][ +  + ]:        546 :                 for (int i = 0; i < m_aStates.top().nCells; ++i)
    1636                 :            :                 {
    1637 [ +  - ][ +  - ]:        480 :                     m_aStates.top().aTableCellSprms = m_aStates.top().aTableCellsSprms.front();
         [ +  - ][ +  - ]
    1638 [ +  - ][ +  - ]:        480 :                     m_aStates.top().aTableCellsSprms.pop_front();
    1639 [ +  - ][ +  - ]:        480 :                     m_aStates.top().aTableCellAttributes = m_aStates.top().aTableCellsAttributes.front();
         [ +  - ][ +  - ]
    1640 [ +  - ][ +  - ]:        480 :                     m_aStates.top().aTableCellsAttributes.pop_front();
    1641         [ +  - ]:        480 :                     replayBuffer(m_aTableBuffer);
    1642                 :            :                 }
    1643 [ +  - ][ +  - ]:         66 :                 m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
    1644 [ +  - ][ +  - ]:         66 :                 m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
    1645                 :            : 
    1646                 :            :                 writerfilter::Reference<Properties>::Pointer_t const pParagraphProperties(
    1647 [ +  - ][ +  - ]:        198 :                         new RTFReferenceProperties(m_aStates.top().aParagraphAttributes, m_aStates.top().aParagraphSprms)
                 [ +  - ]
    1648 [ +  - ][ +  - ]:        198 :                         );
         [ +  - ][ +  - ]
    1649 [ +  - ][ +  - ]:         66 :                 Mapper().props(pParagraphProperties);
                 [ +  - ]
    1650                 :            : 
    1651 [ +  - ][ -  + ]:         66 :                 if (m_aStates.top().aFrame.hasProperties())
    1652                 :            :                 {
    1653                 :            :                     writerfilter::Reference<Properties>::Pointer_t const pFrameProperties(
    1654 [ #  # ][ #  # ]:          0 :                             new RTFReferenceProperties(RTFSprms(), m_aStates.top().aFrame.getSprms()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1655 [ #  # ][ #  # ]:          0 :                     Mapper().props(pFrameProperties);
         [ #  # ][ #  # ]
    1656                 :            :                 }
    1657                 :            : 
    1658                 :            :                 // Table width.
    1659 [ +  - ][ +  - ]:         66 :                 RTFValue::Pointer_t pUnitValue(new RTFValue(3));
                 [ +  - ]
    1660         [ +  - ]:         66 :                 lcl_putNestedAttribute(m_aStates.top().aTableRowSprms,
    1661 [ +  - ][ +  - ]:        132 :                         NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_type, pUnitValue);
                 [ +  - ]
    1662 [ +  - ][ +  - ]:         66 :                 RTFValue::Pointer_t pWValue(new RTFValue(m_aStates.top().nCellX));
         [ +  - ][ +  - ]
    1663         [ +  - ]:         66 :                 lcl_putNestedAttribute(m_aStates.top().aTableRowSprms,
    1664 [ +  - ][ +  - ]:        132 :                         NS_ooxml::LN_CT_TblPrBase_tblW, NS_ooxml::LN_CT_TblWidth_w, pWValue);
                 [ +  - ]
    1665                 :            : 
    1666 [ +  - ][ +  - ]:         66 :                 RTFValue::Pointer_t pRowValue(new RTFValue(1));
                 [ +  - ]
    1667 [ +  - ][ +  - ]:         66 :                 if (m_aStates.top().nCells > 0)
    1668 [ +  - ][ +  - ]:         66 :                     m_aStates.top().aTableRowSprms.set(NS_sprm::LN_PRow, pRowValue);
         [ +  - ][ +  - ]
    1669                 :            :                 writerfilter::Reference<Properties>::Pointer_t const pTableRowProperties(
    1670 [ +  - ][ +  - ]:        198 :                         new RTFReferenceProperties(m_aStates.top().aTableRowAttributes, m_aStates.top().aTableRowSprms)
                 [ +  - ]
    1671 [ +  - ][ +  - ]:        198 :                         );
         [ +  - ][ +  - ]
    1672 [ +  - ][ +  - ]:         66 :                 Mapper().props(pTableRowProperties);
                 [ +  - ]
    1673                 :            : 
    1674         [ +  - ]:         66 :                 tableBreak();
    1675                 :         66 :                 m_bNeedPap = true;
    1676                 :         66 :                 m_bNeedFinalPar = true;
    1677                 :         66 :                 m_aTableBuffer.clear();
    1678         [ +  - ]:         66 :                 m_aStates.top().nCells = 0;
    1679         [ +  - ]:         66 :                 m_aStates.top().aTableCellsSprms.clear();
    1680 [ +  - ][ +  - ]:         66 :                 m_aStates.top().aTableCellsAttributes.clear();
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1681                 :            :             }
    1682                 :         66 :             break;
    1683                 :            :         case RTF_COLUMN:
    1684                 :            :             {
    1685                 :          0 :                 sal_uInt8 sBreak[] = { 0xe };
    1686         [ #  # ]:          0 :                 Mapper().startCharacterGroup();
    1687         [ #  # ]:          0 :                 Mapper().text(sBreak, 1);
    1688         [ #  # ]:          0 :                 Mapper().endCharacterGroup();
    1689                 :            :             }
    1690                 :          0 :             break;
    1691                 :            :         case RTF_CHFTN:
    1692                 :            :             // Nothing to do, dmapper assumes this is the default.
    1693                 :          6 :             break;
    1694                 :            :         case RTF_PAGE:
    1695                 :            :             {
    1696                 :        156 :                 sal_uInt8 sBreak[] = { 0xc };
    1697         [ +  - ]:        156 :                 Mapper().text(sBreak, 1);
    1698         [ +  + ]:        156 :                 if (!m_bNeedPap)
    1699         [ +  - ]:        150 :                     parBreak();
    1700                 :            :             }
    1701                 :        156 :             break;
    1702                 :            :         case RTF_CHPGN:
    1703                 :            :             {
    1704                 :          6 :                 OUString aStr("PAGE");
    1705         [ +  - ]:          6 :                 singleChar(0x13);
    1706         [ +  - ]:          6 :                 text(aStr);
    1707         [ +  - ]:          6 :                 singleChar(0x14, true);
    1708         [ +  - ]:          6 :                 singleChar(0x15);
    1709                 :            :             }
    1710                 :          6 :             break;
    1711                 :            :         default:
    1712                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle symbol '" << lcl_RtfToString(nKeyword) << "'");
    1713         [ +  - ]:          6 :             aSkip.setParsed(false);
    1714                 :          6 :             break;
    1715                 :            :     }
    1716         [ +  - ]:      73758 :     return 0;
    1717                 :            : }
    1718                 :            : 
    1719                 :      23991 : int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
    1720                 :            : {
    1721         [ +  - ]:      23991 :     checkUnicode();
    1722         [ +  - ]:      23991 :     RTFSkipDestination aSkip(*this);
    1723                 :      23991 :     int nParam = -1;
    1724                 :      23991 :     int nSprm = -1;
    1725                 :            : 
    1726                 :            :     // Map all underline flags to a single sprm.
    1727      [ -  -  + ]:      23991 :     switch (nKeyword)
    1728                 :            :     {
    1729                 :          0 :         case RTF_ULD: nSprm = 4; break;
    1730                 :          0 :         case RTF_ULW: nSprm = 2; break;
    1731                 :      23991 :         default: break;
    1732                 :            :     }
    1733         [ -  + ]:      23991 :     if (nSprm >= 0)
    1734                 :            :     {
    1735 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pValue(new RTFValue(nSprm));
                 [ #  # ]
    1736 [ #  # ][ #  # ]:          0 :         m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CKul, pValue);
         [ #  # ][ #  # ]
    1737         [ #  # ]:          0 :         return 0;
    1738                 :            :     }
    1739                 :            : 
    1740                 :            :     // Indentation
    1741   [ +  -  +  +  :      23991 :     switch (nKeyword)
                   -  + ]
    1742                 :            :     {
    1743                 :         15 :         case RTF_QC: nParam = 1; break;
    1744                 :          0 :         case RTF_QJ: nParam = 3; break;
    1745                 :        219 :         case RTF_QL: nParam = 0; break;
    1746                 :         30 :         case RTF_QR: nParam = 2; break;
    1747                 :          0 :         case RTF_QD: nParam = 4; break;
    1748                 :      23727 :         default: break;
    1749                 :            :     }
    1750         [ +  + ]:      23991 :     if (nParam >= 0)
    1751                 :            :     {
    1752 [ +  - ][ +  - ]:        264 :         RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    1753 [ +  - ][ +  - ]:        264 :         m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PJc, pValue);
         [ +  - ][ +  - ]
    1754         [ +  - ]:        264 :         return 0;
    1755                 :            :     }
    1756                 :            : 
    1757                 :            :     // Font Alignment
    1758   [ +  -  -  -  :      23727 :     switch (nKeyword)
                   -  + ]
    1759                 :            :     {
    1760                 :            :         case RTF_FAFIXED:
    1761                 :        243 :         case RTF_FAAUTO: nParam = NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_auto; break;
    1762                 :          0 :         case RTF_FAHANG: nParam = NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_top; break;
    1763                 :          0 :         case RTF_FACENTER: nParam = NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_center; break;
    1764                 :          0 :         case RTF_FAROMAN: nParam = NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_baseline; break;
    1765                 :          0 :         case RTF_FAVAR: nParam = NS_ooxml::LN_Value_wordprocessingml_ST_TextAlignment_bottom; break;
    1766                 :      23484 :         default: break;
    1767                 :            :     }
    1768         [ +  + ]:      23727 :     if (nParam >= 0)
    1769                 :            :     {
    1770 [ +  - ][ +  - ]:        243 :         RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    1771 [ +  - ][ +  - ]:        243 :         m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PWAlignFont, pValue);
         [ +  - ][ +  - ]
    1772         [ +  - ]:        243 :         return 0;
    1773                 :            :     }
    1774                 :            : 
    1775                 :            :     // Tab kind.
    1776   [ +  -  -  + ]:      23484 :     switch (nKeyword)
    1777                 :            :     {
    1778                 :          6 :         case RTF_TQR: nParam = 2; break;
    1779                 :          0 :         case RTF_TQC: nParam = 1; break;
    1780                 :          0 :         case RTF_TQDEC: nParam = 3; break;
    1781                 :      23478 :         default: break;
    1782                 :            :     }
    1783         [ +  + ]:      23484 :     if (nParam >= 0)
    1784                 :            :     {
    1785 [ +  - ][ +  - ]:          6 :         RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    1786 [ +  - ][ +  - ]:          6 :         m_aStates.top().aTabAttributes.set(NS_ooxml::LN_CT_TabStop_val, pValue);
         [ +  - ][ +  - ]
    1787         [ +  - ]:          6 :         return 0;
    1788                 :            :     }
    1789                 :            : 
    1790                 :            :     // Tab lead.
    1791   [ -  -  -  -  :      23478 :     switch (nKeyword)
                -  -  + ]
    1792                 :            :     {
    1793                 :          0 :         case RTF_TLDOT: nParam = 1; break;
    1794                 :          0 :         case RTF_TLMDOT: nParam = NS_ooxml::LN_Value_ST_TabTlc_middleDot; break;
    1795                 :          0 :         case RTF_TLHYPH: nParam = 2; break;
    1796                 :          0 :         case RTF_TLUL: nParam = 3; break;
    1797                 :          0 :         case RTF_TLTH: nParam = 2; break; // thick line is not supported by dmapper, this is just a hack
    1798                 :          0 :         case RTF_TLEQ: nParam = 0; break; // equal sign isn't, either
    1799                 :      23478 :         default: break;
    1800                 :            :     }
    1801         [ -  + ]:      23478 :     if (nParam >= 0)
    1802                 :            :     {
    1803 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ #  # ]
    1804 [ #  # ][ #  # ]:          0 :         m_aStates.top().aTabAttributes.set(NS_ooxml::LN_CT_TabStop_leader, pValue);
         [ #  # ][ #  # ]
    1805         [ #  # ]:          0 :         return 0;
    1806                 :            :     }
    1807                 :            : 
    1808                 :            :     // Border types
    1809                 :            :     {
    1810   [ -  +  -  -  :      23478 :         switch (nKeyword)
          +  -  -  -  +  
          +  +  +  +  +  
                +  +  + ]
    1811                 :            :         {
    1812                 :            :             // brdrhair and brdrs are the same, brdrw will make a difference
    1813                 :            :             // map to values in ooxml/model.xml resource ST_Border
    1814                 :          0 :             case RTF_BRDRHAIR: nParam = 5; break;
    1815                 :         51 :             case RTF_BRDRS: nParam = 1; break;
    1816                 :          0 :             case RTF_BRDRDOT: nParam = 6; break;
    1817                 :          0 :             case RTF_BRDRDASH: nParam = 7; break;
    1818                 :         51 :             case RTF_BRDRDB: nParam = 3; break;
    1819                 :          0 :             case RTF_BRDRTNTHSG: nParam = 11; break;
    1820                 :          0 :             case RTF_BRDRTNTHMG: nParam = 14; break;
    1821                 :          0 :             case RTF_BRDRTNTHLG: nParam = 17; break;
    1822                 :         30 :             case RTF_BRDRTHTNSG: nParam = 12; break;
    1823                 :         60 :             case RTF_BRDRTHTNMG: nParam = 15; break;
    1824                 :         54 :             case RTF_BRDRTHTNLG: nParam = 18; break;
    1825                 :         36 :             case RTF_BRDREMBOSS: nParam = 24; break;
    1826                 :         36 :             case RTF_BRDRENGRAVE: nParam = 25; break;
    1827                 :         66 :             case RTF_BRDROUTSET: nParam = 18; break;
    1828                 :         60 :             case RTF_BRDRINSET: nParam = 17; break;
    1829                 :        144 :             case RTF_BRDRNONE: nParam = 0; break;
    1830                 :      22890 :             default: break;
    1831                 :            :         }
    1832         [ +  + ]:      23478 :         if (nParam >= 0)
    1833                 :            :         {
    1834 [ +  - ][ +  - ]:        588 :             RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    1835 [ +  - ][ +  - ]:        588 :             lcl_putBorderProperty(m_aStates, NS_rtf::LN_BRCTYPE, pValue);
                 [ +  - ]
    1836         [ +  - ]:        588 :             return 0;
    1837                 :            :         }
    1838                 :            :     }
    1839                 :            : 
    1840                 :            :     // Section breaks
    1841   [ +  -  +  -  :      22890 :     switch (nKeyword)
                   -  + ]
    1842                 :            :     {
    1843                 :         99 :         case RTF_SBKNONE: nParam = 0; break;
    1844                 :          0 :         case RTF_SBKCOL: nParam = 1; break;
    1845                 :          3 :         case RTF_SBKPAGE: nParam = 2; break;
    1846                 :          0 :         case RTF_SBKEVEN: nParam = 3; break;
    1847                 :          0 :         case RTF_SBKODD: nParam = 4; break;
    1848                 :      22788 :         default: break;
    1849                 :            :     }
    1850         [ +  + ]:      22890 :     if (nParam >= 0)
    1851                 :            :     {
    1852 [ +  - ][ +  - ]:        102 :         RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    1853 [ +  - ][ +  - ]:        102 :         m_aStates.top().aSectionSprms.set(NS_sprm::LN_SBkc, pValue);
         [ +  - ][ +  - ]
    1854         [ +  - ]:        102 :         return 0;
    1855                 :            :     }
    1856                 :            : 
    1857                 :            :     // Footnote numbering
    1858   [ +  -  -  -  :      22788 :     switch (nKeyword)
                -  -  + ]
    1859                 :            :     {
    1860                 :         90 :         case RTF_FTNNAR: nParam = NS_ooxml::LN_Value_ST_NumberFormat_decimal; break;
    1861                 :          0 :         case RTF_FTNNALC: nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter; break;
    1862                 :          0 :         case RTF_FTNNAUC: nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperLetter; break;
    1863                 :          0 :         case RTF_FTNNRLC: nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman; break;
    1864                 :          0 :         case RTF_FTNNRUC: nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperRoman; break;
    1865                 :          0 :         case RTF_FTNNCHI: nParam = NS_ooxml::LN_Value_ST_NumberFormat_chicago; break;
    1866                 :      22698 :         default: break;
    1867                 :            :     }
    1868         [ +  + ]:      22788 :     if (nParam >= 0)
    1869                 :            :     {
    1870 [ +  - ][ +  - ]:         90 :         RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    1871 [ +  - ][ +  - ]:         90 :         lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_footnotePr, NS_ooxml::LN_CT_FtnProps_numFmt, pValue);
                 [ +  - ]
    1872         [ +  - ]:         90 :         return 0;
    1873                 :            :     }
    1874                 :            : 
    1875                 :            :     // Footnote restart type
    1876   [ -  -  +  + ]:      22698 :     switch (nKeyword)
    1877                 :            :     {
    1878                 :          0 :         case RTF_FTNRSTPG: nParam = NS_ooxml::LN_Value_ST_RestartNumber_eachPage; break;
    1879                 :          0 :         case RTF_FTNRESTART: nParam = NS_ooxml::LN_Value_ST_RestartNumber_eachSect; break;
    1880                 :         84 :         case RTF_FTNRSTCONT: nParam = NS_ooxml::LN_Value_ST_RestartNumber_continuous; break;
    1881                 :      22614 :         default: break;
    1882                 :            :     }
    1883         [ +  + ]:      22698 :     if (nParam >= 0)
    1884                 :            :     {
    1885 [ +  - ][ +  - ]:         84 :         RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    1886 [ +  - ][ +  - ]:         84 :         lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_footnotePr, NS_ooxml::LN_EG_FtnEdnNumProps_numRestart, pValue);
                 [ +  - ]
    1887         [ +  - ]:         84 :         return 0;
    1888                 :            :     }
    1889                 :            : 
    1890                 :            :     // Endnote numbering
    1891   [ +  -  -  +  :      22614 :     switch (nKeyword)
                -  -  + ]
    1892                 :            :     {
    1893                 :          6 :         case RTF_AFTNNAR: nParam = NS_ooxml::LN_Value_ST_NumberFormat_decimal; break;
    1894                 :          0 :         case RTF_AFTNNALC: nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerLetter; break;
    1895                 :          0 :         case RTF_AFTNNAUC: nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperLetter; break;
    1896                 :         84 :         case RTF_AFTNNRLC: nParam = NS_ooxml::LN_Value_ST_NumberFormat_lowerRoman; break;
    1897                 :          0 :         case RTF_AFTNNRUC: nParam = NS_ooxml::LN_Value_ST_NumberFormat_upperRoman; break;
    1898                 :          0 :         case RTF_AFTNNCHI: nParam = NS_ooxml::LN_Value_ST_NumberFormat_chicago; break;
    1899                 :      22524 :         default: break;
    1900                 :            :     }
    1901         [ +  + ]:      22614 :     if (nParam >= 0)
    1902                 :            :     {
    1903 [ +  - ][ +  - ]:         90 :         RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    1904 [ +  - ][ +  - ]:         90 :         lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_endnotePr, NS_ooxml::LN_CT_EdnProps_numFmt, pValue);
                 [ +  - ]
    1905         [ +  - ]:         90 :         return 0;
    1906                 :            :     }
    1907                 :            : 
    1908                 :            :     // Cell Text Flow
    1909   [ +  -  -  -  :      22524 :     switch (nKeyword)
                   -  + ]
    1910                 :            :     {
    1911                 :        354 :         case RTF_CLTXLRTB:  nParam = 0; break;
    1912                 :          0 :         case RTF_CLTXTBRL:  nParam = 1; break;
    1913                 :          0 :         case RTF_CLTXBTLR:  nParam = 3; break;
    1914                 :          0 :         case RTF_CLTXLRTBV: nParam = 4; break;
    1915                 :          0 :         case RTF_CLTXTBRLV: nParam = 5; break;
    1916                 :      22170 :         default: break;
    1917                 :            :     }
    1918         [ +  + ]:      22524 :     if (nParam >= 0)
    1919                 :            :     {
    1920 [ +  - ][ +  - ]:        354 :         RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    1921 [ +  - ][ +  - ]:        354 :         m_aStates.top().aTableCellSprms.set(NS_ooxml::LN_CT_TcPrBase_textDirection, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    1922                 :            :     }
    1923                 :            : 
    1924                 :            :     // Trivial paragraph flags
    1925   [ -  +  +  +  :      22524 :     switch (nKeyword)
                      + ]
    1926                 :            :     {
    1927         [ #  # ]:          0 :         case RTF_KEEP: if (m_pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeep; break;
    1928         [ +  + ]:        108 :         case RTF_KEEPN: if (m_pCurrentBuffer != &m_aTableBuffer) nParam = NS_sprm::LN_PFKeepFollow; break;
    1929                 :        645 :         case RTF_INTBL: m_pCurrentBuffer = &m_aTableBuffer; nParam = NS_sprm::LN_PFInTable; break;
    1930                 :          6 :         case RTF_PAGEBB: nParam = NS_sprm::LN_PFPageBreakBefore; break;
    1931                 :      21765 :         default: break;
    1932                 :            :     }
    1933         [ +  + ]:      22524 :     if (nParam >= 0)
    1934                 :            :     {
    1935 [ +  - ][ +  - ]:       1086 :         RTFValue::Pointer_t pValue(new RTFValue(1));
                 [ +  - ]
    1936 [ +  - ][ +  - ]:       1086 :         m_aStates.top().aParagraphSprms.erase(NS_sprm::LN_PFInTable);
    1937 [ +  - ][ +  - ]:       1086 :         m_aStates.top().aParagraphSprms.set(nParam, pValue);
         [ +  - ][ +  - ]
    1938         [ +  - ]:       1086 :         return 0;
    1939                 :            :     }
    1940                 :            : 
    1941   [ +  +  +  +  :      21438 :     switch (nKeyword)
          +  +  +  +  +  
          +  +  +  -  -  
          +  -  +  -  -  
          +  -  +  +  +  
          +  +  +  +  -  
          +  -  +  -  +  
          -  +  -  +  +  
          +  -  -  -  -  
          -  -  -  -  +  
          +  -  -  -  -  
          -  -  -  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                      + ]
    1942                 :            :     {
    1943                 :            :         case RTF_FNIL:
    1944                 :            :         case RTF_FROMAN:
    1945                 :            :         case RTF_FSWISS:
    1946                 :            :         case RTF_FMODERN:
    1947                 :            :         case RTF_FSCRIPT:
    1948                 :            :         case RTF_FDECOR:
    1949                 :            :         case RTF_FTECH:
    1950                 :            :         case RTF_FBIDI:
    1951                 :            :             // TODO ooxml:CT_Font_family seems to be ignored by the domain mapper
    1952                 :       1659 :             break;
    1953                 :            :         case RTF_ANSI:
    1954         [ +  - ]:        135 :             m_aStates.top().nCurrentEncoding = RTL_TEXTENCODING_MS_1252;
    1955                 :        135 :             break;
    1956                 :            :         case RTF_PLAIN:
    1957                 :            :             {
    1958 [ +  - ][ +  - ]:        387 :                 m_aStates.top().aCharacterSprms = getDefaultState().aCharacterSprms;
                 [ +  - ]
    1959 [ +  - ][ +  - ]:        387 :                 RTFValue::Pointer_t pValue = m_aStates.top().aCharacterSprms.find(NS_sprm::LN_CRgFtc0);
    1960         [ +  + ]:        387 :                 if (pValue.get())
    1961 [ +  - ][ +  - ]:        336 :                     m_aStates.top().nCurrentEncoding = getEncoding(pValue->getInt());
                 [ +  - ]
    1962 [ +  - ][ +  - ]:        387 :                 m_aStates.top().aCharacterAttributes = getDefaultState().aCharacterAttributes;
         [ +  - ][ +  - ]
    1963                 :            :             }
    1964                 :        387 :             break;
    1965                 :            :         case RTF_PARD:
    1966 [ +  - ][ +  - ]:        522 :             m_aStates.top().aParagraphSprms = m_aDefaultState.aParagraphSprms;
    1967 [ +  - ][ +  - ]:        522 :             m_aStates.top().aParagraphAttributes = m_aDefaultState.aParagraphAttributes;
    1968 [ +  - ][ +  - ]:        522 :             m_aStates.top().resetFrame();
    1969                 :        522 :             m_pCurrentBuffer = 0;
    1970                 :        522 :             break;
    1971                 :            :         case RTF_SECTD:
    1972 [ +  - ][ +  - ]:        120 :             m_aStates.top().aSectionSprms = m_aDefaultState.aSectionSprms;
    1973 [ +  - ][ +  - ]:        120 :             m_aStates.top().aSectionAttributes = m_aDefaultState.aSectionAttributes;
    1974                 :        120 :             break;
    1975                 :            :         case RTF_TROWD:
    1976 [ +  - ][ +  - ]:         99 :             m_aStates.top().aTableRowSprms = m_aDefaultState.aTableRowSprms;
    1977 [ +  - ][ +  - ]:         99 :             m_aStates.top().aTableRowAttributes = m_aDefaultState.aTableRowAttributes;
    1978         [ +  - ]:         99 :             m_aStates.top().nCellX = 0;
    1979                 :            :             // In case the table definition is in the middle of the row
    1980                 :            :             // (invalid), make sure table definition is emitted.
    1981                 :         99 :             m_bNeedPap = true;
    1982                 :         99 :             break;
    1983                 :            :         case RTF_WIDCTLPAR:
    1984                 :            :         case RTF_NOWIDCTLPAR:
    1985                 :            :             {
    1986 [ +  - ][ +  - ]:        552 :                 RTFValue::Pointer_t pValue(new RTFValue(nKeyword == RTF_WIDCTLPAR));
                 [ +  - ]
    1987 [ +  - ][ +  - ]:        552 :                 m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PFWidowControl, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    1988                 :            :             }
    1989                 :        552 :             break;
    1990                 :            :         case RTF_BOX:
    1991                 :            :             {
    1992         [ +  - ]:          3 :                 RTFSprms aAttributes;
    1993 [ +  - ][ +  - ]:          3 :                 RTFValue::Pointer_t pValue(new RTFValue(aAttributes));
         [ +  - ][ +  - ]
    1994         [ +  + ]:         15 :                 for (int i = 0; i < 4; i++)
    1995 [ +  - ][ +  - ]:         12 :                     m_aStates.top().aParagraphSprms.set(lcl_getParagraphBorder(i), pValue);
         [ +  - ][ +  - ]
    1996 [ +  - ][ +  - ]:          3 :                 m_aStates.top().nBorderState = BORDER_PARAGRAPH_BOX;
    1997                 :            :             }
    1998                 :          3 :             break;
    1999                 :            :         case RTF_LTRSECT:
    2000                 :            :         case RTF_RTLSECT:
    2001                 :            :             {
    2002 [ +  - ][ +  - ]:         21 :                 RTFValue::Pointer_t pValue(new RTFValue(nKeyword == RTF_LTRSECT ? 0 : 1));
                 [ +  - ]
    2003 [ +  - ][ +  - ]:         21 :                 m_aStates.top().aParagraphSprms.set(NS_sprm::LN_STextFlow, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2004                 :            :             }
    2005                 :         21 :             break;
    2006                 :            :         case RTF_LTRPAR:
    2007                 :            :         case RTF_RTLPAR:
    2008                 :            :             {
    2009 [ +  - ][ +  - ]:        156 :                 RTFValue::Pointer_t pValue(new RTFValue(nKeyword == RTF_LTRPAR ? 0 : 1));
                 [ +  - ]
    2010 [ +  - ][ +  - ]:        156 :                 m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PFrameTextFlow, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2011                 :            :             }
    2012                 :        156 :             break;
    2013                 :            :         case RTF_LTRROW:
    2014                 :            :         case RTF_RTLROW:
    2015                 :            :             {
    2016 [ +  - ][ +  - ]:        111 :                 RTFValue::Pointer_t pValue(new RTFValue(nKeyword == RTF_LTRROW ? 0 : 1));
                 [ +  - ]
    2017 [ +  - ][ +  - ]:        111 :                 m_aStates.top().aParagraphSprms.set(NS_sprm::LN_TTextFlow, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2018                 :            :             }
    2019                 :        111 :             break;
    2020                 :            :         case RTF_LTRCH:
    2021                 :            :         case RTF_RTLCH:
    2022                 :            :             // dmapper does not support these.
    2023                 :       4323 :             break;
    2024                 :            :         case RTF_ULNONE:
    2025                 :            :             {
    2026 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(0));
                 [ #  # ]
    2027 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CKul, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2028                 :            :             }
    2029                 :          0 :             break;
    2030                 :            :         case RTF_NONSHPPICT:
    2031                 :            :         case RTF_MMATHPICT: // Picture group used by readers not understanding \moMath group
    2032         [ #  # ]:          0 :             m_aStates.top().nDestinationState = DESTINATION_SKIP;
    2033                 :          0 :             break;
    2034                 :            :         case RTF_CLBRDRT:
    2035                 :            :         case RTF_CLBRDRL:
    2036                 :            :         case RTF_CLBRDRB:
    2037                 :            :         case RTF_CLBRDRR:
    2038                 :            :             {
    2039         [ +  - ]:       1416 :                 RTFSprms aAttributes;
    2040         [ +  - ]:       1416 :                 RTFSprms aSprms;
    2041 [ +  - ][ +  - ]:       1416 :                 RTFValue::Pointer_t pValue(new RTFValue(aAttributes, aSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    2042   [ +  +  +  +  :       1416 :                 switch (nKeyword)
                      - ]
    2043                 :            :                 {
    2044                 :        354 :                     case RTF_CLBRDRT: nParam = NS_ooxml::LN_CT_TcBorders_top; break;
    2045                 :        354 :                     case RTF_CLBRDRL: nParam = NS_ooxml::LN_CT_TcBorders_left; break;
    2046                 :        354 :                     case RTF_CLBRDRB: nParam = NS_ooxml::LN_CT_TcBorders_bottom; break;
    2047                 :        354 :                     case RTF_CLBRDRR: nParam = NS_ooxml::LN_CT_TcBorders_right; break;
    2048                 :          0 :                     default: break;
    2049                 :            :                 }
    2050 [ +  - ][ +  - ]:       1416 :                 lcl_putNestedSprm(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_tcBorders, nParam, pValue);
         [ +  - ][ +  - ]
    2051 [ +  - ][ +  - ]:       1416 :                 m_aStates.top().nBorderState = BORDER_CELL;
    2052                 :            :             }
    2053                 :       1416 :             break;
    2054                 :            :         case RTF_PGBRDRT:
    2055                 :            :         case RTF_PGBRDRL:
    2056                 :            :         case RTF_PGBRDRB:
    2057                 :            :         case RTF_PGBRDRR:
    2058                 :            :             {
    2059         [ #  # ]:          0 :                 RTFSprms aAttributes;
    2060         [ #  # ]:          0 :                 RTFSprms aSprms;
    2061 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(aAttributes, aSprms));
         [ #  # ][ #  # ]
                 [ #  # ]
    2062   [ #  #  #  #  :          0 :                 switch (nKeyword)
                      # ]
    2063                 :            :                 {
    2064                 :          0 :                     case RTF_PGBRDRT: nParam = NS_ooxml::LN_CT_PageBorders_top; break;
    2065                 :          0 :                     case RTF_PGBRDRL: nParam = NS_ooxml::LN_CT_PageBorders_left; break;
    2066                 :          0 :                     case RTF_PGBRDRB: nParam = NS_ooxml::LN_CT_PageBorders_bottom; break;
    2067                 :          0 :                     case RTF_PGBRDRR: nParam = NS_ooxml::LN_CT_PageBorders_right; break;
    2068                 :          0 :                     default: break;
    2069                 :            :                 }
    2070 [ #  # ][ #  # ]:          0 :                 lcl_putNestedSprm(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgBorders, nParam, pValue);
         [ #  # ][ #  # ]
    2071 [ #  # ][ #  # ]:          0 :                 m_aStates.top().nBorderState = BORDER_PAGE;
    2072                 :            :             }
    2073                 :          0 :             break;
    2074                 :            :         case RTF_BRDRT:
    2075                 :            :         case RTF_BRDRL:
    2076                 :            :         case RTF_BRDRB:
    2077                 :            :         case RTF_BRDRR:
    2078                 :            :             {
    2079         [ +  - ]:          3 :                 RTFSprms aAttributes;
    2080         [ +  - ]:          3 :                 RTFSprms aSprms;
    2081 [ +  - ][ +  - ]:          3 :                 RTFValue::Pointer_t pValue(new RTFValue(aAttributes, aSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    2082   [ -  -  +  -  :          3 :                 switch (nKeyword)
                      - ]
    2083                 :            :                 {
    2084                 :          0 :                     case RTF_BRDRT: nParam = lcl_getParagraphBorder(0); break;
    2085                 :          0 :                     case RTF_BRDRL: nParam = lcl_getParagraphBorder(1); break;
    2086                 :          3 :                     case RTF_BRDRB: nParam = lcl_getParagraphBorder(2); break;
    2087                 :          0 :                     case RTF_BRDRR: nParam = lcl_getParagraphBorder(3); break;
    2088                 :          0 :                     default: break;
    2089                 :            :                 }
    2090 [ +  - ][ +  - ]:          3 :                 lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PrBase_pBdr, nParam, pValue);
         [ +  - ][ +  - ]
    2091 [ +  - ][ +  - ]:          3 :                 m_aStates.top().nBorderState = BORDER_PARAGRAPH;
    2092                 :            :             }
    2093                 :          3 :             break;
    2094                 :            :         case RTF_CLVMGF:
    2095                 :            :             {
    2096 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(NS_ooxml::LN_Value_ST_Merge_restart));
                 [ #  # ]
    2097 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aTableCellSprms.set(NS_ooxml::LN_CT_TcPrBase_vMerge, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2098                 :            :             }
    2099                 :          0 :             break;
    2100                 :            :         case RTF_CLVMRG:
    2101                 :            :             {
    2102 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(NS_ooxml::LN_Value_ST_Merge_continue));
                 [ #  # ]
    2103 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aTableCellSprms.set(NS_ooxml::LN_CT_TcPrBase_vMerge, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2104                 :            :             }
    2105                 :          0 :             break;
    2106                 :            :         case RTF_CLVERTALT:
    2107                 :            :         case RTF_CLVERTALC:
    2108                 :            :         case RTF_CLVERTALB:
    2109                 :            :             {
    2110   [ +  -  -  - ]:        450 :                 switch (nKeyword)
    2111                 :            :                 {
    2112                 :        450 :                     case RTF_CLVERTALT: nParam = 0; break;
    2113                 :          0 :                     case RTF_CLVERTALC: nParam = 1; break;
    2114                 :          0 :                     case RTF_CLVERTALB: nParam = 3; break;
    2115                 :          0 :                     default: break;
    2116                 :            :                 }
    2117 [ +  - ][ +  - ]:        450 :                 RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    2118 [ +  - ][ +  - ]:        450 :                 m_aStates.top().aTableCellSprms.set(NS_ooxml::LN_CT_TcPrBase_vAlign, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2119                 :            :             }
    2120                 :        450 :             break;
    2121                 :            :         case RTF_TRKEEP:
    2122                 :            :             {
    2123 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(1));
                 [ #  # ]
    2124 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aTableRowSprms.set(NS_sprm::LN_TCantSplit, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2125                 :            :             }
    2126                 :            :         case RTF_SECTUNLOCKED:
    2127                 :            :             {
    2128 [ +  - ][ +  - ]:         84 :                 RTFValue::Pointer_t pValue(new RTFValue(!nParam));
                 [ +  - ]
    2129 [ +  - ][ +  - ]:         84 :                 m_aStates.top().aSectionSprms.set(NS_ooxml::LN_EG_SectPrContents_formProt, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2130                 :            :             }
    2131                 :            :         case RTF_PGNDEC:
    2132                 :            :         case RTF_PGNUCRM:
    2133                 :            :         case RTF_PGNLCRM:
    2134                 :            :         case RTF_PGNUCLTR:
    2135                 :            :         case RTF_PGNLCLTR:
    2136                 :            :         case RTF_PGNBIDIA:
    2137                 :            :         case RTF_PGNBIDIB:
    2138                 :            :             // These should be mapped to NS_ooxml::LN_EG_SectPrContents_pgNumType, but dmapper has no API for that at the moment.
    2139                 :        249 :             break;
    2140                 :            :         case RTF_LOCH:
    2141                 :            :             // Noop, dmapper detects this automatically.
    2142                 :       2979 :             break;
    2143                 :            :         case RTF_HICH:
    2144         [ +  - ]:       2223 :             m_aStates.top().bIsCjk = true;
    2145                 :       2223 :             break;
    2146                 :            :         case RTF_DBCH:
    2147         [ +  - ]:       3222 :             m_aStates.top().bIsCjk = false;
    2148                 :       3222 :             break;
    2149                 :            :         case RTF_TITLEPG:
    2150                 :            :             {
    2151 [ +  - ][ +  - ]:         18 :                 RTFValue::Pointer_t pValue(new RTFValue(1));
                 [ +  - ]
    2152 [ +  - ][ +  - ]:         18 :                 m_aStates.top().aSectionSprms.set(NS_ooxml::LN_EG_SectPrContents_titlePg, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2153                 :            :             }
    2154                 :         18 :             break;
    2155                 :            :         case RTF_SUPER:
    2156                 :            :             {
    2157         [ +  - ]:         21 :                 if (!m_pCurrentBuffer)
    2158                 :         21 :                     m_pCurrentBuffer = &m_aSuperBuffer;
    2159 [ +  - ][ +  - ]:         21 :                 RTFValue::Pointer_t pValue(new RTFValue("superscript"));
                 [ +  - ]
    2160 [ +  - ][ +  - ]:         21 :                 m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2161                 :            :             }
    2162                 :         21 :             break;
    2163                 :            :         case RTF_SUB:
    2164                 :            :             {
    2165 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue("subscript"));
                 [ #  # ]
    2166 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_vertAlign, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2167                 :            :             }
    2168                 :          0 :             break;
    2169                 :            :         case RTF_NOSUPERSUB:
    2170         [ +  - ]:          3 :             if (m_pCurrentBuffer == &m_aSuperBuffer)
    2171                 :            :             {
    2172         [ +  - ]:          3 :                 replayBuffer(m_aSuperBuffer);
    2173                 :          3 :                 m_pCurrentBuffer = 0;
    2174                 :            :             }
    2175 [ +  - ][ +  - ]:          3 :             m_aStates.top().aCharacterSprms.erase(NS_ooxml::LN_EG_RPrBase_vertAlign);
    2176                 :          3 :             break;
    2177                 :            :         case RTF_LINEPPAGE:
    2178                 :            :         case RTF_LINECONT:
    2179                 :            :             {
    2180 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(nKeyword == RTF_LINEPPAGE ? 0 : 2));
         [ #  # ][ #  # ]
    2181         [ #  # ]:          0 :                 lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2182 [ #  # ][ #  # ]:          0 :                         NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_restart, pValue);
         [ #  # ][ #  # ]
    2183                 :            :             }
    2184                 :          0 :             break;
    2185                 :            :         case RTF_AENDDOC:
    2186                 :            :             // Noop, this is the default in Writer.
    2187                 :        102 :             break;
    2188                 :            :         case RTF_AENDNOTES:
    2189                 :            :             // Noop, Writer does not support having endnotes at the end of section.
    2190                 :          0 :             break;
    2191                 :            :         case RTF_AFTNRSTCONT:
    2192                 :            :             // Noop, this is the default in Writer.
    2193                 :         84 :             break;
    2194                 :            :         case RTF_AFTNRESTART:
    2195                 :            :             // Noop, Writer does not support restarting endnotes at each section.
    2196                 :          0 :             break;
    2197                 :            :         case RTF_FTNBJ:
    2198                 :            :             // Noop, this is the default in Writer.
    2199                 :        105 :             break;
    2200                 :            :         case RTF_ENDDOC:
    2201                 :            :             {
    2202 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(NS_ooxml::LN_Value_ST_RestartNumber_eachSect));
                 [ #  # ]
    2203 [ #  # ][ #  # ]:          0 :                 lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_footnotePr, NS_ooxml::LN_EG_FtnEdnNumProps_numRestart, pValue);
         [ #  # ][ #  # ]
    2204                 :            :             }
    2205                 :          0 :             break;
    2206                 :            :         case RTF_NOLINE:
    2207 [ +  - ][ +  - ]:        162 :             lcl_eraseNestedAttribute(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_distance);
    2208                 :        162 :             break;
    2209                 :            :         case RTF_FORMSHADE:
    2210                 :            :             // Noop, this is the default in Writer.
    2211                 :         87 :             break;
    2212                 :            :         case RTF_PNGBLIP:
    2213         [ +  - ]:         12 :             m_aStates.top().aPicture.nStyle = BMPSTYLE_PNG;
    2214                 :         12 :             break;
    2215 [ #  # ][ #  # ]:          0 :         case RTF_POSYT: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_top); break;
    2216 [ #  # ][ #  # ]:          0 :         case RTF_POSYB: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_bottom); break;
    2217 [ #  # ][ #  # ]:          0 :         case RTF_POSYC: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_center); break;
    2218 [ #  # ][ #  # ]:          0 :         case RTF_POSYIN: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_inside); break;
    2219 [ #  # ][ #  # ]:          0 :         case RTF_POSYOUT: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_outside); break;
    2220 [ #  # ][ #  # ]:          0 :         case RTF_POSYIL: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, NS_ooxml::LN_Value_wordprocessingml_ST_YAlign_inline); break;
    2221                 :            : 
    2222 [ #  # ][ #  # ]:          0 :         case RTF_PHMRG: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_margin); break;
    2223 [ #  # ][ #  # ]:          0 :         case RTF_PVMRG: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_margin); break;
    2224 [ +  - ][ +  - ]:         12 :         case RTF_PHPG: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_page); break;
    2225 [ +  - ][ +  - ]:         18 :         case RTF_PVPG: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_page); break;
    2226 [ #  # ][ #  # ]:          0 :         case RTF_PHCOL: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_HAnchor_text); break;
    2227 [ #  # ][ #  # ]:          0 :         case RTF_PVPARA: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor, NS_ooxml::LN_Value_wordprocessingml_ST_VAnchor_text); break;
    2228                 :            : 
    2229 [ #  # ][ #  # ]:          0 :         case RTF_POSXC: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_center); break;
    2230 [ #  # ][ #  # ]:          0 :         case RTF_POSXI: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_inside); break;
    2231 [ #  # ][ #  # ]:          0 :         case RTF_POSXO: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_outside); break;
    2232 [ #  # ][ #  # ]:          0 :         case RTF_POSXL: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_left); break;
    2233 [ #  # ][ #  # ]:          0 :         case RTF_POSXR: m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, NS_ooxml::LN_Value_wordprocessingml_ST_XAlign_right); break;
    2234                 :            : 
    2235                 :            :         case RTF_DPLINE:
    2236                 :            :         case RTF_DPRECT:
    2237                 :            :         case RTF_DPELLIPSE:
    2238                 :            :                 {
    2239                 :          3 :                     sal_Int32 nType = 0;
    2240   [ +  -  -  - ]:          3 :                     switch (nKeyword)
    2241                 :            :                     {
    2242                 :            :                         case RTF_DPLINE:
    2243 [ +  - ][ +  - ]:          3 :                             m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.drawing.LineShape"), uno::UNO_QUERY);
         [ +  - ][ +  - ]
                 [ +  - ]
    2244                 :          3 :                             break;
    2245                 :            :                         case RTF_DPRECT:
    2246                 :          0 :                             nType = ESCHER_ShpInst_Rectangle;
    2247                 :          0 :                             break;
    2248                 :            :                         case RTF_DPELLIPSE:
    2249                 :          0 :                             nType = ESCHER_ShpInst_Ellipse;
    2250                 :          0 :                             break;
    2251                 :            :                         default:
    2252                 :          0 :                             break;
    2253                 :            :                     }
    2254         [ -  + ]:          3 :                     if (nType)
    2255 [ #  # ][ #  # ]:          0 :                             m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.drawing.CustomShape"), uno::UNO_QUERY);
         [ #  # ][ #  # ]
                 [ #  # ]
    2256         [ +  - ]:          3 :                     uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier( m_xDstDoc, uno::UNO_QUERY);
    2257         [ +  - ]:          3 :                     if (xDrawSupplier.is())
    2258                 :            :                     {
    2259 [ +  - ][ +  - ]:          3 :                         uno::Reference<drawing::XShapes> xShapes(xDrawSupplier->getDrawPage(), uno::UNO_QUERY);
                 [ +  - ]
    2260         [ +  - ]:          3 :                         if (xShapes.is())
    2261 [ +  - ][ +  - ]:          3 :                             xShapes->add(m_aStates.top().aDrawingObject.xShape);
                 [ +  - ]
    2262                 :            :                     }
    2263         [ -  + ]:          3 :                     if (nType)
    2264                 :            :                     {
    2265 [ #  # ][ #  # ]:          0 :                             uno::Reference<drawing::XEnhancedCustomShapeDefaulter> xDefaulter(m_aStates.top().aDrawingObject.xShape, uno::UNO_QUERY);
    2266 [ #  # ][ #  # ]:          0 :                             xDefaulter->createCustomShapeDefaults(OUString::valueOf(nType));
    2267                 :            :                     }
    2268 [ +  - ][ +  - ]:          3 :                     m_aStates.top().aDrawingObject.xPropertySet.set(m_aStates.top().aDrawingObject.xShape, uno::UNO_QUERY);
                 [ +  - ]
    2269         [ +  - ]:          3 :                     std::vector<beans::PropertyValue>& rPendingProperties = m_aStates.top().aDrawingObject.aPendingProperties;
    2270 [ +  - ][ +  + ]:          9 :                     for (std::vector<beans::PropertyValue>::iterator i = rPendingProperties.begin(); i != rPendingProperties.end(); ++i)
    2271 [ +  - ][ +  - ]:          9 :                         m_aStates.top().aDrawingObject.xPropertySet->setPropertyValue(i->Name, i->Value);
                 [ +  - ]
    2272                 :            :                 }
    2273                 :          3 :                 break;
    2274                 :            :         case RTF_DOBXMARGIN:
    2275                 :            :         case RTF_DOBYMARGIN:
    2276                 :            :                 {
    2277                 :          3 :                     beans::PropertyValue aPropertyValue;
    2278 [ -  + ][ +  - ]:          3 :                     aPropertyValue.Name = (nKeyword == RTF_DOBXMARGIN ? OUString("HoriOrientRelation") : OUString("VertOrientRelation"));
                 [ +  - ]
    2279         [ +  - ]:          3 :                     aPropertyValue.Value <<= text::RelOrientation::PAGE_PRINT_AREA;
    2280 [ +  - ][ +  - ]:          3 :                     m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
    2281                 :            :                 }
    2282                 :          3 :                 break;
    2283                 :            :         case RTF_DOBXPAGE:
    2284                 :            :         case RTF_DOBYPAGE:
    2285                 :            :                 {
    2286                 :          3 :                     beans::PropertyValue aPropertyValue;
    2287 [ +  - ][ -  + ]:          3 :                     aPropertyValue.Name = (nKeyword == RTF_DOBXPAGE ? OUString("HoriOrientRelation") : OUString("VertOrientRelation"));
                 [ -  + ]
    2288         [ +  - ]:          3 :                     aPropertyValue.Value <<= text::RelOrientation::PAGE_FRAME;
    2289 [ +  - ][ +  - ]:          3 :                     m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
    2290                 :            :                 }
    2291                 :          3 :                 break;
    2292                 :            :         case RTF_CONTEXTUALSPACE:
    2293                 :            :                 {
    2294 [ +  - ][ +  - ]:          6 :                     RTFValue::Pointer_t pValue(new RTFValue(1));
                 [ +  - ]
    2295 [ +  - ][ +  - ]:          6 :                     m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PContextualSpacing, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2296                 :            :                 }
    2297                 :          6 :                 break;
    2298                 :            :         case RTF_LINKSTYLES:
    2299                 :            :                 {
    2300 [ +  - ][ +  - ]:          3 :                     RTFValue::Pointer_t pValue(new RTFValue(1));
                 [ +  - ]
    2301 [ +  - ][ +  - ]:          3 :                     m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_linkStyles, pValue);
         [ +  - ][ +  - ]
    2302                 :            :                 }
    2303                 :          3 :                 break;
    2304                 :            :         case RTF_PNLVLBODY:
    2305                 :            :                 {
    2306 [ +  - ][ +  - ]:          9 :                     RTFValue::Pointer_t pValue(new RTFValue(2));
                 [ +  - ]
    2307 [ +  - ][ +  - ]:          9 :                     m_aStates.top().aTableAttributes.set(NS_rtf::LN_LSID, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2308                 :            :                 }
    2309                 :          9 :                 break;
    2310                 :            :         case RTF_PNDEC:
    2311                 :            :                 {
    2312 [ +  - ][ +  - ]:          9 :                     RTFValue::Pointer_t pValue(new RTFValue(0)); // decimal, same as \levelnfc0
                 [ +  - ]
    2313 [ +  - ][ +  - ]:          9 :                     m_aStates.top().aTableSprms.set(NS_rtf::LN_NFC, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2314                 :            :                 }
    2315                 :          9 :                 break;
    2316                 :            :         case RTF_PNLVLBLT:
    2317                 :            :                 {
    2318 [ +  - ][ +  - ]:          3 :                     m_aStates.top().aTableAttributes.set(NS_rtf::LN_LSID, RTFValue::Pointer_t(new RTFValue(1)));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2319 [ +  - ][ +  - ]:          3 :                     m_aStates.top().aTableSprms.set(NS_rtf::LN_NFC, RTFValue::Pointer_t(new RTFValue(23))); // bullets, same as \levelnfc23
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2320                 :            :                 }
    2321                 :          3 :                 break;
    2322                 :            :         case RTF_LANDSCAPE:
    2323 [ +  - ][ +  - ]:          6 :                 lcl_putNestedAttribute(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_orient, RTFValue::Pointer_t(new RTFValue(1)));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2324                 :          6 :                 break;
    2325                 :            :         case RTF_FACINGP:
    2326 [ +  - ][ +  - ]:          6 :                 m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_evenAndOddHeaders, RTFValue::Pointer_t(new RTFValue(1)));
         [ +  - ][ +  - ]
                 [ +  - ]
    2327                 :          6 :                 break;
    2328                 :            :         case RTF_SHPBXPAGE:
    2329         [ +  - ]:         15 :                 m_aStates.top().aShape.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME;
    2330                 :         15 :                 break;
    2331                 :            :         case RTF_SHPBYPAGE:
    2332         [ +  - ]:         15 :                 m_aStates.top().aShape.nVertOrientRelation = text::RelOrientation::PAGE_FRAME;
    2333                 :         15 :                 break;
    2334                 :            :         default:
    2335                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle flag '" << lcl_RtfToString(nKeyword) << "'");
    2336         [ +  - ]:       2103 :             aSkip.setParsed(false);
    2337                 :       2103 :             break;
    2338                 :            :     }
    2339         [ +  - ]:      23991 :     return 0;
    2340                 :            : }
    2341                 :            : 
    2342                 :      39879 : int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
    2343                 :            : {
    2344         [ +  - ]:      39879 :     checkUnicode(nKeyword != RTF_U, true);
    2345         [ +  - ]:      39879 :     RTFSkipDestination aSkip(*this);
    2346                 :      39879 :     int nSprm = 0;
    2347 [ +  - ][ +  - ]:      39879 :     RTFValue::Pointer_t pIntValue(new RTFValue(nParam));
                 [ +  - ]
    2348                 :            :     // Trivial table sprms.
    2349   [ +  +  +  +  :      39879 :     switch (nKeyword)
                      + ]
    2350                 :            :     {
    2351                 :       1290 :         case RTF_FPRQ: nSprm = NS_rtf::LN_PRQ; break;
    2352                 :         18 :         case RTF_LEVELJC: nSprm = NS_ooxml::LN_CT_Lvl_lvlJc; break;
    2353                 :         30 :         case RTF_LEVELNFC: nSprm = NS_rtf::LN_NFC; break;
    2354                 :         30 :         case RTF_LEVELSTARTAT: nSprm = NS_rtf::LN_ISTARTAT; break;
    2355                 :      38511 :         default: break;
    2356                 :            :     }
    2357         [ +  + ]:      39879 :     if (nSprm > 0)
    2358                 :            :     {
    2359 [ +  - ][ +  - ]:       1368 :         m_aStates.top().aTableSprms.set(nSprm, pIntValue);
         [ +  - ][ +  - ]
    2360                 :       1368 :         return 0;
    2361                 :            :     }
    2362                 :            :     // Trivial character sprms.
    2363   [ +  +  +  -  :      38511 :     switch (nKeyword)
          -  +  -  +  +  
                   +  + ]
    2364                 :            :     {
    2365 [ +  - ][ +  + ]:       8355 :         case RTF_AF: nSprm = (m_aStates.top().bIsCjk ? NS_sprm::LN_CRgFtc1 : NS_sprm::LN_CRgFtc2); break;
    2366                 :        801 :         case RTF_FS: nSprm = NS_sprm::LN_CHps; break;
    2367                 :        654 :         case RTF_AFS: nSprm = NS_sprm::LN_CHpsBi; break;
    2368                 :          0 :         case RTF_ANIMTEXT: nSprm = NS_sprm::LN_CSfxText; break;
    2369                 :          0 :         case RTF_EXPNDTW: nSprm = NS_sprm::LN_CDxaSpace; break;
    2370                 :        318 :         case RTF_KERNING: nSprm = NS_sprm::LN_CHpsKern; break;
    2371                 :          0 :         case RTF_CHARSCALEX: nSprm = NS_sprm::LN_CCharScale; break;
    2372                 :        624 :         case RTF_LANG: nSprm = NS_sprm::LN_CRgLid0; break;
    2373                 :        582 :         case RTF_LANGFE: nSprm = NS_sprm::LN_CRgLid1; break;
    2374                 :        468 :         case RTF_ALANG: nSprm = NS_sprm::LN_CLidBi; break;
    2375                 :      26709 :         default: break;
    2376                 :            :     }
    2377         [ +  + ]:      38511 :     if (nSprm > 0)
    2378                 :            :     {
    2379 [ +  - ][ +  - ]:      11802 :         m_aStates.top().aCharacterSprms.set(nSprm, pIntValue);
         [ +  - ][ +  - ]
    2380                 :            :         // Language is a character property, but we should store it at a paragraph level as well for fields.
    2381 [ +  + ][ +  + ]:      11802 :         if (nKeyword == RTF_LANG && m_bNeedPap)
    2382 [ +  - ][ +  - ]:        618 :             m_aStates.top().aParagraphSprms.set(nSprm, pIntValue);
         [ +  - ][ +  - ]
    2383                 :      11802 :         return 0;
    2384                 :            :     }
    2385                 :            :     // Trivial paragraph sprms.
    2386   [ +  +  +  +  :      26709 :     switch (nKeyword)
                   +  + ]
    2387                 :            :     {
    2388                 :        282 :         case RTF_FI: nSprm = NS_sprm::LN_PDxaLeft1; break;
    2389                 :        258 :         case RTF_LIN: nSprm = 0x845e; break;
    2390                 :        246 :         case RTF_RI: nSprm = NS_sprm::LN_PDxaRight; break;
    2391                 :        243 :         case RTF_RIN: nSprm = 0x845d; break;
    2392                 :         84 :         case RTF_ITAP: nSprm = NS_sprm::LN_PTableDepth; break;
    2393                 :      25596 :         default: break;
    2394                 :            :     }
    2395         [ +  + ]:      26709 :     if (nSprm > 0)
    2396                 :            :     {
    2397 [ +  - ][ +  - ]:       1113 :         m_aStates.top().aParagraphSprms.set(nSprm, pIntValue);
         [ +  - ][ +  - ]
    2398 [ +  + ][ -  + ]:       1113 :         if (nKeyword == RTF_ITAP && nParam > 0)
    2399                 :            :             // Invalid tables may omit INTBL after ITAP
    2400         [ #  # ]:          0 :             dispatchFlag(RTF_INTBL);
    2401                 :       1113 :         return 0;
    2402                 :            :     }
    2403                 :            : 
    2404                 :            :     // Trivial table attributes.
    2405      [ +  +  + ]:      25596 :     switch (nKeyword)
    2406                 :            :     {
    2407                 :        549 :         case RTF_SBASEDON: nSprm = NS_rtf::LN_ISTDBASE; break;
    2408                 :        594 :         case RTF_SNEXT: nSprm = NS_rtf::LN_ISTDNEXT; break;
    2409                 :      24453 :         default: break;
    2410                 :            :     }
    2411         [ +  + ]:      25596 :     if (nSprm > 0)
    2412                 :            :     {
    2413 [ +  - ][ +  - ]:       1143 :         m_aStates.top().aTableAttributes.set(nSprm, pIntValue);
         [ +  - ][ +  - ]
    2414                 :       1143 :         return 0;
    2415                 :            :     }
    2416                 :            : 
    2417                 :            :     // Info group.
    2418   [ +  +  +  +  :      24453 :     switch (nKeyword)
                   +  + ]
    2419                 :            :     {
    2420         [ +  - ]:        255 :         case RTF_YR: m_aStates.top().nYear = nParam; nSprm = 1; break;
    2421         [ +  - ]:        255 :         case RTF_MO: m_aStates.top().nMonth = nParam; nSprm = 1; break;
    2422         [ +  - ]:        255 :         case RTF_DY: m_aStates.top().nDay = nParam; nSprm = 1; break;
    2423         [ +  - ]:        255 :         case RTF_HR: m_aStates.top().nHour = nParam; nSprm = 1; break;
    2424         [ +  - ]:        255 :         case RTF_MIN: m_aStates.top().nMinute = nParam; nSprm = 1; break;
    2425                 :      23178 :         default: break;
    2426                 :            :     }
    2427         [ +  + ]:      24453 :     if (nSprm > 0)
    2428                 :       1275 :         return 0;
    2429                 :            : 
    2430                 :            :     // Frame size / position.
    2431                 :      23178 :     Id nId = 0;
    2432   [ +  +  +  +  :      23178 :     switch (nKeyword)
                      + ]
    2433                 :            :     {
    2434                 :         18 :         case RTF_ABSW: nId = NS_sprm::LN_PDxaWidth; break;
    2435                 :         18 :         case RTF_ABSH: nId = NS_sprm::LN_PWHeightAbs; break;
    2436 [ +  - ][ +  - ]:         18 :         case RTF_POSX: nId = NS_ooxml::LN_CT_FramePr_x; m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, 0); break;
    2437 [ +  - ][ +  - ]:         18 :         case RTF_POSY: nId = NS_ooxml::LN_CT_FramePr_y; m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, 0); break;
    2438                 :      23106 :         default: break;
    2439                 :            :     }
    2440         [ +  + ]:      23178 :     if (nId > 0)
    2441                 :            :     {
    2442                 :         72 :         m_bNeedPap = true;
    2443                 :            :         // Don't try to support text frames inside tables for now.
    2444         [ +  - ]:         72 :         if (m_pCurrentBuffer != &m_aTableBuffer)
    2445 [ +  - ][ +  - ]:         72 :             m_aStates.top().aFrame.setSprm(nId, nParam);
    2446                 :         72 :         return 0;
    2447                 :            :     }
    2448                 :            : 
    2449                 :            :     // Then check for the more complex ones.
    2450   [ +  +  +  +  :      23106 :     switch (nKeyword)
          +  +  +  +  +  
          +  +  +  +  +  
          -  +  -  -  +  
          -  -  -  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          -  +  -  -  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  -  
          +  -  -  -  +  
          +  +  +  -  -  
          -  +  +  +  +  
          +  +  -  -  -  
          -  -  -  -  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  -  -  -  
                +  -  + ]
    2451                 :            :     {
    2452                 :            :         case RTF_F:
    2453 [ +  - ][ +  + ]:       4203 :             if (m_aStates.top().nDestinationState == DESTINATION_FONTTABLE || m_aStates.top().nDestinationState == DESTINATION_FONTENTRY)
         [ +  - ][ +  + ]
                 [ +  + ]
    2454                 :            :             {
    2455         [ +  - ]:       1326 :                 m_aFontIndexes.push_back(nParam);
    2456         [ +  - ]:       1326 :                 m_nCurrentFontIndex = getFontIndex(nParam);
    2457                 :            :             }
    2458                 :            :             else
    2459                 :            :             {
    2460         [ +  - ]:       2877 :                 int nFontIndex = getFontIndex(nParam);
    2461 [ +  - ][ +  - ]:       2877 :                 RTFValue::Pointer_t pValue(new RTFValue(nFontIndex));
                 [ +  - ]
    2462 [ +  - ][ +  - ]:       2877 :                 m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CRgFtc0, pValue);
         [ +  - ][ +  - ]
    2463 [ +  - ][ +  - ]:       2877 :                 m_aStates.top().nCurrentEncoding = getEncoding(nFontIndex);
                 [ +  - ]
    2464                 :            :             }
    2465                 :       4203 :             break;
    2466                 :            :         case RTF_RED:
    2467         [ +  - ]:        336 :             m_aStates.top().aCurrentColor.nRed = nParam;
    2468                 :        336 :             break;
    2469                 :            :         case RTF_GREEN:
    2470         [ +  - ]:        336 :             m_aStates.top().aCurrentColor.nGreen = nParam;
    2471                 :        336 :             break;
    2472                 :            :         case RTF_BLUE:
    2473         [ +  - ]:        336 :             m_aStates.top().aCurrentColor.nBlue = nParam;
    2474                 :        336 :             break;
    2475                 :            :         case RTF_FCHARSET:
    2476                 :            :             {
    2477                 :            :                 // we always send text to the domain mapper in OUString, so no
    2478                 :            :                 // need to send encoding info
    2479                 :            :                 int i;
    2480         [ +  - ]:      12390 :                 for (i = 0; i < nRTFEncodings; i++)
    2481                 :            :                 {
    2482         [ +  + ]:      12390 :                     if (aRTFEncodings[i].charset == nParam)
    2483                 :       1311 :                         break;
    2484                 :            :                 }
    2485         [ -  + ]:       1311 :                 if (i == nRTFEncodings)
    2486                 :            :                     // not found
    2487                 :          0 :                     return 0;
    2488 [ +  - ][ +  - ]:       1311 :                 m_aFontEncodings[m_nCurrentFontIndex] = rtl_getTextEncodingFromWindowsCodePage(aRTFEncodings[i].codepage);
    2489                 :            :             }
    2490                 :       1311 :             break;
    2491                 :            :         case RTF_ANSICPG:
    2492 [ +  - ][ +  - ]:         27 :             m_aStates.top().nCurrentEncoding = rtl_getTextEncodingFromWindowsCodePage(nParam);
    2493                 :         27 :             break;
    2494                 :            :         case RTF_CPG:
    2495 [ +  - ][ +  - ]:          3 :             m_aFontEncodings[m_nCurrentFontIndex] = rtl_getTextEncodingFromWindowsCodePage(nParam);
    2496                 :          3 :             break;
    2497                 :            :         case RTF_CF:
    2498                 :            :             {
    2499                 :            :                 // NS_sprm::LN_CIco won't work, that would be an index in a static table
    2500 [ +  - ][ +  - ]:        351 :                 RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam)));
         [ +  - ][ +  - ]
    2501 [ +  - ][ +  - ]:        351 :                 m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_Color_val, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2502                 :            :             }
    2503                 :        351 :             break;
    2504                 :            :         case RTF_S:
    2505 [ +  - ][ +  - ]:        984 :             if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET || m_aStates.top().nDestinationState == DESTINATION_STYLEENTRY)
         [ +  - ][ +  + ]
                 [ +  + ]
    2506                 :            :             {
    2507                 :        705 :                 m_nCurrentStyleIndex = nParam;
    2508 [ +  - ][ +  - ]:        705 :                 m_aStates.top().aTableAttributes.set(NS_rtf::LN_ISTD, pIntValue);
         [ +  - ][ +  - ]
    2509 [ +  - ][ +  - ]:        705 :                 RTFValue::Pointer_t pValue(new RTFValue(1));
                 [ +  - ]
    2510 [ +  - ][ +  - ]:        705 :                 m_aStates.top().aTableAttributes.set(NS_rtf::LN_SGC, pValue); // paragraph style
         [ +  - ][ +  - ]
                 [ +  - ]
    2511                 :            :             }
    2512                 :            :             else
    2513 [ +  - ][ +  - ]:        279 :                 m_aStates.top().aParagraphAttributes.set(NS_rtf::LN_ISTD, pIntValue);
         [ +  - ][ +  - ]
    2514                 :        984 :             break;
    2515                 :            :         case RTF_CS:
    2516 [ +  - ][ -  + ]:         39 :             if (m_aStates.top().nDestinationState == DESTINATION_STYLESHEET)
    2517                 :            :             {
    2518                 :          0 :                 m_nCurrentStyleIndex = nParam;
    2519 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aTableAttributes.set(NS_rtf::LN_ISTD, pIntValue);
         [ #  # ][ #  # ]
    2520 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(2));
                 [ #  # ]
    2521 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aTableAttributes.set(NS_rtf::LN_SGC, pValue); // character style
         [ #  # ][ #  # ]
                 [ #  # ]
    2522                 :            :             }
    2523                 :            :             else
    2524 [ +  - ][ +  - ]:         39 :                 m_aStates.top().aCharacterAttributes.set(NS_rtf::LN_ISTD, pIntValue);
         [ +  - ][ +  - ]
    2525                 :         39 :             break;
    2526                 :            :         case RTF_DEFF:
    2527 [ +  - ][ +  - ]:        129 :                 m_aDefaultState.aCharacterSprms.set(NS_sprm::LN_CRgFtc0, pIntValue);
                 [ +  - ]
    2528                 :        129 :             break;
    2529                 :            :         case RTF_DEFLANG:
    2530 [ +  - ][ +  - ]:         15 :                 m_aDefaultState.aCharacterSprms.set(NS_sprm::LN_CRgLid0, pIntValue);
                 [ +  - ]
    2531                 :         15 :             break;
    2532                 :            :         case RTF_ADEFLANG:
    2533 [ +  - ][ +  - ]:         96 :                 m_aDefaultState.aCharacterSprms.set(NS_sprm::LN_CLidBi, pIntValue);
                 [ +  - ]
    2534                 :         96 :             break;
    2535                 :            :         case RTF_CHCBPAT:
    2536         [ -  + ]:          3 :             if (nParam)
    2537                 :            :             {
    2538 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam)));
         [ #  # ][ #  # ]
    2539 [ #  # ][ #  # ]:          0 :                 lcl_putNestedAttribute(m_aStates.top().aCharacterSprms, NS_sprm::LN_CShd, NS_ooxml::LN_CT_Shd_fill, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2540                 :            :             }
    2541                 :          3 :             break;
    2542                 :            :         case RTF_CLCBPAT:
    2543                 :            :             {
    2544 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam)));
         [ #  # ][ #  # ]
    2545         [ #  # ]:          0 :                 lcl_putNestedAttribute(m_aStates.top().aTableCellSprms,
    2546 [ #  # ][ #  # ]:          0 :                         NS_ooxml::LN_CT_TcPrBase_shd, NS_ooxml::LN_CT_Shd_fill, pValue);
         [ #  # ][ #  # ]
    2547                 :            :             }
    2548                 :          0 :             break;
    2549                 :            :         case RTF_CBPAT:
    2550         [ +  + ]:          6 :             if (nParam)
    2551                 :            :             {
    2552 [ +  - ][ +  - ]:          3 :                 RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam)));
         [ +  - ][ +  - ]
    2553 [ +  - ][ +  - ]:          3 :                 lcl_putNestedAttribute(m_aStates.top().aParagraphSprms, NS_sprm::LN_PShd, NS_ooxml::LN_CT_Shd_fill, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2554                 :            :             }
    2555                 :          6 :             break;
    2556                 :            :         case RTF_ULC:
    2557                 :            :             {
    2558 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam)));
         [ #  # ][ #  # ]
    2559 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aCharacterSprms.set(0x6877, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2560                 :            :             }
    2561                 :          0 :             break;
    2562                 :            :         case RTF_HIGHLIGHT:
    2563                 :            :             {
    2564 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ #  # ]
    2565 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CHighlight, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2566                 :            :             }
    2567                 :          0 :             break;
    2568                 :            :         case RTF_UP:
    2569                 :            :         case RTF_DN:
    2570                 :            :             {
    2571 [ +  - ][ +  - ]:          3 :                 RTFValue::Pointer_t pValue(new RTFValue(nParam * (nKeyword == RTF_UP ? 1 : -1)));
         [ +  - ][ +  - ]
    2572 [ +  - ][ +  - ]:          3 :                 m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CHpsPos, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2573                 :            :             }
    2574                 :          3 :             break;
    2575                 :            :         case RTF_HORZVERT:
    2576                 :            :             {
    2577 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(true));
                 [ #  # ]
    2578 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_EastAsianLayout_vert, pValue);
         [ #  # ][ #  # ]
    2579         [ #  # ]:          0 :                 if (nParam)
    2580                 :            :                     // rotate fits to a single line
    2581 [ #  # ][ #  # ]:          0 :                     m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_EastAsianLayout_vertCompress, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2582                 :            :             }
    2583                 :          0 :             break;
    2584                 :            :         case RTF_EXPND:
    2585                 :            :             {
    2586 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(nParam/5));
                 [ #  # ]
    2587 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CDxaSpace, pValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2588                 :            :             }
    2589                 :          0 :             break;
    2590                 :            :         case RTF_TWOINONE:
    2591                 :            :             {
    2592 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(true));
                 [ #  # ]
    2593 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_EastAsianLayout_combine, pValue);
         [ #  # ][ #  # ]
    2594         [ #  # ]:          0 :                 if (nParam > 0)
    2595 [ #  # ][ #  # ]:          0 :                     m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_EastAsianLayout_combineBrackets, pIntValue);
         [ #  # ][ #  # ]
                 [ #  # ]
    2596                 :            :             }
    2597                 :          0 :             break;
    2598                 :            :         case RTF_SL:
    2599                 :            :             {
    2600                 :            :                 // This is similar to RTF_ABSH, negative value means 'exact', positive means 'at least'.
    2601 [ +  - ][ +  - ]:         33 :                 RTFValue::Pointer_t pValue(new RTFValue(NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_atLeast));
                 [ +  - ]
    2602         [ -  + ]:         33 :                 if (nParam < 0)
    2603                 :            :                 {
    2604 [ #  # ][ #  # ]:          0 :                     pValue.reset(new RTFValue(NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_exact));
                 [ #  # ]
    2605 [ #  # ][ #  # ]:          0 :                     pIntValue.reset(new RTFValue(-nParam));
                 [ #  # ]
    2606                 :            :                 }
    2607 [ +  - ][ +  - ]:         33 :                 m_aStates.top().aParagraphAttributes.set(NS_ooxml::LN_CT_Spacing_lineRule, pValue);
         [ +  - ][ +  - ]
    2608 [ +  - ][ +  - ]:         33 :                 m_aStates.top().aParagraphAttributes.set(NS_ooxml::LN_CT_Spacing_line, pIntValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2609                 :            :             }
    2610                 :         33 :             break;
    2611                 :            :         case RTF_SLMULT:
    2612         [ +  - ]:         30 :             if (nParam > 0)
    2613                 :            :             {
    2614 [ +  - ][ +  - ]:         30 :                 RTFValue::Pointer_t pValue(new RTFValue(NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_auto));
                 [ +  - ]
    2615 [ +  - ][ +  - ]:         30 :                 m_aStates.top().aParagraphAttributes.set(NS_ooxml::LN_CT_Spacing_lineRule, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2616                 :            :             }
    2617                 :         30 :             break;
    2618                 :            :         case RTF_BRDRW:
    2619                 :            :             {
    2620                 :            :                 // dmapper expects it in 1/8 pt, we have it in twip - but avoid rounding 1 to 0
    2621         [ +  - ]:        441 :                 if (nParam > 1)
    2622                 :        441 :                     nParam = nParam * 2 / 5;
    2623 [ +  - ][ +  - ]:        441 :                 RTFValue::Pointer_t pValue(new RTFValue(nParam));
                 [ +  - ]
    2624 [ +  - ][ +  - ]:        441 :                 lcl_putBorderProperty(m_aStates, NS_rtf::LN_DPTLINEWIDTH, pValue);
         [ +  - ][ +  - ]
    2625                 :            :             }
    2626                 :        441 :             break;
    2627                 :            :         case RTF_BRDRCF:
    2628                 :            :             {
    2629 [ +  - ][ +  - ]:         48 :                 RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam)));
         [ +  - ][ +  - ]
    2630 [ +  - ][ +  - ]:         48 :                 lcl_putBorderProperty(m_aStates, NS_ooxml::LN_CT_Border_color, pValue);
         [ +  - ][ +  - ]
    2631                 :            :             }
    2632                 :         48 :             break;
    2633                 :            :         case RTF_BRSP:
    2634                 :            :             {
    2635                 :            :                 // dmapper expects it in points, we have it in twip
    2636 [ +  - ][ +  - ]:          3 :                 RTFValue::Pointer_t pValue(new RTFValue(nParam / 20));
                 [ +  - ]
    2637 [ +  - ][ +  - ]:          3 :                 lcl_putBorderProperty(m_aStates, NS_rtf::LN_DPTSPACE, pValue);
         [ +  - ][ +  - ]
    2638                 :            :             }
    2639                 :          3 :             break;
    2640                 :            :         case RTF_TX:
    2641                 :            :             {
    2642 [ +  - ][ +  - ]:        153 :                 m_aStates.top().aTabAttributes.set(NS_ooxml::LN_CT_TabStop_pos, pIntValue);
         [ +  - ][ +  - ]
    2643 [ +  - ][ +  - ]:        153 :                 RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aTabAttributes));
         [ +  - ][ +  - ]
                 [ +  - ]
    2644 [ +  - ][ +  - ]:        153 :                 lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_tabs, NS_ooxml::LN_CT_Tabs_tab, pValue);
         [ +  - ][ +  - ]
    2645 [ +  - ][ +  - ]:        153 :                 m_aStates.top().aTabAttributes.clear();
    2646                 :            :             }
    2647                 :        153 :             break;
    2648                 :            :         case RTF_ILVL:
    2649 [ +  - ][ +  - ]:         18 :             lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_numPr, NS_sprm::LN_PIlvl, pIntValue);
         [ +  - ][ +  - ]
    2650                 :         18 :             break;
    2651                 :            :         case RTF_LISTTEMPLATEID:
    2652                 :            :             // This one is not referenced anywhere, so it's pointless to store it at the moment.
    2653                 :         15 :             break;
    2654                 :            :         case RTF_LISTID:
    2655                 :            :             {
    2656 [ +  - ][ +  + ]:         30 :                 if (m_aStates.top().nDestinationState == DESTINATION_LISTENTRY)
    2657 [ +  - ][ +  - ]:         15 :                     m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_AbstractNum_abstractNumId, pIntValue);
         [ +  - ][ +  - ]
    2658 [ +  - ][ +  - ]:         15 :                 else if (m_aStates.top().nDestinationState == DESTINATION_LISTOVERRIDEENTRY)
    2659 [ +  - ][ +  - ]:         15 :                     m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Num_abstractNumId, pIntValue);
         [ +  - ][ +  - ]
    2660                 :            :             }
    2661                 :         30 :             break;
    2662                 :            :         case RTF_LS:
    2663                 :            :             {
    2664 [ +  - ][ +  + ]:         42 :                 if (m_aStates.top().nDestinationState == DESTINATION_LISTOVERRIDEENTRY)
    2665 [ +  - ][ +  - ]:         15 :                     m_aStates.top().aTableAttributes.set(NS_rtf::LN_LSID, pIntValue);
         [ +  - ][ +  - ]
    2666                 :            :                 else
    2667 [ +  - ][ +  - ]:         27 :                     lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_tabs, NS_sprm::LN_PIlfo, pIntValue);
         [ +  - ][ +  - ]
    2668                 :            :             }
    2669                 :         42 :             break;
    2670                 :            :         case RTF_UC:
    2671 [ +  - ][ +  - ]:         27 :             if ((SAL_MIN_INT16 <= nParam) && (nParam <= SAL_MAX_INT16))
    2672         [ +  - ]:         27 :                 m_aStates.top().nUc = nParam;
    2673                 :         27 :             break;
    2674                 :            :         case RTF_U:
    2675 [ +  - ][ +  - ]:        282 :             if ((SAL_MIN_INT16 <= nParam) && (nParam <= SAL_MAX_INT16))
    2676                 :            :             {
    2677         [ +  - ]:        282 :                 m_aUnicodeBuffer.append(static_cast<sal_Unicode>(nParam));
    2678 [ +  - ][ +  - ]:        282 :                 m_aStates.top().nCharsToSkip = m_aStates.top().nUc;
    2679                 :            :             }
    2680                 :        282 :             break;
    2681                 :            :         case RTF_LEVELFOLLOW:
    2682 [ +  - ][ +  - ]:         30 :             m_aStates.top().aTableAttributes.set(NS_rtf::LN_IXCHFOLLOW, pIntValue);
         [ +  - ][ +  - ]
    2683                 :         30 :             break;
    2684                 :            :         case RTF_LISTOVERRIDECOUNT:
    2685                 :            :             // Ignore this for now, the exporter always emits it with a zero parameter.
    2686                 :         15 :             break;
    2687                 :            :         case RTF_PICSCALEX:
    2688         [ +  - ]:         12 :             m_aStates.top().aPicture.nScaleX = nParam;
    2689                 :         12 :             break;
    2690                 :            :         case RTF_PICSCALEY:
    2691         [ +  - ]:         12 :             m_aStates.top().aPicture.nScaleY = nParam;
    2692                 :         12 :             break;
    2693                 :            :         case RTF_PICW:
    2694         [ +  - ]:         12 :             m_aStates.top().aPicture.nWidth = nParam;
    2695                 :         12 :             break;
    2696                 :            :         case RTF_PICH:
    2697         [ +  - ]:         12 :             m_aStates.top().aPicture.nHeight = nParam;
    2698                 :         12 :             break;
    2699                 :            :         case RTF_PICWGOAL:
    2700 [ +  - ][ +  - ]:         15 :             m_aStates.top().aPicture.nGoalWidth = TWIP_TO_MM100(nParam);
    2701                 :         15 :             break;
    2702                 :            :         case RTF_PICHGOAL:
    2703 [ +  - ][ +  - ]:         15 :             m_aStates.top().aPicture.nGoalHeight = TWIP_TO_MM100(nParam);
    2704                 :         15 :             break;
    2705 [ +  - ][ +  - ]:          9 :         case RTF_PICCROPL: m_aStates.top().aPicture.nCropL = TWIP_TO_MM100(nParam); break;
    2706 [ +  - ][ +  - ]:          9 :         case RTF_PICCROPR: m_aStates.top().aPicture.nCropR = TWIP_TO_MM100(nParam); break;
    2707 [ +  - ][ +  - ]:          9 :         case RTF_PICCROPT: m_aStates.top().aPicture.nCropT = TWIP_TO_MM100(nParam); break;
    2708 [ +  - ][ +  - ]:          9 :         case RTF_PICCROPB: m_aStates.top().aPicture.nCropB = TWIP_TO_MM100(nParam); break;
    2709                 :            :         case RTF_SHPWRK:
    2710                 :            :             {
    2711                 :         24 :                 int nValue = 0;
    2712   [ +  -  -  -  :         24 :                 switch (nParam)
                      - ]
    2713                 :            :                 {
    2714                 :         24 :                     case 0: nValue = NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_bothSides; break;
    2715                 :          0 :                     case 1: nValue = NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_left; break;
    2716                 :          0 :                     case 2: nValue = NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_right; break;
    2717                 :          0 :                     case 3: nValue = NS_ooxml::LN_Value_wordprocessingDrawing_ST_WrapText_largest; break;
    2718                 :          0 :                     default: break;
    2719                 :            :                 }
    2720 [ +  - ][ +  - ]:         24 :                 RTFValue::Pointer_t pValue(new RTFValue(nValue));
                 [ +  - ]
    2721 [ +  - ][ +  - ]:         24 :                 m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_WrapSquare_wrapText, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    2722                 :            :             }
    2723                 :         24 :             break;
    2724                 :            :         case RTF_CELLX:
    2725                 :            :             {
    2726         [ +  - ]:        480 :                 int nCellX = nParam - m_aStates.top().nCellX;
    2727         [ +  - ]:        480 :                 m_aStates.top().nCellX = nParam;
    2728 [ +  - ][ +  - ]:        480 :                 RTFValue::Pointer_t pXValue(new RTFValue(nCellX));
                 [ +  - ]
    2729 [ +  - ][ +  - ]:        480 :                 m_aStates.top().aTableRowSprms.set(NS_ooxml::LN_CT_TblGridBase_gridCol, pXValue, false);
         [ +  - ][ +  - ]
    2730         [ +  - ]:        480 :                 m_aStates.top().nCells++;
    2731                 :            : 
    2732                 :            :                 // Push cell properties.
    2733 [ +  - ][ +  - ]:        480 :                 m_aStates.top().aTableCellsSprms.push_back(m_aStates.top().aTableCellSprms);
                 [ +  - ]
    2734 [ +  - ][ +  - ]:        480 :                 m_aStates.top().aTableCellsAttributes.push_back(m_aStates.top().aTableCellAttributes);
                 [ +  - ]
    2735 [ +  - ][ +  - ]:        480 :                 m_aStates.top().aTableCellSprms = m_aDefaultState.aTableCellSprms;
    2736 [ +  - ][ +  - ]:        480 :                 m_aStates.top().aTableCellAttributes = m_aDefaultState.aTableCellAttributes;
    2737                 :            :                 // We assume text after a row definition always belongs to the table, to handle text before the real INTBL token
    2738 [ +  - ][ +  - ]:        480 :                 dispatchFlag(RTF_INTBL);
    2739                 :            :             }
    2740                 :        480 :             break;
    2741                 :            :         case RTF_TRRH:
    2742                 :            :             {
    2743                 :          9 :                 rtl::OUString hRule = rtl::OUString::createFromAscii("auto");
    2744         [ -  + ]:          9 :                 if ( nParam < 0 )
    2745                 :            :                 {
    2746 [ #  # ][ #  # ]:          0 :                     RTFValue::Pointer_t pAbsValue(new RTFValue(-nParam));
                 [ #  # ]
    2747                 :          0 :                     pIntValue.swap( pAbsValue );
    2748                 :            : 
    2749         [ #  # ]:          0 :                     hRule = rtl::OUString::createFromAscii("exact");
    2750                 :            :                 }
    2751         [ +  - ]:          9 :                 else if ( nParam > 0 )
    2752                 :          9 :                     hRule = rtl::OUString::createFromAscii("atLeast");
    2753                 :            : 
    2754         [ +  - ]:          9 :                 lcl_putNestedAttribute(m_aStates.top().aTableRowSprms,
    2755 [ +  - ][ +  - ]:         18 :                         NS_ooxml::LN_CT_TrPrBase_trHeight, NS_ooxml::LN_CT_Height_val, pIntValue);
                 [ +  - ]
    2756                 :            : 
    2757 [ +  - ][ +  - ]:          9 :                 RTFValue::Pointer_t pHRule(new RTFValue(hRule));
                 [ +  - ]
    2758         [ +  - ]:          9 :                 lcl_putNestedAttribute(m_aStates.top().aTableRowSprms,
    2759 [ +  - ][ +  - ]:         18 :                     NS_ooxml::LN_CT_TrPrBase_trHeight, NS_ooxml::LN_CT_Height_hRule, pHRule);
         [ +  - ][ +  - ]
    2760                 :            :             }
    2761                 :          9 :             break;
    2762                 :            :         case RTF_COLS:
    2763         [ #  # ]:          0 :                 lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2764 [ #  # ][ #  # ]:          0 :                         NS_ooxml::LN_EG_SectPrContents_cols, NS_ooxml::LN_CT_Columns_num, pIntValue);
                 [ #  # ]
    2765                 :          0 :             break;
    2766                 :            :         case RTF_COLSX:
    2767         [ +  - ]:         12 :                 lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2768 [ +  - ][ +  - ]:         24 :                         NS_ooxml::LN_EG_SectPrContents_cols, NS_ooxml::LN_CT_Columns_space, pIntValue);
                 [ +  - ]
    2769                 :         12 :             break;
    2770                 :            :         case RTF_COLNO:
    2771         [ #  # ]:          0 :                 lcl_putNestedSprm(m_aStates.top().aSectionSprms,
    2772 [ #  # ][ #  # ]:          0 :                         NS_ooxml::LN_EG_SectPrContents_cols, NS_ooxml::LN_CT_Columns_col, pIntValue);
                 [ #  # ]
    2773                 :          0 :             break;
    2774                 :            :         case RTF_COLW:
    2775                 :            :         case RTF_COLSR:
    2776                 :            :             {
    2777 [ #  # ][ #  # ]:          0 :                 RTFSprms& rAttributes = lcl_getLastAttributes(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_cols);
    2778 [ #  # ][ #  # ]:          0 :                 rAttributes.set((nKeyword == RTF_COLW ? NS_ooxml::LN_CT_Column_w : NS_ooxml::LN_CT_Column_space), pIntValue);
         [ #  # ][ #  # ]
    2779                 :            :             }
    2780                 :          0 :             break;
    2781                 :            :         case RTF_PAPERH: // fall through: set the default + current value
    2782                 :            :             lcl_putNestedAttribute(m_aDefaultState.aSectionSprms,
    2783 [ +  - ][ +  - ]:        111 :                     NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_h, pIntValue, true);
                 [ +  - ]
    2784                 :            :         case RTF_PGHSXN:
    2785         [ +  - ]:        204 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2786 [ +  - ][ +  - ]:        408 :                     NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_h, pIntValue, true);
                 [ +  - ]
    2787                 :        204 :             break;
    2788                 :            :         case RTF_PAPERW: // fall through: set the default + current value
    2789                 :            :             lcl_putNestedAttribute(m_aDefaultState.aSectionSprms,
    2790 [ +  - ][ +  - ]:        111 :                     NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_w, pIntValue, true);
                 [ +  - ]
    2791                 :            :         case RTF_PGWSXN:
    2792         [ +  - ]:        204 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2793 [ +  - ][ +  - ]:        408 :                     NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_w, pIntValue, true);
                 [ +  - ]
    2794                 :        204 :             break;
    2795                 :            :         case RTF_MARGL: // fall through: set the default + current value
    2796                 :            :             lcl_putNestedAttribute(m_aDefaultState.aSectionSprms,
    2797 [ +  - ][ +  - ]:        114 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_left, pIntValue, true);
                 [ +  - ]
    2798                 :            :         case RTF_MARGLSXN:
    2799         [ +  - ]:        210 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2800 [ +  - ][ +  - ]:        420 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_left, pIntValue, true);
                 [ +  - ]
    2801                 :        210 :             break;
    2802                 :            :         case RTF_MARGR: // fall through: set the default + current value
    2803                 :            :             lcl_putNestedAttribute(m_aDefaultState.aSectionSprms,
    2804 [ +  - ][ +  - ]:        114 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_right, pIntValue, true);
                 [ +  - ]
    2805                 :            :         case RTF_MARGRSXN:
    2806         [ +  - ]:        210 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2807 [ +  - ][ +  - ]:        420 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_right, pIntValue, true);
                 [ +  - ]
    2808                 :        210 :             break;
    2809                 :            :         case RTF_MARGT: // fall through: set the default + current value
    2810                 :            :             lcl_putNestedAttribute(m_aDefaultState.aSectionSprms,
    2811 [ +  - ][ +  - ]:        108 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_top, pIntValue, true);
                 [ +  - ]
    2812                 :            :         case RTF_MARGTSXN:
    2813         [ +  - ]:        204 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2814 [ +  - ][ +  - ]:        408 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_top, pIntValue, true);
                 [ +  - ]
    2815                 :        204 :             break;
    2816                 :            :         case RTF_MARGB: // fall through: set the default + current value
    2817                 :            :             lcl_putNestedAttribute(m_aDefaultState.aSectionSprms,
    2818 [ +  - ][ +  - ]:        108 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_bottom, pIntValue, true);
                 [ +  - ]
    2819                 :            :         case RTF_MARGBSXN:
    2820         [ +  - ]:        204 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2821 [ +  - ][ +  - ]:        408 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_bottom, pIntValue, true);
                 [ +  - ]
    2822                 :        204 :             break;
    2823                 :            :         case RTF_HEADERY:
    2824         [ +  - ]:          9 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2825 [ +  - ][ +  - ]:         18 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_header, pIntValue, true);
                 [ +  - ]
    2826                 :          9 :             break;
    2827                 :            :         case RTF_FOOTERY:
    2828         [ +  - ]:          6 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2829 [ +  - ][ +  - ]:         12 :                     NS_ooxml::LN_EG_SectPrContents_pgMar, NS_ooxml::LN_CT_PageMar_footer, pIntValue, true);
                 [ +  - ]
    2830                 :          6 :             break;
    2831                 :            :         case RTF_DEFTAB:
    2832 [ +  - ][ +  - ]:         93 :             m_aSettingsTableSprms.set(NS_ooxml::LN_CT_Settings_defaultTabStop, pIntValue);
                 [ +  - ]
    2833                 :         93 :             break;
    2834                 :            :         case RTF_LINEMOD:
    2835         [ #  # ]:          0 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2836 [ #  # ][ #  # ]:          0 :                     NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_countBy, pIntValue);
                 [ #  # ]
    2837                 :          0 :             break;
    2838                 :            :         case RTF_LINEX:
    2839         [ -  + ]:         15 :             if (nParam)
    2840         [ #  # ]:          0 :                 lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2841 [ #  # ][ #  # ]:          0 :                         NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_distance, pIntValue);
                 [ #  # ]
    2842                 :         15 :             break;
    2843                 :            :         case RTF_LINESTARTS:
    2844         [ #  # ]:          0 :             lcl_putNestedAttribute(m_aStates.top().aSectionSprms,
    2845 [ #  # ][ #  # ]:          0 :                     NS_ooxml::LN_EG_SectPrContents_lnNumType, NS_ooxml::LN_CT_LineNumber_start, pIntValue);
                 [ #  # ]
    2846                 :          0 :             break;
    2847                 :            :         case RTF_REVAUTH:
    2848                 :            :         case RTF_REVAUTHDEL:
    2849                 :            :             {
    2850 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(m_aAuthors[nParam]));
         [ #  # ][ #  # ]
    2851         [ #  # ]:          0 :                 lcl_putNestedAttribute(m_aStates.top().aCharacterSprms,
    2852 [ #  # ][ #  # ]:          0 :                         NS_ooxml::LN_trackchange, NS_ooxml::LN_CT_TrackChange_author, pValue);
         [ #  # ][ #  # ]
    2853                 :            :             }
    2854                 :          0 :             break;
    2855                 :            :         case RTF_REVDTTM:
    2856                 :            :         case RTF_REVDTTMDEL:
    2857                 :            :             {
    2858 [ #  # ][ #  # ]:          0 :                 OUString aStr(OStringToOUString(lcl_DTTM22OString(nParam), m_aStates.top().nCurrentEncoding));
                 [ #  # ]
    2859 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(aStr));
                 [ #  # ]
    2860         [ #  # ]:          0 :                 lcl_putNestedAttribute(m_aStates.top().aCharacterSprms,
    2861 [ #  # ][ #  # ]:          0 :                         NS_ooxml::LN_trackchange, NS_ooxml::LN_CT_TrackChange_date, pValue);
         [ #  # ][ #  # ]
    2862                 :            :             }
    2863                 :          0 :             break;
    2864                 :            :         case RTF_SHPLEFT:
    2865 [ +  - ][ +  - ]:         36 :             m_aStates.top().aShape.nLeft = TWIP_TO_MM100(nParam);
    2866                 :         36 :             break;
    2867                 :            :         case RTF_SHPTOP:
    2868 [ +  - ][ +  + ]:         36 :             m_aStates.top().aShape.nTop = TWIP_TO_MM100(nParam);
    2869                 :         36 :             break;
    2870                 :            :         case RTF_SHPRIGHT:
    2871 [ +  - ][ +  - ]:         36 :             m_aStates.top().aShape.nRight = TWIP_TO_MM100(nParam);
    2872                 :         36 :             break;
    2873                 :            :         case RTF_SHPBOTTOM:
    2874 [ +  - ][ +  - ]:         36 :             m_aStates.top().aShape.nBottom = TWIP_TO_MM100(nParam);
    2875                 :         36 :             break;
    2876                 :            :         case RTF_FFTYPE:
    2877   [ #  #  #  # ]:          0 :             switch (nParam)
    2878                 :            :             {
    2879                 :          0 :                 case 0: m_nFormFieldType = FORMFIELD_TEXT; break;
    2880                 :          0 :                 case 1: m_nFormFieldType = FORMFIELD_CHECKBOX; break;
    2881                 :          0 :                 case 2: m_nFormFieldType = FORMFIELD_LIST; break;
    2882                 :          0 :                 default: m_nFormFieldType = FORMFIELD_NONE; break;
    2883                 :            :             }
    2884                 :          0 :             break;
    2885                 :            :         case RTF_FFDEFRES:
    2886         [ #  # ]:          0 :             if (m_nFormFieldType == FORMFIELD_CHECKBOX)
    2887 [ #  # ][ #  # ]:          0 :                 m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFCheckBox_default, pIntValue);
                 [ #  # ]
    2888         [ #  # ]:          0 :             else if (m_nFormFieldType == FORMFIELD_LIST)
    2889 [ #  # ][ #  # ]:          0 :                 m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFDDList_default, pIntValue);
                 [ #  # ]
    2890                 :          0 :             break;
    2891                 :            :         case RTF_FFRES:
    2892         [ #  # ]:          0 :             if (m_nFormFieldType == FORMFIELD_CHECKBOX)
    2893 [ #  # ][ #  # ]:          0 :                 m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFCheckBox_checked, pIntValue);
                 [ #  # ]
    2894         [ #  # ]:          0 :             else if (m_nFormFieldType == FORMFIELD_LIST)
    2895 [ #  # ][ #  # ]:          0 :                 m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFDDList_result, pIntValue);
                 [ #  # ]
    2896                 :          0 :             break;
    2897                 :            :         case RTF_EDMINS:
    2898         [ +  + ]:          9 :             if (m_xDocumentProperties.is())
    2899 [ +  - ][ +  - ]:          3 :                 m_xDocumentProperties->setEditingDuration(nParam);
    2900                 :          9 :             break;
    2901                 :            :         case RTF_NOFPAGES:
    2902                 :            :         case RTF_NOFWORDS:
    2903                 :            :         case RTF_NOFCHARS:
    2904                 :            :         case RTF_NOFCHARSWS:
    2905         [ +  + ]:         36 :             if (m_xDocumentProperties.is())
    2906                 :            :             {
    2907 [ +  - ][ +  - ]:         12 :                 uno::Sequence<beans::NamedValue> aSet = m_xDocumentProperties->getDocumentStatistics();
    2908                 :         12 :                 OUString aName;
    2909   [ +  +  +  +  :         12 :                 switch (nKeyword)
                      - ]
    2910                 :            :                 {
    2911                 :          3 :                     case RTF_NOFPAGES: aName = "PageCount"; nParam = 99; break;
    2912                 :          3 :                     case RTF_NOFWORDS: aName = "WordCount"; break;
    2913                 :          3 :                     case RTF_NOFCHARS: aName = "CharacterCount"; break;
    2914                 :          3 :                     case RTF_NOFCHARSWS: aName = "NonWhitespaceCharacterCount"; break;
    2915                 :          0 :                     default: break;
    2916                 :            :                 }
    2917         [ +  - ]:         12 :                 if (!aName.isEmpty())
    2918                 :            :                 {
    2919                 :         12 :                     bool bFound = false;
    2920                 :         12 :                     int nLen = aSet.getLength();
    2921         [ +  + ]:         30 :                     for (int i = 0; i < nLen; ++i)
    2922 [ +  - ][ -  + ]:         18 :                         if (aSet[i].Name.equals(aName))
    2923 [ #  # ][ #  # ]:          0 :                             aSet[i].Value = uno::makeAny(sal_Int32(nParam));
    2924         [ +  - ]:         12 :                     if (!bFound)
    2925                 :            :                     {
    2926         [ +  - ]:         12 :                         aSet.realloc(nLen + 1);
    2927         [ +  - ]:         12 :                         aSet[nLen].Name = aName;
    2928 [ +  - ][ +  - ]:         12 :                         aSet[nLen].Value = uno::makeAny(sal_Int32(nParam));
    2929                 :            :                     }
    2930 [ +  - ][ +  - ]:         12 :                     m_xDocumentProperties->setDocumentStatistics(aSet);
    2931         [ +  - ]:         12 :                 }
    2932                 :            :             }
    2933                 :         36 :             break;
    2934                 :            :         case RTF_VERSION:
    2935         [ +  + ]:          9 :             if (m_xDocumentProperties.is())
    2936 [ +  - ][ +  - ]:          3 :                 m_xDocumentProperties->setEditingCycles(nParam);
    2937                 :          9 :             break;
    2938                 :            :         case RTF_VERN:
    2939                 :            :             // Ignore this for now, later the RTF writer version could be used to add hacks for older buggy writers.
    2940                 :         93 :             break;
    2941                 :            :         case RTF_FTNSTART:
    2942 [ +  - ][ +  - ]:         96 :             lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_footnotePr, NS_ooxml::LN_EG_FtnEdnNumProps_numStart, pIntValue);
                 [ +  - ]
    2943                 :         96 :             break;
    2944                 :            :         case RTF_AFTNSTART:
    2945 [ +  - ][ +  - ]:         90 :             lcl_putNestedSprm(m_aDefaultState.aParagraphSprms, NS_ooxml::LN_EG_SectPrContents_endnotePr, NS_ooxml::LN_EG_FtnEdnNumProps_numStart, pIntValue);
                 [ +  - ]
    2946                 :         90 :             break;
    2947                 :            :         case RTF_DFRMTXTX:
    2948 [ #  # ][ #  # ]:          0 :             m_aStates.top().aFrame.setSprm(NS_sprm::LN_PDxaFromText, nParam);
    2949                 :          0 :             break;
    2950                 :            :         case RTF_DFRMTXTY:
    2951 [ #  # ][ #  # ]:          0 :             m_aStates.top().aFrame.setSprm(NS_sprm::LN_PDyaFromText, nParam);
    2952                 :          0 :             break;
    2953                 :            :         case RTF_DXFRTEXT:
    2954 [ #  # ][ #  # ]:          0 :             m_aStates.top().aFrame.setSprm(NS_sprm::LN_PDxaFromText, nParam);
    2955 [ #  # ][ #  # ]:          0 :             m_aStates.top().aFrame.setSprm(NS_sprm::LN_PDyaFromText, nParam);
    2956                 :          0 :             break;
    2957                 :            :         case RTF_FLYVERT:
    2958                 :            :             {
    2959                 :          0 :                 RTFVertOrient aVertOrient(nParam);
    2960 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_yAlign, aVertOrient.GetAlign());
    2961 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_vAnchor, aVertOrient.GetAnchor());
    2962                 :            :             }
    2963                 :          0 :             break;
    2964                 :            :         case RTF_FLYHORZ:
    2965                 :            :             {
    2966                 :          0 :                 RTFHoriOrient aHoriOrient(nParam);
    2967 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_xAlign, aHoriOrient.GetAlign());
    2968 [ #  # ][ #  # ]:          0 :                 m_aStates.top().aFrame.setSprm(NS_ooxml::LN_CT_FramePr_hAnchor, aHoriOrient.GetAnchor());
    2969                 :            :             }
    2970                 :          0 :             break;
    2971                 :            :         case RTF_FLYANCHOR:
    2972         [ #  # ]:          0 :             m_aStates.top().aFrame.nAnchorType = nParam;
    2973                 :          0 :             break;
    2974                 :            :         case RTF_WMETAFILE:
    2975         [ #  # ]:          0 :             m_aStates.top().aPicture.eWMetafile = nParam;
    2976                 :          0 :             break;
    2977                 :            :         case RTF_SB:
    2978         [ +  - ]:        435 :             lcl_putNestedAttribute(m_aStates.top().aParagraphSprms,
    2979 [ +  - ][ +  - ]:        870 :                     NS_ooxml::LN_CT_PPrBase_spacing, NS_ooxml::LN_CT_Spacing_before, pIntValue, true);
                 [ +  - ]
    2980                 :        435 :             break;
    2981                 :            :         case RTF_SA:
    2982         [ +  - ]:        453 :             lcl_putNestedAttribute(m_aStates.top().aParagraphSprms,
    2983 [ +  - ][ +  - ]:        906 :                     NS_ooxml::LN_CT_PPrBase_spacing, NS_ooxml::LN_CT_Spacing_after, pIntValue, true);
                 [ +  - ]
    2984                 :        453 :             break;
    2985                 :            :         case RTF_DPX:
    2986 [ +  - ][ +  - ]:          3 :             m_aStates.top().aDrawingObject.nLeft = TWIP_TO_MM100(nParam);
    2987                 :          3 :             break;
    2988                 :            :         case RTF_DPY:
    2989 [ +  - ][ +  - ]:          3 :             m_aStates.top().aDrawingObject.nTop = TWIP_TO_MM100(nParam);
    2990                 :          3 :             break;
    2991                 :            :         case RTF_DPXSIZE:
    2992 [ +  - ][ +  - ]:          3 :             m_aStates.top().aDrawingObject.nRight = TWIP_TO_MM100(nParam);
    2993                 :          3 :             break;
    2994                 :            :         case RTF_DPYSIZE:
    2995 [ +  - ][ +  - ]:          3 :             m_aStates.top().aDrawingObject.nBottom = TWIP_TO_MM100(nParam);
    2996                 :          3 :             break;
    2997                 :            :         case RTF_PNSTART:
    2998 [ +  - ][ +  - ]:         12 :             m_aStates.top().aTableSprms.set(NS_rtf::LN_ISTARTAT, pIntValue);
         [ +  - ][ +  - ]
    2999                 :         12 :             break;
    3000                 :            :         case RTF_PNF:
    3001                 :            :             {
    3002         [ +  - ]:          3 :                 int nFontIndex = getFontIndex(nParam);
    3003 [ +  - ][ +  - ]:          3 :                 RTFValue::Pointer_t pValue(new RTFValue(nFontIndex));
                 [ +  - ]
    3004 [ +  - ][ +  - ]:          3 :                 lcl_putNestedSprm(m_aStates.top().aTableSprms, NS_ooxml::LN_CT_Lvl_rPr, NS_sprm::LN_CRgFtc0, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    3005                 :            :             }
    3006                 :          3 :             break;
    3007                 :            :         case RTF_VIEWSCALE:
    3008 [ +  - ][ +  - ]:         99 :             m_aSettingsTableAttributes.set(NS_ooxml::LN_CT_Zoom_percent, pIntValue);
                 [ +  - ]
    3009                 :         99 :             break;
    3010                 :            :         case RTF_BIN:
    3011         [ +  - ]:          3 :             m_aStates.top().nInternalState = INTERNAL_BIN;
    3012         [ +  - ]:          3 :             m_aStates.top().nBinaryToRead = nParam;
    3013                 :          3 :             break;
    3014                 :            :         case RTF_DPLINECOR:
    3015 [ +  - ][ +  - ]:          3 :             m_aStates.top().aDrawingObject.nLineColorR = nParam; m_aStates.top().aDrawingObject.bHasLineColor = true;
    3016                 :          3 :             break;
    3017                 :            :         case RTF_DPLINECOG:
    3018 [ +  - ][ +  - ]:          3 :             m_aStates.top().aDrawingObject.nLineColorG = nParam; m_aStates.top().aDrawingObject.bHasLineColor = true;
    3019                 :          3 :             break;
    3020                 :            :         case RTF_DPLINECOB:
    3021 [ +  - ][ +  - ]:          3 :             m_aStates.top().aDrawingObject.nLineColorB = nParam; m_aStates.top().aDrawingObject.bHasLineColor = true;
    3022                 :          3 :             break;
    3023                 :            :         case RTF_DPFILLBGCR:
    3024 [ #  # ][ #  # ]:          0 :             m_aStates.top().aDrawingObject.nFillColorR = nParam; m_aStates.top().aDrawingObject.bHasFillColor = true;
    3025                 :          0 :             break;
    3026                 :            :         case RTF_DPFILLBGCG:
    3027 [ #  # ][ #  # ]:          0 :             m_aStates.top().aDrawingObject.nFillColorG = nParam; m_aStates.top().aDrawingObject.bHasFillColor = true;
    3028                 :          0 :             break;
    3029                 :            :         case RTF_DPFILLBGCB:
    3030 [ #  # ][ #  # ]:          0 :             m_aStates.top().aDrawingObject.nFillColorB = nParam; m_aStates.top().aDrawingObject.bHasFillColor = true;
    3031                 :          0 :             break;
    3032                 :            :         case RTF_LI:
    3033 [ +  - ][ +  - ]:        420 :             m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PDxaLeft, pIntValue);
         [ +  - ][ +  - ]
    3034                 :            :             // It turns out \li should reset the \fi inherited from the stylesheet.
    3035                 :            :             // So set the direct formatting to zero, if we don't have such direct formatting yet.
    3036 [ +  - ][ +  - ]:        420 :             if (!m_aStates.top().aParagraphSprms.find(NS_sprm::LN_PDxaLeft1).get())
         [ +  - ][ +  + ]
    3037 [ +  - ][ +  - ]:        243 :                 m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PDxaLeft1, RTFValue::Pointer_t(new RTFValue(0)));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    3038                 :        420 :             break;
    3039                 :            :         case RTF_CLSHDNG:
    3040                 :            :             {
    3041                 :          0 :                 int nValue = -1;
    3042   [ #  #  #  #  :          0 :                 switch (nParam)
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    3043                 :            :                 {
    3044                 :          0 :                     case 500: nValue = 2; break;
    3045                 :          0 :                     case 1000: nValue = 3; break;
    3046                 :          0 :                     case 1200: nValue = 27; break;
    3047                 :          0 :                     case 1500: nValue = 28; break;
    3048                 :          0 :                     case 2000: nValue = 4; break;
    3049                 :          0 :                     case 2500: nValue = 5; break;
    3050                 :          0 :                     case 3000: nValue = 6; break;
    3051                 :          0 :                     case 3500: nValue = 43; break;
    3052                 :          0 :                     case 3700: nValue = 44; break;
    3053                 :          0 :                     case 4000: nValue = 7; break;
    3054                 :          0 :                     case 4500: nValue = 46; break;
    3055                 :          0 :                     case 5000: nValue = 8; break;
    3056                 :          0 :                     case 5500: nValue = 49; break;
    3057                 :          0 :                     case 6000: nValue = 9; break;
    3058                 :          0 :                     case 6200: nValue = 51; break;
    3059                 :          0 :                     case 6500: nValue = 52; break;
    3060                 :          0 :                     case 7000: nValue = 10; break;
    3061                 :          0 :                     case 7500: nValue = 11; break;
    3062                 :          0 :                     case 8000: nValue = 12; break;
    3063                 :          0 :                     case 8500: nValue = 57; break;
    3064                 :          0 :                     case 8700: nValue = 58; break;
    3065                 :          0 :                     case 9000: nValue = 13; break;
    3066                 :          0 :                     case 9500: nValue = 60; break;
    3067                 :          0 :                     default: break;
    3068                 :            :                 }
    3069         [ #  # ]:          0 :                 if (nValue != -1)
    3070 [ #  # ][ #  # ]:          0 :                     lcl_putNestedAttribute(m_aStates.top().aTableCellSprms, NS_ooxml::LN_CT_TcPrBase_shd, NS_ooxml::LN_CT_Shd_val, RTFValue::Pointer_t(new RTFValue(nValue)));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3071                 :            :             }
    3072                 :          0 :             break;
    3073                 :            :         default:
    3074                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle value '" << lcl_RtfToString(nKeyword) << "'");
    3075         [ +  - ]:       9840 :             aSkip.setParsed(false);
    3076                 :       9840 :             break;
    3077                 :            :     }
    3078 [ +  - ][ +  - ]:      39879 :     return 0;
    3079                 :            : }
    3080                 :            : 
    3081                 :       1299 : int RTFDocumentImpl::dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam)
    3082                 :            : {
    3083         [ +  - ]:       1299 :     checkUnicode();
    3084         [ +  - ]:       1299 :     RTFSkipDestination aSkip(*this);
    3085                 :       1299 :     int nSprm = -1;
    3086 [ +  - ][ +  + ]:       1299 :     RTFValue::Pointer_t pBoolValue(new RTFValue(!bParam || nParam != 0));
         [ +  + ][ +  - ]
                 [ +  - ]
    3087                 :            : 
    3088                 :            :     // Map all underline toggles to a single sprm.
    3089   [ +  -  -  -  :       1299 :     switch (nKeyword)
          -  -  -  -  -  
          -  -  -  -  -  
                   -  + ]
    3090                 :            :     {
    3091                 :          3 :         case RTF_UL: nSprm = 1; break;
    3092                 :          0 :         case RTF_ULDASH: nSprm = 7; break;
    3093                 :          0 :         case RTF_ULDASHD: nSprm = 9; break;
    3094                 :          0 :         case RTF_ULDASHDD: nSprm = 10; break;
    3095                 :          0 :         case RTF_ULDB: nSprm = 3; break;
    3096                 :          0 :         case RTF_ULHWAVE: nSprm = 27; break;
    3097                 :          0 :         case RTF_ULLDASH: nSprm = 39; break;
    3098                 :          0 :         case RTF_ULTH: nSprm = 6; break;
    3099                 :          0 :         case RTF_ULTHD: nSprm = 20; break;
    3100                 :          0 :         case RTF_ULTHDASH: nSprm = 23; break;
    3101                 :          0 :         case RTF_ULTHDASHD: nSprm = 25; break;
    3102                 :          0 :         case RTF_ULTHDASHDD: nSprm = 26; break;
    3103                 :          0 :         case RTF_ULTHLDASH: nSprm = 55; break;
    3104                 :          0 :         case RTF_ULULDBWAVE: nSprm = 43; break;
    3105                 :          0 :         case RTF_ULWAVE: nSprm = 11; break;
    3106                 :       1296 :         default: break;
    3107                 :            :     }
    3108         [ +  + ]:       1299 :     if (nSprm >= 0)
    3109                 :            :     {
    3110 [ +  - ][ +  - ]:          3 :         RTFValue::Pointer_t pValue(new RTFValue((!bParam || nParam != 0) ? nSprm : 0));
         [ -  + ][ +  - ]
                 [ +  - ]
    3111 [ +  - ][ +  - ]:          3 :         m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CKul, pValue);
         [ +  - ][ +  - ]
    3112         [ +  - ]:          3 :         return 0;
    3113                 :            :     }
    3114                 :            : 
    3115                 :            :     // Accent characters (over dot / over coma).
    3116   [ -  -  -  -  :       1296 :     switch (nKeyword)
                   -  + ]
    3117                 :            :     {
    3118                 :          0 :         case RTF_ACCNONE: nSprm = 0; break;
    3119                 :          0 :         case RTF_ACCDOT: nSprm = 1; break;
    3120                 :          0 :         case RTF_ACCCOMMA: nSprm = 2; break;
    3121                 :          0 :         case RTF_ACCCIRCLE: nSprm = 3; break;
    3122                 :          0 :         case RTF_ACCUNDERDOT: nSprm = 4; break;
    3123                 :       1296 :         default: break;
    3124                 :            :     }
    3125         [ -  + ]:       1296 :     if (nSprm >= 0)
    3126                 :            :     {
    3127 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pValue(new RTFValue((!bParam || nParam != 0) ? nSprm : 0));
         [ #  # ][ #  # ]
                 [ #  # ]
    3128 [ #  # ][ #  # ]:          0 :         m_aStates.top().aCharacterSprms.set(NS_sprm::LN_CKcd, pValue);
         [ #  # ][ #  # ]
    3129         [ #  # ]:          0 :         return 0;
    3130                 :            :     }
    3131                 :            : 
    3132                 :            :     // Trivial character sprms.
    3133   [ +  +  +  +  :       1296 :     switch (nKeyword)
          -  -  -  -  +  
             -  +  -  +  
                      + ]
    3134                 :            :     {
    3135                 :         69 :         case RTF_B: nSprm = NS_sprm::LN_CFBold; break;
    3136                 :         36 :         case RTF_AB: nSprm = NS_sprm::LN_CFBoldBi; break;
    3137                 :        765 :         case RTF_I: nSprm = NS_sprm::LN_CFItalic; break;
    3138                 :         81 :         case RTF_AI: nSprm = NS_sprm::LN_CFItalicBi; break;
    3139                 :          0 :         case RTF_UL: nSprm = NS_sprm::LN_CKul; break;
    3140                 :          0 :         case RTF_OUTL: nSprm = NS_sprm::LN_CFOutline; break;
    3141                 :          0 :         case RTF_SHAD: nSprm = NS_sprm::LN_CFShadow; break;
    3142                 :          0 :         case RTF_V: nSprm = NS_sprm::LN_CFVanish; break;
    3143                 :          3 :         case RTF_STRIKE: nSprm = NS_sprm::LN_CFStrike; break;
    3144                 :          0 :         case RTF_STRIKED: nSprm = NS_sprm::LN_CFDStrike; break;
    3145                 :         15 :         case RTF_SCAPS: nSprm = NS_sprm::LN_CFSmallCaps; break;
    3146                 :          0 :         case RTF_IMPR: nSprm = NS_sprm::LN_CFImprint; break;
    3147                 :          3 :         case RTF_CAPS: nSprm = NS_sprm::LN_CFCaps; break;
    3148                 :        324 :         default: break;
    3149                 :            :     }
    3150         [ +  + ]:       1296 :     if (nSprm >= 0)
    3151                 :            :     {
    3152 [ +  - ][ +  - ]:        972 :         m_aStates.top().aCharacterSprms.set(nSprm, pBoolValue);
         [ +  - ][ +  - ]
    3153                 :        972 :         return 0;
    3154                 :            :     }
    3155                 :            : 
    3156      [ +  -  + ]:        324 :     switch (nKeyword)
    3157                 :            :     {
    3158                 :            :         case RTF_ASPALPHA:
    3159 [ +  - ][ +  - ]:        144 :             m_aStates.top().aParagraphSprms.set(NS_sprm::LN_PFAutoSpaceDE, pBoolValue);
         [ +  - ][ +  - ]
    3160                 :        144 :             break;
    3161                 :            :         case RTF_DELETED:
    3162                 :            :         case RTF_REVISED:
    3163                 :            :             {
    3164 [ #  # ][ #  # ]:          0 :                 RTFValue::Pointer_t pValue(new RTFValue(nKeyword == RTF_DELETED ? ooxml::OOXML_del : ooxml::OOXML_ins));
         [ #  # ][ #  # ]
    3165         [ #  # ]:          0 :                 lcl_putNestedAttribute(m_aStates.top().aCharacterSprms,
    3166 [ #  # ][ #  # ]:          0 :                         NS_ooxml::LN_trackchange, NS_ooxml::LN_token, pValue);
         [ #  # ][ #  # ]
    3167                 :            :             }
    3168                 :          0 :             break;
    3169                 :            :         default:
    3170                 :            :             SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle toggle '" << lcl_RtfToString(nKeyword) << "'");
    3171         [ +  - ]:        180 :             aSkip.setParsed(false);
    3172                 :        180 :             break;
    3173                 :            :     }
    3174 [ +  - ][ +  - ]:       1299 :     return 0;
    3175                 :            : }
    3176                 :            : 
    3177                 :      15081 : int RTFDocumentImpl::pushState()
    3178                 :            : {
    3179                 :            :     //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before push: " << m_nGroup);
    3180                 :            : 
    3181         [ +  - ]:      15081 :     checkUnicode();
    3182         [ +  - ]:      15081 :     m_nGroupStartPos = Strm().Tell();
    3183         [ +  - ]:      15081 :     RTFParserState aState(this);
    3184         [ +  + ]:      15081 :     if (m_aStates.empty())
    3185         [ +  - ]:        336 :         aState = m_aDefaultState;
    3186                 :            :     else
    3187                 :            :     {
    3188 [ +  - ][ +  + ]:      14745 :         if (m_aStates.top().nDestinationState == DESTINATION_MR)
    3189 [ +  - ][ +  - ]:        693 :             lcl_DestinationToMath(m_aStates.top().aDestinationText, m_aMathBuffer);
    3190 [ +  - ][ +  - ]:      14745 :         aState = m_aStates.top();
    3191                 :            :     }
    3192         [ +  - ]:      15081 :     m_aStates.push(aState);
    3193 [ +  - ][ +  - ]:      15081 :     m_aStates.top().aDestinationText.setLength(0);
    3194                 :            : 
    3195                 :      15081 :     m_nGroup++;
    3196                 :            : 
    3197 [ +  - ][ +  +  :      15081 :     switch (m_aStates.top().nDestinationState)
          +  +  +  +  +  
                      + ]
    3198                 :            :     {
    3199         [ +  - ]:       1320 :     case DESTINATION_FONTTABLE: m_aStates.top().nDestinationState = DESTINATION_FONTENTRY; break;
    3200         [ +  - ]:        765 :     case DESTINATION_STYLESHEET: m_aStates.top().nDestinationState = DESTINATION_STYLEENTRY; break;
    3201                 :            :     case DESTINATION_FIELDRESULT:
    3202                 :            :     case DESTINATION_SHAPETEXT:
    3203                 :            :     case DESTINATION_FORMFIELD:
    3204         [ +  - ]:          9 :         m_aStates.top().nDestinationState = DESTINATION_NORMAL;
    3205                 :          9 :     break;
    3206                 :            :     case DESTINATION_MNUM:
    3207                 :            :     case DESTINATION_MDEN:
    3208                 :            :     case DESTINATION_ME:
    3209                 :            :     case DESTINATION_MFNAME:
    3210                 :            :     case DESTINATION_MLIM:
    3211                 :            :     case DESTINATION_MSUB:
    3212                 :            :     case DESTINATION_MSUP:
    3213                 :            :     case DESTINATION_MDEG:
    3214         [ +  - ]:       2103 :         m_aStates.top().nDestinationState = DESTINATION_MR;
    3215                 :       2103 :     break;
    3216                 :            :     case DESTINATION_FIELDINSTRUCTION:
    3217         [ +  - ]:          6 :         m_aStates.top().nDestinationState = DESTINATION_NORMAL;
    3218                 :          6 :     break;
    3219         [ +  - ]:          3 :     case DESTINATION_REVISIONTABLE: m_aStates.top().nDestinationState = DESTINATION_REVISIONENTRY; break;
    3220         [ +  - ]:        924 :     case DESTINATION_MOMATH: m_aStates.top().nDestinationState = DESTINATION_MR; break;
    3221                 :       9951 :     default: break;
    3222                 :            :     }
    3223                 :            : 
    3224         [ +  - ]:      15081 :     return 0;
    3225                 :            : }
    3226                 :            : 
    3227                 :        753 : RTFSprms RTFDocumentImpl::mergeSprms()
    3228                 :            : {
    3229                 :        753 :     RTFSprms aSprms;
    3230 [ +  - ][ -  + ]:       1506 :     for (RTFSprms::Iterator_t i = m_aStates.top().aTableSprms.begin();
                 [ +  - ]
    3231         [ +  - ]:        753 :             i != m_aStates.top().aTableSprms.end(); ++i)
    3232 [ #  # ][ #  # ]:          0 :         aSprms.set(i->first, i->second);
                 [ #  # ]
    3233 [ +  - ][ +  - ]:       5544 :     for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterSprms.begin();
                 [ +  + ]
    3234         [ +  - ]:       2772 :             i != m_aStates.top().aCharacterSprms.end(); ++i)
    3235 [ +  - ][ +  - ]:       2019 :         aSprms.set(i->first, i->second);
                 [ +  - ]
    3236 [ +  - ][ +  - ]:       3762 :     for (RTFSprms::Iterator_t i = m_aStates.top().aParagraphSprms.begin();
                 [ +  + ]
    3237         [ +  - ]:       1881 :             i != m_aStates.top().aParagraphSprms.end(); ++i)
    3238 [ +  - ][ +  - ]:       1128 :         aSprms.set(i->first, i->second);
                 [ +  - ]
    3239                 :        753 :     return aSprms;
    3240                 :            : }
    3241                 :            : 
    3242                 :       2082 : void RTFDocumentImpl::resetSprms()
    3243                 :            : {
    3244                 :       2082 :     m_aStates.top().aTableSprms.clear();
    3245                 :       2082 :     m_aStates.top().aCharacterSprms.clear();
    3246                 :       2082 :     m_aStates.top().aParagraphSprms.clear();
    3247                 :       2082 : }
    3248                 :            : 
    3249                 :        753 : RTFSprms RTFDocumentImpl::mergeAttributes()
    3250                 :            : {
    3251                 :        753 :     RTFSprms aAttributes;
    3252 [ +  - ][ +  + ]:       8118 :     for (RTFSprms::Iterator_t i = m_aStates.top().aTableAttributes.begin();
                 [ +  - ]
    3253         [ +  - ]:       4059 :             i != m_aStates.top().aTableAttributes.end(); ++i)
    3254 [ +  - ][ +  - ]:       3306 :         aAttributes.set(i->first, i->second);
                 [ +  - ]
    3255 [ +  - ][ +  - ]:       1740 :     for (RTFSprms::Iterator_t i = m_aStates.top().aCharacterAttributes.begin();
                 [ +  + ]
    3256         [ +  - ]:        870 :             i != m_aStates.top().aCharacterAttributes.end(); ++i)
    3257 [ +  - ][ +  - ]:        117 :         aAttributes.set(i->first, i->second);
                 [ +  - ]
    3258 [ +  - ][ +  - ]:       1518 :     for (RTFSprms::Iterator_t i = m_aStates.top().aParagraphAttributes.begin();
                 [ +  + ]
    3259         [ +  - ]:        759 :             i != m_aStates.top().aParagraphAttributes.end(); ++i)
    3260 [ +  - ][ +  - ]:          6 :         aAttributes.set(i->first, i->second);
                 [ +  - ]
    3261                 :        753 :     return aAttributes;
    3262                 :            : }
    3263                 :            : 
    3264                 :       2082 : void RTFDocumentImpl::resetAttributes()
    3265                 :            : {
    3266                 :       2082 :     m_aStates.top().aTableAttributes.clear();
    3267                 :       2082 :     m_aStates.top().aCharacterAttributes.clear();
    3268                 :       2082 :     m_aStates.top().aParagraphAttributes.clear();
    3269                 :       2082 : }
    3270                 :            : 
    3271                 :      15072 : int RTFDocumentImpl::popState()
    3272                 :            : {
    3273                 :            :     //SAL_INFO("writerfilter", OSL_THIS_FUNC << " before pop: m_nGroup " << m_nGroup <<
    3274                 :            :     //                         ", dest state: " << m_aStates.top().nDestinationState);
    3275                 :            : 
    3276         [ +  - ]:      15072 :     checkUnicode();
    3277 [ +  - ][ +  - ]:      15072 :     RTFParserState aState(m_aStates.top());
    3278                 :      15072 :     sal_Int32 nMathToken = 0;
    3279                 :            : 
    3280 [ +  - ][ +  +  :      15072 :     switch (m_aStates.top().nDestinationState)
          +  +  +  +  +  
          +  +  +  -  -  
          +  -  -  -  -  
          +  +  +  +  +  
          +  +  +  +  +  
          -  -  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                   +  + ]
    3281                 :            :     {
    3282                 :            :     case DESTINATION_FONTTABLE:
    3283                 :            :     {
    3284 [ +  - ][ +  - ]:        150 :         writerfilter::Reference<Table>::Pointer_t const pTable(new RTFReferenceTable(m_aFontTableEntries));
                 [ +  - ]
    3285 [ +  - ][ +  - ]:        150 :         Mapper().table(NS_rtf::LN_FONTTABLE, pTable);
         [ +  - ][ +  - ]
    3286                 :            :     }
    3287                 :        150 :     break;
    3288                 :            :     case DESTINATION_STYLESHEET:
    3289                 :            :     {
    3290 [ +  - ][ +  - ]:        114 :         writerfilter::Reference<Table>::Pointer_t const pTable(new RTFReferenceTable(m_aStyleTableEntries));
                 [ +  - ]
    3291 [ +  - ][ +  - ]:        114 :         Mapper().table(NS_rtf::LN_STYLESHEET, pTable);
         [ +  - ][ +  - ]
    3292                 :            :     }
    3293                 :        114 :     break;
    3294                 :            :     case DESTINATION_LISTOVERRIDETABLE:
    3295                 :            :     {
    3296         [ +  - ]:         15 :         RTFSprms aListTableAttributes;
    3297 [ +  - ][ +  - ]:         15 :         writerfilter::Reference<Properties>::Pointer_t const pProp(new RTFReferenceProperties(aListTableAttributes, m_aListTableSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3298         [ +  - ]:         15 :         RTFReferenceTable::Entries_t aListTableEntries;
    3299 [ +  - ][ +  - ]:         15 :         aListTableEntries.insert(make_pair(0, pProp));
                 [ +  - ]
    3300 [ +  - ][ +  - ]:         15 :         writerfilter::Reference<Table>::Pointer_t const pTable(new RTFReferenceTable(aListTableEntries));
                 [ +  - ]
    3301 [ +  - ][ +  - ]:         15 :         Mapper().table(NS_rtf::LN_LISTTABLE, pTable);
         [ +  - ][ +  - ]
                 [ +  - ]
    3302                 :            :     }
    3303                 :         15 :     break;
    3304                 :            :     case DESTINATION_LISTENTRY:
    3305 [ +  - ][ +  + ]:         39 :         for (RTFSprms::Iterator_t i = aState.aListLevelEntries.begin(); i != aState.aListLevelEntries.end(); ++i)
    3306 [ +  - ][ +  - ]:         24 :             aState.aTableSprms.set(i->first, i->second, false);
                 [ +  - ]
    3307                 :         15 :     break;
    3308                 :            :     case DESTINATION_FIELDINSTRUCTION:
    3309                 :            :         {
    3310 [ +  - ][ +  - ]:         18 :             RTFValue::Pointer_t pValue(new RTFValue(m_aFormfieldAttributes, m_aFormfieldSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3311         [ +  - ]:         18 :             RTFSprms aFFAttributes;
    3312         [ +  - ]:         18 :             RTFSprms aFFSprms;
    3313 [ +  - ][ +  - ]:         18 :             aFFSprms.set(NS_ooxml::LN_ffdata, pValue);
                 [ +  - ]
    3314 [ +  - ][ +  - ]:         18 :             writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aFFAttributes, aFFSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3315 [ +  - ][ +  - ]:         18 :             Mapper().props(pProperties);
                 [ +  - ]
    3316                 :         18 :             m_aFormfieldAttributes.clear();
    3317 [ +  - ][ +  - ]:         18 :             m_aFormfieldSprms.clear();
    3318                 :            :         }
    3319         [ +  - ]:         18 :         singleChar(0x14);
    3320                 :         18 :     break;
    3321                 :            :     case DESTINATION_FIELDRESULT:
    3322         [ +  - ]:         15 :         singleChar(0x15);
    3323                 :         15 :     break;
    3324                 :            :     case DESTINATION_LEVELTEXT:
    3325                 :            :     {
    3326 [ +  - ][ +  - ]:         30 :         OUString aStr = m_aStates.top().aDestinationText.makeStringAndClear();
    3327                 :            : 
    3328                 :            :         // The first character is the length of the string (the rest should be ignored).
    3329                 :         30 :         sal_Int32 nLength(aStr.toChar());
    3330                 :         30 :         OUString aValue;
    3331         [ +  - ]:         30 :         if (nLength <= aStr.getLength())
    3332                 :         30 :             aValue = aStr.copy(1, nLength);
    3333                 :            :         else
    3334                 :          0 :             aValue = aStr;
    3335 [ +  - ][ +  - ]:         30 :         RTFValue::Pointer_t pValue(new RTFValue(aValue, true));
                 [ +  - ]
    3336 [ +  - ][ +  - ]:         30 :         aState.aTableAttributes.set(NS_ooxml::LN_CT_LevelText_val, pValue);
         [ +  - ][ +  - ]
    3337                 :            :     }
    3338                 :         30 :     break;
    3339                 :            :     case DESTINATION_LEVELNUMBERS:
    3340                 :            :     {
    3341 [ +  - ][ +  - ]:         30 :         RTFSprms& rAttributes = aState.aTableSprms.find(NS_ooxml::LN_CT_Lvl_lvlText)->getAttributes();
                 [ +  - ]
    3342         [ +  - ]:         30 :         RTFValue::Pointer_t pValue = rAttributes.find(NS_ooxml::LN_CT_LevelText_val);
    3343         [ +  - ]:         30 :         OUString aOrig = pValue->getString();
    3344                 :            : 
    3345                 :         30 :         OUStringBuffer aBuf;
    3346                 :         30 :         sal_Int32 nReplaces = 1;
    3347         [ +  + ]:        108 :         for (int i = 0; i < aOrig.getLength(); i++)
    3348                 :            :         {
    3349 [ +  - ][ +  - ]:        156 :             if (std::find(m_aStates.top().aLevelNumbers.begin(), m_aStates.top().aLevelNumbers.end(), i+1)
         [ +  + ][ +  - ]
    3350 [ +  - ][ +  - ]:        156 :                     != m_aStates.top().aLevelNumbers.end())
    3351                 :            :             {
    3352         [ +  - ]:         45 :                 aBuf.append(sal_Unicode('%'));
    3353                 :            :                 // '1.1.1' -> '%1.%2.%3', but '1.' (with '2.' prefix omitted) is %2.
    3354 [ +  - ][ +  - ]:         45 :                 aBuf.append(sal_Int32(nReplaces++ + m_aStates.top().nListLevelNum + 1 - m_aStates.top().aLevelNumbers.size()));
                 [ +  - ]
    3355                 :            :             }
    3356                 :            :             else
    3357         [ +  - ]:         33 :                 aBuf.append(aOrig.copy(i, 1));
    3358                 :            :         }
    3359 [ +  - ][ +  - ]:         30 :         pValue->setString(aBuf.makeStringAndClear());
                 [ +  - ]
    3360                 :            :     }
    3361                 :         30 :     break;
    3362                 :            :     case DESTINATION_SHAPEPROPERTYNAME:
    3363                 :            :     case DESTINATION_SHAPEPROPERTYVALUE:
    3364                 :            :     case DESTINATION_SHAPEPROPERTY:
    3365                 :            :     {
    3366 [ +  - ][ +  + ]:       1098 :         if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYNAME)
    3367 [ +  - ][ +  - ]:        366 :             aState.aShape.aProperties.push_back(make_pair(m_aStates.top().aDestinationText.makeStringAndClear(), OUString()));
                 [ +  - ]
    3368 [ +  - ][ +  + ]:        732 :         else if (m_aStates.top().nDestinationState == DESTINATION_SHAPEPROPERTYVALUE && aState.aShape.aProperties.size())
         [ +  + ][ +  + ]
    3369 [ +  - ][ +  - ]:        363 :             aState.aShape.aProperties.back().second = m_aStates.top().aDestinationText.makeStringAndClear();
                 [ +  - ]
    3370                 :            :     }
    3371                 :       1098 :     break;
    3372                 :            :     case DESTINATION_PICPROP:
    3373                 :            :     case DESTINATION_SHAPEINSTRUCTION:
    3374         [ +  - ]:         39 :         if (!m_bObject)
    3375 [ +  - ][ +  - ]:         39 :             m_pSdrImport->resolve(m_aStates.top().aShape);
    3376                 :         39 :     break;
    3377                 :            :     case DESTINATION_BOOKMARKSTART:
    3378                 :            :     {
    3379 [ #  # ][ #  # ]:          0 :         OUString aStr = m_aStates.top().aDestinationText.makeStringAndClear();
    3380                 :          0 :         int nPos = m_aBookmarks.size();
    3381         [ #  # ]:          0 :         m_aBookmarks[aStr] = nPos;
    3382 [ #  # ][ #  # ]:          0 :         Mapper().props(lcl_getBookmarkProperties(nPos, aStr));
                 [ #  # ]
    3383                 :            :     }
    3384                 :          0 :     break;
    3385                 :            :     case DESTINATION_BOOKMARKEND:
    3386 [ #  # ][ #  # ]:          0 :         Mapper().props(lcl_getBookmarkProperties(m_aBookmarks[m_aStates.top().aDestinationText.makeStringAndClear()]));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3387                 :          0 :     break;
    3388                 :            :     case DESTINATION_PICT:
    3389         [ +  - ]:         15 :         resolvePict(true);
    3390                 :         15 :     break;
    3391                 :            :     case DESTINATION_SHAPETEXT:
    3392                 :          0 :         m_pCurrentBuffer = 0; // Just disable buffering, don't empty it yet.
    3393                 :          0 :     break;
    3394                 :            :     case DESTINATION_FORMFIELDNAME:
    3395                 :            :     {
    3396 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aDestinationText.makeStringAndClear()));
         [ #  # ][ #  # ]
                 [ #  # ]
    3397 [ #  # ][ #  # ]:          0 :         m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFData_name, pValue);
         [ #  # ][ #  # ]
    3398                 :            :     }
    3399                 :          0 :     break;
    3400                 :            :     case DESTINATION_FORMFIELDLIST:
    3401                 :            :     {
    3402 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pValue(new RTFValue(m_aStates.top().aDestinationText.makeStringAndClear()));
         [ #  # ][ #  # ]
                 [ #  # ]
    3403 [ #  # ][ #  # ]:          0 :         m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFDDList_listEntry, pValue);
         [ #  # ][ #  # ]
    3404                 :            :     }
    3405                 :          0 :     break;
    3406                 :            :     case DESTINATION_DATAFIELD:
    3407                 :            :     {
    3408 [ #  # ][ #  # ]:          0 :         OString aStr = OUStringToOString(m_aStates.top().aDestinationText.makeStringAndClear(), m_aStates.top().nCurrentEncoding);
         [ #  # ][ #  # ]
    3409                 :            :         // decode hex dump
    3410                 :          0 :         OStringBuffer aBuf;
    3411                 :          0 :         const char *str = aStr.getStr();
    3412                 :          0 :         int b = 0, count = 2;
    3413         [ #  # ]:          0 :         for (int i = 0; i < aStr.getLength(); ++i)
    3414                 :            :         {
    3415                 :          0 :             char ch = str[i];
    3416 [ #  # ][ #  # ]:          0 :             if (ch != 0x0d && ch != 0x0a)
    3417                 :            :             {
    3418                 :          0 :                 b = b << 4;
    3419         [ #  # ]:          0 :                 sal_Int8 parsed = m_pTokenizer->asHex(ch);
    3420         [ #  # ]:          0 :                 if (parsed == -1)
    3421                 :          0 :                     return ERROR_HEX_INVALID;
    3422                 :          0 :                 b += parsed;
    3423                 :          0 :                 count--;
    3424         [ #  # ]:          0 :                 if (!count)
    3425                 :            :                 {
    3426         [ #  # ]:          0 :                     aBuf.append((char)b);
    3427                 :          0 :                     count = 2;
    3428                 :          0 :                     b = 0;
    3429                 :            :                 }
    3430                 :            :             }
    3431                 :            :         }
    3432                 :          0 :         aStr = aBuf.makeStringAndClear();
    3433                 :            :         // ignore the first bytes
    3434         [ #  # ]:          0 :         if (aStr.getLength() > 8)
    3435                 :          0 :             aStr = aStr.copy(8);
    3436                 :            :         // extract name
    3437                 :          0 :         int nLength = aStr.toChar();
    3438                 :          0 :         aStr = aStr.copy(1);
    3439                 :          0 :         OString aName = aStr.copy(0, nLength);
    3440                 :          0 :         aStr = aStr.copy(nLength+1); // zero-terminated string
    3441                 :            :         // extract default text
    3442                 :          0 :         nLength = aStr.toChar();
    3443                 :          0 :         aStr = aStr.copy(1);
    3444                 :          0 :         OString aDefaultText = aStr.copy(0, nLength);
    3445 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pNValue(new RTFValue(OStringToOUString(aName, m_aStates.top().nCurrentEncoding)));
         [ #  # ][ #  # ]
                 [ #  # ]
    3446 [ #  # ][ #  # ]:          0 :         m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFData_name, pNValue);
                 [ #  # ]
    3447 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pDValue(new RTFValue(OStringToOUString(aDefaultText, m_aStates.top().nCurrentEncoding)));
         [ #  # ][ #  # ]
                 [ #  # ]
    3448 [ #  # ][ #  # ]:          0 :         m_aFormfieldSprms.set(NS_ooxml::LN_CT_FFTextInput_default, pDValue);
                 [ #  # ]
    3449                 :            : 
    3450 [ #  # ][ #  # ]:          0 :         m_bFormField = false;
         [ #  # ][ #  # ]
    3451                 :            :     }
    3452                 :          0 :     break;
    3453                 :            :     case DESTINATION_CREATIONTIME:
    3454         [ +  + ]:         87 :     if (m_xDocumentProperties.is())
    3455 [ +  - ][ +  - ]:         81 :         m_xDocumentProperties->setCreationDate(lcl_getDateTime(m_aStates));
                 [ +  - ]
    3456                 :         87 :     break;
    3457                 :            :     case DESTINATION_REVISIONTIME:
    3458         [ +  + ]:         87 :     if (m_xDocumentProperties.is())
    3459 [ +  - ][ +  - ]:         81 :         m_xDocumentProperties->setModificationDate(lcl_getDateTime(m_aStates));
                 [ +  - ]
    3460                 :         87 :     break;
    3461                 :            :     case DESTINATION_PRINTTIME:
    3462         [ +  + ]:         81 :     if (m_xDocumentProperties.is())
    3463 [ +  - ][ +  - ]:         78 :         m_xDocumentProperties->setPrintDate(lcl_getDateTime(m_aStates));
                 [ +  - ]
    3464                 :         81 :     break;
    3465                 :            :     case DESTINATION_AUTHOR:
    3466         [ +  + ]:          9 :     if (m_xDocumentProperties.is())
    3467 [ +  - ][ +  - ]:          3 :         m_xDocumentProperties->setAuthor(m_aStates.top().aDestinationText.makeStringAndClear());
         [ +  - ][ +  - ]
    3468                 :          9 :     break;
    3469                 :            :     case DESTINATION_KEYWORDS:
    3470         [ +  - ]:          6 :     if (m_xDocumentProperties.is())
    3471 [ +  - ][ +  - ]:          6 :         m_xDocumentProperties->setKeywords(comphelper::string::convertCommaSeparated(m_aStates.top().aDestinationText.makeStringAndClear()));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    3472                 :          6 :     break;
    3473                 :            :     case DESTINATION_COMMENT:
    3474         [ +  + ]:        162 :     if (m_xDocumentProperties.is())
    3475 [ +  - ][ +  - ]:        156 :         m_xDocumentProperties->setGenerator(m_aStates.top().aDestinationText.makeStringAndClear());
         [ +  - ][ +  - ]
    3476                 :        162 :     break;
    3477                 :            :     case DESTINATION_TITLE:
    3478         [ +  + ]:         12 :     if (m_xDocumentProperties.is())
    3479 [ +  - ][ +  - ]:          6 :         m_xDocumentProperties->setTitle(m_aStates.top().aDestinationText.makeStringAndClear());
         [ +  - ][ +  - ]
    3480                 :         12 :     break;
    3481                 :            :     case DESTINATION_SUBJECT:
    3482         [ +  - ]:          9 :     if (m_xDocumentProperties.is())
    3483 [ +  - ][ +  - ]:          9 :         m_xDocumentProperties->setSubject(m_aStates.top().aDestinationText.makeStringAndClear());
         [ +  - ][ +  - ]
    3484                 :          9 :     break;
    3485                 :            :     case DESTINATION_DOCCOMM:
    3486         [ +  - ]:          6 :     if (m_xDocumentProperties.is())
    3487 [ +  - ][ +  - ]:          6 :         m_xDocumentProperties->setDescription(m_aStates.top().aDestinationText.makeStringAndClear());
         [ +  - ][ +  - ]
    3488                 :          6 :     break;
    3489                 :            :     case DESTINATION_OPERATOR:
    3490                 :            :     case DESTINATION_COMPANY:
    3491                 :            :     {
    3492 [ +  - ][ +  + ]:         18 :         OUString aName = m_aStates.top().nDestinationState == DESTINATION_OPERATOR ? OUString("Operator") : OUString("Company");
         [ +  + ][ +  + ]
    3493         [ +  + ]:         18 :         if (m_xDocumentProperties.is())
    3494                 :            :         {
    3495 [ +  - ][ +  - ]:          6 :             uno::Reference<beans::XPropertyContainer> xUserDefinedProperties = m_xDocumentProperties->getUserDefinedProperties();
    3496         [ +  - ]:          6 :             xUserDefinedProperties->addProperty(aName, beans::PropertyAttribute::REMOVEABLE,
    3497 [ +  - ][ +  - ]:          6 :                     uno::makeAny(m_aStates.top().aDestinationText.makeStringAndClear()));
         [ +  - ][ +  - ]
    3498                 :         18 :         }
    3499                 :            :     }
    3500                 :         18 :     break;
    3501                 :            :     case DESTINATION_OBJDATA:
    3502                 :            :     {
    3503 [ #  # ][ #  # ]:          0 :         m_pObjectData.reset(new SvMemoryStream());
                 [ #  # ]
    3504                 :          0 :         int b = 0, count = 2;
    3505                 :            : 
    3506                 :            :         // Feed the destination text to a stream.
    3507 [ #  # ][ #  # ]:          0 :         OString aStr = OUStringToOString(m_aStates.top().aDestinationText.makeStringAndClear(), RTL_TEXTENCODING_ASCII_US);
                 [ #  # ]
    3508                 :          0 :         const char *str = aStr.getStr();
    3509         [ #  # ]:          0 :         for (int i = 0; i < aStr.getLength(); ++i)
    3510                 :            :         {
    3511                 :          0 :             char ch = str[i];
    3512 [ #  # ][ #  # ]:          0 :             if (ch != 0x0d && ch != 0x0a)
    3513                 :            :             {
    3514                 :          0 :                 b = b << 4;
    3515         [ #  # ]:          0 :                 sal_Int8 parsed = m_pTokenizer->asHex(ch);
    3516         [ #  # ]:          0 :                 if (parsed == -1)
    3517                 :          0 :                     return ERROR_HEX_INVALID;
    3518                 :          0 :                 b += parsed;
    3519                 :          0 :                 count--;
    3520         [ #  # ]:          0 :                 if (!count)
    3521                 :            :                 {
    3522         [ #  # ]:          0 :                     *m_pObjectData << (char)b;
    3523                 :          0 :                     count = 2;
    3524                 :          0 :                     b = 0;
    3525                 :            :                 }
    3526                 :            :             }
    3527                 :            :         }
    3528                 :            : 
    3529         [ #  # ]:          0 :         if (m_pObjectData->Tell())
    3530                 :            :         {
    3531         [ #  # ]:          0 :             m_pObjectData->Seek(0);
    3532                 :            : 
    3533                 :            :             // Skip ObjectHeader
    3534                 :            :             sal_uInt32 nData;
    3535         [ #  # ]:          0 :             *m_pObjectData >> nData; // OLEVersion
    3536         [ #  # ]:          0 :             *m_pObjectData >> nData; // FormatID
    3537         [ #  # ]:          0 :             *m_pObjectData >> nData; // ClassName
    3538         [ #  # ]:          0 :             m_pObjectData->SeekRel(nData);
    3539         [ #  # ]:          0 :             *m_pObjectData >> nData; // TopicName
    3540         [ #  # ]:          0 :             m_pObjectData->SeekRel(nData);
    3541         [ #  # ]:          0 :             *m_pObjectData >> nData; // ItemName
    3542         [ #  # ]:          0 :             m_pObjectData->SeekRel(nData);
    3543         [ #  # ]:          0 :             *m_pObjectData >> nData; // NativeDataSize
    3544                 :            :         }
    3545                 :            : 
    3546 [ #  # ][ #  # ]:          0 :         uno::Reference<io::XInputStream> xInputStream(new utl::OInputStreamWrapper(m_pObjectData.get()));
                 [ #  # ]
    3547 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pStreamValue(new RTFValue(xInputStream));
                 [ #  # ]
    3548                 :            : 
    3549         [ #  # ]:          0 :         RTFSprms aOLEAttributes;
    3550 [ #  # ][ #  # ]:          0 :         aOLEAttributes.set(NS_ooxml::LN_inputstream, pStreamValue);
                 [ #  # ]
    3551 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pValue(new RTFValue(aOLEAttributes));
         [ #  # ][ #  # ]
    3552 [ #  # ][ #  # ]:          0 :         m_aObjectSprms.set(NS_ooxml::LN_OLEObject_OLEObject, pValue);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3553                 :            :     }
    3554                 :          0 :     break;
    3555                 :            :     case DESTINATION_OBJECT:
    3556                 :            :     {
    3557         [ #  # ]:          0 :         RTFSprms aObjAttributes;
    3558         [ #  # ]:          0 :         RTFSprms aObjSprms;
    3559 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pValue(new RTFValue(m_aObjectAttributes, m_aObjectSprms));
         [ #  # ][ #  # ]
                 [ #  # ]
    3560 [ #  # ][ #  # ]:          0 :         aObjSprms.set(NS_ooxml::LN_object, pValue);
                 [ #  # ]
    3561 [ #  # ][ #  # ]:          0 :         writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aObjAttributes, aObjSprms));
         [ #  # ][ #  # ]
                 [ #  # ]
    3562                 :          0 :         uno::Reference<drawing::XShape> xShape;
    3563         [ #  # ]:          0 :         RTFValue::Pointer_t pShape = m_aObjectAttributes.find(NS_ooxml::LN_shape);
    3564                 :            :         OSL_ASSERT(pShape.get());
    3565         [ #  # ]:          0 :         if (pShape.get())
    3566 [ #  # ][ #  # ]:          0 :             pShape->getAny() >>= xShape;
    3567         [ #  # ]:          0 :         Mapper().startShape(xShape);
    3568 [ #  # ][ #  # ]:          0 :         Mapper().props(pProperties);
                 [ #  # ]
    3569         [ #  # ]:          0 :         Mapper().endShape();
    3570                 :          0 :         m_aObjectAttributes.clear();
    3571                 :          0 :         m_aObjectSprms.clear();
    3572 [ #  # ][ #  # ]:          0 :         m_bObject = false;
                 [ #  # ]
    3573                 :            :     }
    3574                 :          0 :     break;
    3575                 :            :     case DESTINATION_ANNOTATIONDATE:
    3576                 :            :     {
    3577         [ +  - ]:          6 :         OUString aStr(OStringToOUString(lcl_DTTM22OString(m_aStates.top().aDestinationText.makeStringAndClear().toInt32()),
    3578 [ +  - ][ +  - ]:         12 :                     m_aStates.top().nCurrentEncoding));
         [ +  - ][ +  - ]
    3579 [ +  - ][ +  - ]:          6 :         RTFValue::Pointer_t pValue(new RTFValue(aStr));
                 [ +  - ]
    3580         [ +  - ]:          6 :         RTFSprms aAnnAttributes;
    3581 [ +  - ][ +  - ]:          6 :         aAnnAttributes.set(NS_ooxml::LN_CT_TrackChange_date, pValue);
                 [ +  - ]
    3582 [ +  - ][ +  - ]:          6 :         writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aAnnAttributes));
         [ +  - ][ +  - ]
    3583 [ +  - ][ +  - ]:          6 :         Mapper().props(pProperties);
         [ +  - ][ +  - ]
                 [ +  - ]
    3584                 :            :     }
    3585                 :          6 :     break;
    3586                 :            :     case DESTINATION_ANNOTATIONAUTHOR:
    3587 [ +  - ][ +  - ]:          6 :         m_aAuthor = m_aStates.top().aDestinationText.makeStringAndClear();
    3588                 :          6 :     break;
    3589                 :            :     case DESTINATION_ATNID:
    3590 [ +  - ][ +  - ]:          6 :         m_aAuthorInitials = m_aStates.top().aDestinationText.makeStringAndClear();
    3591                 :          6 :     break;
    3592                 :            :     case DESTINATION_FALT:
    3593                 :            :     {
    3594 [ +  - ][ +  - ]:        303 :         OUString aStr(m_aStates.top().aDestinationText.makeStringAndClear());
    3595 [ +  - ][ +  - ]:        303 :         RTFValue::Pointer_t pValue(new RTFValue(aStr));
                 [ +  - ]
    3596 [ +  - ][ +  - ]:        303 :         aState.aTableSprms.set(NS_ooxml::LN_CT_Font_altName, pValue);
         [ +  - ][ +  - ]
    3597                 :            :     }
    3598                 :        303 :     break;
    3599                 :            :     case DESTINATION_DRAWINGOBJECT:
    3600 [ +  - ][ +  - ]:          3 :     if (m_aStates.top().aDrawingObject.xShape.is())
    3601                 :            :     {
    3602         [ +  - ]:          3 :         RTFDrawingObject& rDrawing = m_aStates.top().aDrawingObject;
    3603                 :          3 :         uno::Reference<drawing::XShape> xShape(rDrawing.xShape);
    3604 [ +  - ][ +  - ]:          3 :         xShape->setPosition(awt::Point(rDrawing.nLeft, rDrawing.nTop));
    3605 [ +  - ][ +  - ]:          3 :         xShape->setSize(awt::Size(rDrawing.nRight, rDrawing.nBottom));
    3606                 :          3 :         uno::Reference<beans::XPropertySet> xPropertySet(rDrawing.xPropertySet);
    3607                 :            : 
    3608         [ +  - ]:          3 :         if (rDrawing.bHasLineColor)
    3609 [ +  - ][ +  - ]:          3 :             xPropertySet->setPropertyValue("LineColor", uno::makeAny(sal_uInt32((rDrawing.nLineColorR<<16) + (rDrawing.nLineColorG<<8) + rDrawing.nLineColorB)));
                 [ +  - ]
    3610         [ -  + ]:          3 :         if (rDrawing.bHasFillColor)
    3611 [ #  # ][ #  # ]:          0 :             xPropertySet->setPropertyValue("FillColor", uno::makeAny(sal_uInt32((rDrawing.nFillColorR<<16) + (rDrawing.nFillColorG<<8) + rDrawing.nFillColorB)));
                 [ #  # ]
    3612                 :            :         else
    3613                 :            :             // If there is no fill, the Word default is 100% transparency.
    3614 [ +  - ][ +  - ]:          3 :             xPropertySet->setPropertyValue("FillTransparence", uno::makeAny(sal_Int32(100)));
                 [ +  - ]
    3615                 :            : 
    3616         [ +  - ]:          3 :         Mapper().startShape(xShape);
    3617         [ +  - ]:          3 :         Mapper().endShape();
    3618                 :            :     }
    3619                 :          3 :     break;
    3620                 :            :     case DESTINATION_SHAPE:
    3621 [ +  - ][ +  + ]:         39 :     if (m_aStates.top().aFrame.inFrame())
    3622                 :            :     {
    3623 [ +  - ][ +  - ]:          6 :         m_aStates.top().resetFrame();
    3624         [ +  - ]:          6 :         parBreak();
    3625                 :            :         // Save this state for later use, so we only reset frame status only for the first shape inside a frame.
    3626 [ +  - ][ +  - ]:          6 :         aState = m_aStates.top();
    3627                 :          6 :         m_bNeedPap = true;
    3628                 :            :     }
    3629                 :         39 :     break;
    3630                 :            :     case DESTINATION_MOMATH:
    3631                 :            :     {
    3632         [ +  - ]:        174 :         m_aMathBuffer.appendClosingTag(M_TOKEN(oMath));
    3633                 :            : 
    3634         [ +  - ]:        174 :         SvGlobalName aGlobalName(SO3_SM_CLASSID);
    3635         [ +  - ]:        174 :         comphelper::EmbeddedObjectContainer aContainer;
    3636                 :        174 :         OUString aName;
    3637 [ +  - ][ +  - ]:        174 :         uno::Reference<embed::XEmbeddedObject> xObject = aContainer.CreateEmbeddedObject(aGlobalName.GetByteSequence(), aName);
                 [ +  - ]
    3638 [ +  - ][ +  - ]:        174 :         uno::Reference<util::XCloseable> xComponent(xObject->getComponent(), uno::UNO_QUERY);
                 [ +  - ]
    3639                 :            : // gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class,
    3640                 :            : // so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated
    3641                 :            : // to RTLD_GLOBAL, so most probably a gcc bug.
    3642 [ +  - ][ -  + ]:        174 :         oox::FormulaImportBase* pImport = dynamic_cast<oox::FormulaImportBase*>(dynamic_cast<SfxBaseModel*>(xComponent.get()));
                 [ +  - ]
    3643                 :            :         assert( pImport != NULL );
    3644         [ +  - ]:        174 :         pImport->readFormulaOoxml(m_aMathBuffer);
    3645 [ +  - ][ +  - ]:        174 :         RTFValue::Pointer_t pValue(new RTFValue(xObject));
                 [ +  - ]
    3646         [ +  - ]:        174 :         RTFSprms aMathAttributes;
    3647 [ +  - ][ +  - ]:        174 :         aMathAttributes.set(NS_ooxml::LN_starmath, pValue);
                 [ +  - ]
    3648 [ +  - ][ +  - ]:        174 :         writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aMathAttributes));
         [ +  - ][ +  - ]
    3649 [ +  - ][ +  - ]:        174 :         Mapper().props(pProperties);
                 [ +  - ]
    3650 [ +  - ][ +  - ]:        174 :         m_aMathBuffer = oox::formulaimport::XmlStreamBuilder();
         [ +  - ][ +  - ]
                 [ +  - ]
    3651                 :            :     }
    3652                 :        174 :     break;
    3653 [ +  - ][ +  - ]:       3090 :     case DESTINATION_MR: lcl_DestinationToMath(m_aStates.top().aDestinationText, m_aMathBuffer); break;
    3654         [ +  - ]:        102 :     case DESTINATION_MF: m_aMathBuffer.appendClosingTag(M_TOKEN(f)); break;
    3655         [ +  - ]:         60 :     case DESTINATION_MFPR: m_aMathBuffer.appendClosingTag(M_TOKEN(fPr)); break;
    3656         [ +  - ]:        324 :     case DESTINATION_MCTRLPR: m_aMathBuffer.appendClosingTag(M_TOKEN(ctrlPr)); break;
    3657         [ +  - ]:        102 :     case DESTINATION_MNUM: m_aMathBuffer.appendClosingTag(M_TOKEN(num)); break;
    3658         [ +  - ]:        102 :     case DESTINATION_MDEN: m_aMathBuffer.appendClosingTag(M_TOKEN(den)); break;
    3659         [ +  - ]:         72 :     case DESTINATION_MACC: m_aMathBuffer.appendClosingTag(M_TOKEN(acc)); break;
    3660         [ +  - ]:         72 :     case DESTINATION_MACCPR: m_aMathBuffer.appendClosingTag(M_TOKEN(accPr)); break;
    3661         [ +  - ]:        114 :     case DESTINATION_MCHR: if (!nMathToken) nMathToken = M_TOKEN(chr);
    3662         [ +  + ]:        126 :     case DESTINATION_MPOS: if (!nMathToken) nMathToken = M_TOKEN(pos);
    3663         [ +  + ]:        135 :     case DESTINATION_MVERTJC: if (!nMathToken) nMathToken = M_TOKEN(vertJc);
    3664         [ +  + ]:        141 :     case DESTINATION_MSTRIKEH: if (!nMathToken) nMathToken = M_TOKEN(strikeH);
    3665         [ +  + ]:        153 :     case DESTINATION_MDEGHIDE: if (!nMathToken) nMathToken = M_TOKEN(degHide);
    3666         [ +  + ]:        249 :     case DESTINATION_MBEGCHR: if (!nMathToken) nMathToken = M_TOKEN(begChr);
    3667         [ +  + ]:        258 :     case DESTINATION_MSEPCHR: if (!nMathToken) nMathToken = M_TOKEN(sepChr);
    3668         [ +  + ]:        354 :     case DESTINATION_MENDCHR: if (!nMathToken) nMathToken = M_TOKEN(endChr);
    3669         [ +  + ]:        360 :     case DESTINATION_MSUBHIDE: if (!nMathToken) nMathToken = M_TOKEN(subHide);
    3670         [ +  + ]:        366 :     case DESTINATION_MSUPHIDE: if (!nMathToken) nMathToken = M_TOKEN(supHide);
    3671         [ +  + ]:        384 :     case DESTINATION_MTYPE: if (!nMathToken) nMathToken = M_TOKEN(type);
    3672         [ +  + ]:        390 :     case DESTINATION_MGROW: if (!nMathToken) nMathToken = M_TOKEN(grow);
    3673                 :            :     {
    3674         [ +  - ]:        390 :         oox::formulaimport::XmlStream::AttributeList aAttribs;
    3675 [ +  - ][ +  - ]:        390 :         aAttribs[M_TOKEN(val)] = m_aStates.top().aDestinationText.makeStringAndClear();
                 [ +  - ]
    3676         [ +  - ]:        390 :         m_aMathBuffer.appendOpeningTag(nMathToken, aAttribs);
    3677         [ +  - ]:        390 :         m_aMathBuffer.appendClosingTag(nMathToken);
    3678                 :            :     }
    3679                 :        390 :     break;
    3680         [ +  - ]:        588 :     case DESTINATION_ME: m_aMathBuffer.appendClosingTag(M_TOKEN(e)); break;
    3681         [ +  - ]:          6 :     case DESTINATION_MBAR: m_aMathBuffer.appendClosingTag(M_TOKEN(bar)); break;
    3682         [ +  - ]:          6 :     case DESTINATION_MBARPR: m_aMathBuffer.appendClosingTag(M_TOKEN(barPr)); break;
    3683         [ +  - ]:        135 :     case DESTINATION_MD: m_aMathBuffer.appendClosingTag(M_TOKEN(d)); break;
    3684         [ +  - ]:        135 :     case DESTINATION_MDPR: m_aMathBuffer.appendClosingTag(M_TOKEN(dPr)); break;
    3685         [ +  - ]:         36 :     case DESTINATION_MFUNC: m_aMathBuffer.appendClosingTag(M_TOKEN(func)); break;
    3686         [ +  - ]:         33 :     case DESTINATION_MFUNCPR: m_aMathBuffer.appendClosingTag(M_TOKEN(funcPr)); break;
    3687         [ +  - ]:         36 :     case DESTINATION_MFNAME: m_aMathBuffer.appendClosingTag(M_TOKEN(fName)); break;
    3688         [ +  - ]:         18 :     case DESTINATION_MLIMLOW: m_aMathBuffer.appendClosingTag(M_TOKEN(limLow)); break;
    3689         [ +  - ]:          9 :     case DESTINATION_MLIMLOWPR: m_aMathBuffer.appendClosingTag(M_TOKEN(limLowPr)); break;
    3690         [ +  - ]:         30 :     case DESTINATION_MLIM: m_aMathBuffer.appendClosingTag(M_TOKEN(lim)); break;
    3691         [ +  - ]:          6 :     case DESTINATION_MM: m_aMathBuffer.appendClosingTag(M_TOKEN(m)); break;
    3692         [ +  - ]:          3 :     case DESTINATION_MMPR: m_aMathBuffer.appendClosingTag(M_TOKEN(mPr)); break;
    3693         [ +  - ]:         12 :     case DESTINATION_MMR: m_aMathBuffer.appendClosingTag(M_TOKEN(mr)); break;
    3694         [ +  - ]:         36 :     case DESTINATION_MNARY: m_aMathBuffer.appendClosingTag(M_TOKEN(nary)); break;
    3695         [ +  - ]:         36 :     case DESTINATION_MNARYPR: m_aMathBuffer.appendClosingTag(M_TOKEN(naryPr)); break;
    3696         [ +  - ]:         84 :     case DESTINATION_MSUB: m_aMathBuffer.appendClosingTag(M_TOKEN(sub)); break;
    3697         [ +  - ]:        162 :     case DESTINATION_MSUP: m_aMathBuffer.appendClosingTag(M_TOKEN(sup)); break;
    3698         [ +  - ]:         12 :     case DESTINATION_MLIMUPP: m_aMathBuffer.appendClosingTag(M_TOKEN(limUpp)); break;
    3699         [ +  - ]:          6 :     case DESTINATION_MLIMUPPPR: m_aMathBuffer.appendClosingTag(M_TOKEN(limUppPr)); break;
    3700         [ +  - ]:         12 :     case DESTINATION_MGROUPCHR: m_aMathBuffer.appendClosingTag(M_TOKEN(groupChr)); break;
    3701         [ +  - ]:         12 :     case DESTINATION_MGROUPCHRPR: m_aMathBuffer.appendClosingTag(M_TOKEN(groupChrPr)); break;
    3702         [ +  - ]:          6 :     case DESTINATION_MBORDERBOX: m_aMathBuffer.appendClosingTag(M_TOKEN(borderBox)); break;
    3703         [ +  - ]:          6 :     case DESTINATION_MBORDERBOXPR: m_aMathBuffer.appendClosingTag(M_TOKEN(borderBoxPr)); break;
    3704         [ +  - ]:         18 :     case DESTINATION_MRAD: m_aMathBuffer.appendClosingTag(M_TOKEN(rad)); break;
    3705         [ +  - ]:         15 :     case DESTINATION_MRADPR: m_aMathBuffer.appendClosingTag(M_TOKEN(radPr)); break;
    3706         [ +  - ]:         18 :     case DESTINATION_MDEG: m_aMathBuffer.appendClosingTag(M_TOKEN(deg)); break;
    3707         [ +  - ]:         24 :     case DESTINATION_MSSUB: m_aMathBuffer.appendClosingTag(M_TOKEN(sSub)); break;
    3708         [ +  - ]:         12 :     case DESTINATION_MSSUBPR: m_aMathBuffer.appendClosingTag(M_TOKEN(sSubPr)); break;
    3709         [ +  - ]:        102 :     case DESTINATION_MSSUP: m_aMathBuffer.appendClosingTag(M_TOKEN(sSup)); break;
    3710         [ +  - ]:         51 :     case DESTINATION_MSSUPPR: m_aMathBuffer.appendClosingTag(M_TOKEN(sSupPr)); break;
    3711         [ +  - ]:         12 :     case DESTINATION_MSSUBSUP: m_aMathBuffer.appendClosingTag(M_TOKEN(sSubSup)); break;
    3712         [ +  - ]:          6 :     case DESTINATION_MSSUBSUPPR: m_aMathBuffer.appendClosingTag(M_TOKEN(sSubSupPr)); break;
    3713         [ +  - ]:         12 :     case DESTINATION_MSPRE: m_aMathBuffer.appendClosingTag(M_TOKEN(sPre)); break;
    3714         [ +  - ]:          6 :     case DESTINATION_MSPREPR: m_aMathBuffer.appendClosingTag(M_TOKEN(sPrePr)); break;
    3715         [ +  - ]:          3 :     case DESTINATION_MBOX: m_aMathBuffer.appendClosingTag(M_TOKEN(box)); break;
    3716         [ +  - ]:         18 :     case DESTINATION_MEQARR: m_aMathBuffer.appendClosingTag(M_TOKEN(eqArr)); break;
    3717                 :       6483 :     default: break;
    3718                 :            :     }
    3719                 :            : 
    3720                 :            :     // See if we need to end a track change
    3721 [ +  - ][ +  - ]:      15072 :     RTFValue::Pointer_t pTrackchange = m_aStates.top().aCharacterSprms.find(NS_ooxml::LN_trackchange);
    3722         [ -  + ]:      15072 :     if (pTrackchange.get())
    3723                 :            :     {
    3724         [ #  # ]:          0 :         RTFSprms aTCAttributes;
    3725 [ #  # ][ #  # ]:          0 :         RTFValue::Pointer_t pValue(new RTFValue(0));
                 [ #  # ]
    3726 [ #  # ][ #  # ]:          0 :         aTCAttributes.set(NS_ooxml::LN_endtrackchange, pValue);
                 [ #  # ]
    3727 [ #  # ][ #  # ]:          0 :         writerfilter::Reference<Properties>::Pointer_t const pProperties(new RTFReferenceProperties(aTCAttributes));
         [ #  # ][ #  # ]
    3728 [ #  # ][ #  # ]:          0 :         Mapper().props(pProperties);
         [ #  # ][ #  # ]
                 [ #  # ]
    3729                 :            :     }
    3730                 :            : 
    3731                 :            :     // This is the end of the doc, see if we need to close the last section.
    3732 [ +  + ][ +  + ]:      15072 :     if (m_nGroup == 1 && !m_bFirstRun)
    3733         [ +  - ]:        324 :         sectBreak(true);
    3734                 :            : 
    3735         [ +  - ]:      15072 :     m_aStates.pop();
    3736                 :            : 
    3737                 :      15072 :     m_nGroup--;
    3738                 :            : 
    3739                 :            :     // list table
    3740         [ +  + ]:      15072 :     if (aState.nDestinationState == DESTINATION_LISTENTRY)
    3741                 :            :     {
    3742 [ +  - ][ +  - ]:         15 :         RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3743 [ +  - ][ +  - ]:         15 :         m_aListTableSprms.set(NS_ooxml::LN_CT_Numbering_abstractNum, pValue, false);
         [ +  - ][ +  - ]
    3744                 :            :     }
    3745         [ +  + ]:      15057 :     else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING)
    3746                 :            :     {
    3747         [ +  - ]:         12 :         RTFValue::Pointer_t pIdValue = aState.aTableAttributes.find(NS_rtf::LN_LSID);
    3748         [ +  - ]:         12 :         if (pIdValue.get())
    3749                 :            :         {
    3750                 :            :             // Abstract numbering
    3751         [ +  - ]:         12 :             RTFSprms aLeveltextAttributes;
    3752                 :         12 :             OUString aTextValue;
    3753         [ +  - ]:         12 :             RTFValue::Pointer_t pTextBefore = aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelText_val);
    3754         [ +  + ]:         12 :             if (pTextBefore.get())
    3755         [ +  - ]:          9 :                 aTextValue += pTextBefore->getString();
    3756                 :         12 :             aTextValue += "%1";
    3757         [ +  - ]:         12 :             RTFValue::Pointer_t pTextAfter = aState.aTableAttributes.find(NS_ooxml::LN_CT_LevelSuffix_val);
    3758         [ +  + ]:         12 :             if (pTextAfter.get())
    3759         [ +  - ]:          9 :                 aTextValue += pTextAfter->getString();
    3760 [ +  - ][ +  - ]:         12 :             RTFValue::Pointer_t pTextValue(new RTFValue(aTextValue));
                 [ +  - ]
    3761 [ +  - ][ +  - ]:         12 :             aLeveltextAttributes.set(NS_ooxml::LN_CT_LevelText_val, pTextValue);
                 [ +  - ]
    3762                 :            : 
    3763         [ +  - ]:         12 :             RTFSprms aLevelAttributes;
    3764         [ +  - ]:         12 :             RTFSprms aLevelSprms;
    3765 [ +  - ][ +  - ]:         12 :             RTFValue::Pointer_t pIlvlValue(new RTFValue(0));
                 [ +  - ]
    3766 [ +  - ][ +  - ]:         12 :             aLevelAttributes.set(NS_ooxml::LN_CT_Lvl_ilvl, pIlvlValue);
                 [ +  - ]
    3767                 :            : 
    3768         [ +  - ]:         12 :             RTFValue::Pointer_t pNfcValue = aState.aTableSprms.find(NS_rtf::LN_NFC);
    3769         [ +  - ]:         12 :             if (pNfcValue.get())
    3770 [ +  - ][ +  - ]:         12 :                 aLevelSprms.set(NS_rtf::LN_NFC, pNfcValue);
                 [ +  - ]
    3771                 :            : 
    3772         [ +  - ]:         12 :             RTFValue::Pointer_t pStartatValue = aState.aTableSprms.find(NS_rtf::LN_ISTARTAT);
    3773         [ +  - ]:         12 :             if (pStartatValue.get())
    3774 [ +  - ][ +  - ]:         12 :                 aLevelSprms.set(NS_rtf::LN_ISTARTAT, pStartatValue);
                 [ +  - ]
    3775                 :            : 
    3776 [ +  - ][ +  - ]:         12 :             RTFValue::Pointer_t pLeveltextValue(new RTFValue(aLeveltextAttributes));
         [ +  - ][ +  - ]
    3777 [ +  - ][ +  - ]:         12 :             aLevelSprms.set(NS_ooxml::LN_CT_Lvl_lvlText, pLeveltextValue);
                 [ +  - ]
    3778         [ +  - ]:         12 :             RTFValue::Pointer_t pRunProps = aState.aTableSprms.find(NS_ooxml::LN_CT_Lvl_rPr);
    3779         [ +  + ]:         12 :             if (pRunProps.get())
    3780 [ +  - ][ +  - ]:          3 :                 aLevelSprms.set(NS_ooxml::LN_CT_Lvl_rPr, pRunProps);
                 [ +  - ]
    3781                 :            : 
    3782         [ +  - ]:         12 :             RTFSprms aAbstractAttributes;
    3783         [ +  - ]:         12 :             RTFSprms aAbstractSprms;
    3784 [ +  - ][ +  - ]:         12 :             aAbstractAttributes.set(NS_ooxml::LN_CT_AbstractNum_abstractNumId, pIdValue);
                 [ +  - ]
    3785 [ +  - ][ +  - ]:         12 :             RTFValue::Pointer_t pLevelValue(new RTFValue(aLevelAttributes, aLevelSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3786 [ +  - ][ +  - ]:         12 :             aAbstractSprms.set(NS_ooxml::LN_CT_AbstractNum_lvl, pLevelValue, false);
                 [ +  - ]
    3787                 :            : 
    3788         [ +  - ]:         12 :             RTFSprms aListTableSprms;
    3789 [ +  - ][ +  - ]:         12 :             RTFValue::Pointer_t pAbstractValue(new RTFValue(aAbstractAttributes, aAbstractSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3790                 :            :             // It's important that Numbering_abstractNum and Numbering_num never overwrites previous values.
    3791 [ +  - ][ +  - ]:         12 :             aListTableSprms.set(NS_ooxml::LN_CT_Numbering_abstractNum, pAbstractValue, false);
                 [ +  - ]
    3792                 :            : 
    3793                 :            :             // Numbering
    3794         [ +  - ]:         12 :             RTFSprms aNumberingAttributes;
    3795         [ +  - ]:         12 :             RTFSprms aNumberingSprms;
    3796 [ +  - ][ +  - ]:         12 :             aNumberingAttributes.set(NS_rtf::LN_LSID, pIdValue);
                 [ +  - ]
    3797 [ +  - ][ +  - ]:         12 :             aNumberingSprms.set(NS_ooxml::LN_CT_Num_abstractNumId, pIdValue);
                 [ +  - ]
    3798 [ +  - ][ +  - ]:         12 :             RTFValue::Pointer_t pNumberingValue(new RTFValue(aNumberingAttributes, aNumberingSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3799 [ +  - ][ +  - ]:         12 :             aListTableSprms.set(NS_ooxml::LN_CT_Numbering_num, pNumberingValue, false);
                 [ +  - ]
    3800                 :            : 
    3801                 :            :             // Table
    3802         [ +  - ]:         12 :             RTFSprms aListTableAttributes;
    3803 [ +  - ][ +  - ]:         12 :             writerfilter::Reference<Properties>::Pointer_t const pProp(new RTFReferenceProperties(aListTableAttributes, aListTableSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3804                 :            : 
    3805         [ +  - ]:         12 :             RTFReferenceTable::Entries_t aListTableEntries;
    3806 [ +  - ][ +  - ]:         12 :             aListTableEntries.insert(make_pair(0, pProp));
                 [ +  - ]
    3807 [ +  - ][ +  - ]:         12 :             writerfilter::Reference<Table>::Pointer_t const pTable(new RTFReferenceTable(aListTableEntries));
                 [ +  - ]
    3808 [ +  - ][ +  - ]:         12 :             Mapper().table(NS_rtf::LN_LISTTABLE, pTable);
                 [ +  - ]
    3809                 :            : 
    3810                 :            :             // Use it
    3811 [ +  - ][ +  - ]:         12 :             lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_numPr, NS_sprm::LN_PIlvl, pIlvlValue);
         [ +  - ][ +  - ]
    3812 [ +  - ][ +  - ]:         12 :             lcl_putNestedSprm(m_aStates.top().aParagraphSprms, NS_ooxml::LN_CT_PPrBase_tabs, NS_sprm::LN_PIlfo, pIdValue);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    3813         [ +  - ]:         12 :         }
    3814                 :            :     }
    3815         [ +  + ]:      15045 :     else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING_TEXTAFTER)
    3816                 :            :     {
    3817 [ +  - ][ +  - ]:          9 :         RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
         [ +  - ][ +  - ]
    3818 [ +  - ][ +  - ]:          9 :         m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelSuffix_val, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    3819                 :            :     }
    3820         [ +  + ]:      15036 :     else if (aState.nDestinationState == DESTINATION_PARAGRAPHNUMBERING_TEXTBEFORE)
    3821                 :            :     {
    3822 [ +  - ][ +  - ]:          9 :         RTFValue::Pointer_t pValue(new RTFValue(aState.aDestinationText.makeStringAndClear(), true));
         [ +  - ][ +  - ]
    3823 [ +  - ][ +  - ]:          9 :         m_aStates.top().aTableAttributes.set(NS_ooxml::LN_CT_LevelText_val, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    3824                 :            :     }
    3825         [ +  + ]:      15027 :     else if (aState.nDestinationState == DESTINATION_LISTLEVEL)
    3826                 :            :     {
    3827 [ +  - ][ +  - ]:         24 :         RTFValue::Pointer_t pInnerValue(new RTFValue(m_aStates.top().nListLevelNum++));
         [ +  - ][ +  - ]
    3828 [ +  - ][ +  - ]:         24 :         aState.aTableAttributes.set(NS_ooxml::LN_CT_Lvl_ilvl, pInnerValue);
                 [ +  - ]
    3829                 :            : 
    3830 [ +  - ][ +  - ]:         24 :         RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3831 [ +  - ][ +  - ]:         24 :         m_aStates.top().aListLevelEntries.set(NS_ooxml::LN_CT_AbstractNum_lvl, pValue, false);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    3832                 :            :     }
    3833                 :            :     // list override table
    3834         [ +  + ]:      15003 :     else if (aState.nDestinationState == DESTINATION_LISTOVERRIDEENTRY)
    3835                 :            :     {
    3836 [ +  - ][ +  - ]:         15 :         RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes, aState.aTableSprms));
         [ +  - ][ +  - ]
                 [ +  - ]
    3837 [ +  - ][ +  - ]:         15 :         m_aListTableSprms.set(NS_ooxml::LN_CT_Numbering_num, pValue, false);
         [ +  - ][ +  - ]
    3838                 :            :     }
    3839         [ +  + ]:      14988 :     else if (aState.nDestinationState == DESTINATION_LEVELTEXT)
    3840                 :            :     {
    3841 [ +  - ][ +  - ]:         30 :         RTFValue::Pointer_t pValue(new RTFValue(aState.aTableAttributes));
         [ +  - ][ +  - ]
    3842 [ +  - ][ +  - ]:         30 :         m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_lvlText, pValue);
         [ +  - ][ +  - ]
                 [ +  - ]
    3843                 :            :     }
    3844         [ +  + ]:      14958 :     else if (aState.nDestinationState == DESTINATION_LEVELNUMBERS)
    3845 [ +  - ][ +  - ]:         30 :         m_aStates.top().aTableSprms = aState.aTableSprms;
    3846         [ +  + ]:      14928 :     else if (aState.nDestinationState == DESTINATION_FIELDINSTRUCTION)
    3847         [ +  - ]:         18 :         m_aStates.top().nFieldStatus = FIELD_INSTRUCTION;
    3848         [ +  + ]:      14910 :     else if (aState.nDestinationState == DESTINATION_FIELDRESULT)
    3849         [ +  - ]:         15 :         m_aStates.top().nFieldStatus = FIELD_RESULT;
    3850         [ +  + ]:      14895 :     else if (aState.nDestinationState == DESTINATION_FIELD)
    3851                 :            :     {
    3852         [ +  + ]:         18 :         if (aState.nFieldStatus == FIELD_INSTRUCTION)
    3853         [ +  - ]:          3 :             singleChar(0x15);
    3854                 :            :     }
    3855         [ +  + ]:      14877 :     else if (aState.nDestinationState == DESTINATION_SHAPEPROPERTYVALUEPICT)
    3856                 :            :     {
    3857         [ +  - ]:          3 :         m_aStates.top().aPicture = aState.aPicture;
    3858 [ +  - ][ +  - ]:          3 :         m_aStates.top().aDestinationText = aState.aDestinationText;
    3859                 :            :     }
    3860         [ +  + ]:      14874 :     else if (aState.nDestinationState == DESTINATION_FALT)
    3861 [ +  - ][ +  - ]:        303 :         m_aStates.top().aTableSprms = aState.aTableSprms;
    3862 [ +  + ][ +  - ]:      14571 :     else if (m_aStates.size() && m_aStates.top().nDestinationState == DESTINATION_PICT)
         [ +  + ][ +  + ]
    3863         [ +  - ]:          6 :         m_aStates.top().aPicture = aState.aPicture;
    3864 [ +  + ][ +  + ]:      14565 :     else if (aState.nDestinationState == DESTINATION_SHAPEPROPERTYNAME ||
                 [ +  + ]
    3865                 :            :             aState.nDestinationState == DESTINATION_SHAPEPROPERTYVALUE ||
    3866                 :            :             aState.nDestinationState == DESTINATION_SHAPEPROPERTY)
    3867                 :            :     {
    3868 [ +  - ][ +  - ]:       1098 :         m_aStates.top().aShape = aState.aShape;
    3869         [ +  - ]:       1098 :         m_aStates.top().aPicture = aState.aPicture;
    3870 [ +  - ][ +  - ]:       1098 :         m_aStates.top().aCharacterAttributes = aState.aCharacterAttributes;
    3871                 :            :     }
    3872 [ +  - ][ +  + ]:      13467 :     else if (aState.nDestinationState == DESTINATION_FLYMAINCONTENT ||
                 [ +  + ]
    3873                 :            :             aState.nDestinationState == DESTINATION_SHPPICT ||
    3874                 :            :             aState.nDestinationState == DESTINATION_SHAPE)
    3875         [ +  - ]:         45 :         m_aStates.top().aFrame = aState.aFrame;
    3876         [ +  + ]:      15072 :     if (m_pCurrentBuffer == &m_aSuperBuffer)
    3877                 :            :     {
    3878         [ +  - ]:         18 :         if (!m_bHasFootnote)
    3879         [ +  - ]:         18 :             replayBuffer(m_aSuperBuffer);
    3880                 :         18 :         m_pCurrentBuffer = 0;
    3881                 :         18 :         m_bHasFootnote = false;
    3882                 :            :     }
    3883         [ +  + ]:      15072 :     if (m_aStates.size())
    3884                 :            :     {
    3885         [ +  - ]:      14745 :         m_aStates.top().nCells = aState.nCells;
    3886 [ +  - ][ +  - ]:      14745 :         m_aStates.top().aTableCellsSprms = aState.aTableCellsSprms;
    3887 [ +  - ][ +  - ]:      14745 :         m_aStates.top().aTableCellsAttributes = aState.aTableCellsAttributes;
    3888                 :            :     }
    3889                 :            : 
    3890 [ +  - ][ +  - ]:      15072 :     return 0;
    3891                 :            : }
    3892                 :            : 
    3893                 :          0 : ::std::string RTFDocumentImpl::getType() const
    3894                 :            : {
    3895         [ #  # ]:          0 :     return "RTFDocumentImpl";
    3896                 :            : }
    3897                 :            : 
    3898                 :         90 : uno::Reference<lang::XMultiServiceFactory> RTFDocumentImpl::getModelFactory()
    3899                 :            : {
    3900                 :         90 :     return m_xModelFactory;
    3901                 :            : }
    3902                 :            : 
    3903                 :     742239 : RTFParserState& RTFDocumentImpl::getState()
    3904                 :            : {
    3905                 :     742239 :     return m_aStates.top();
    3906                 :            : }
    3907                 :            : 
    3908                 :     892398 : int RTFDocumentImpl::getGroup() const
    3909                 :            : {
    3910                 :     892398 :     return m_nGroup;
    3911                 :            : }
    3912                 :            : 
    3913                 :          3 : void RTFDocumentImpl::setDestinationText(OUString& rString)
    3914                 :            : {
    3915                 :          3 :     m_aStates.top().aDestinationText.setLength(0);
    3916                 :          3 :     m_aStates.top().aDestinationText.append(rString);
    3917                 :          3 : }
    3918                 :            : 
    3919                 :         36 : bool RTFDocumentImpl::replayShapetext()
    3920                 :            : {
    3921                 :         36 :     bool bRet = !m_aShapetextBuffer.empty();
    3922                 :         36 :     replayBuffer(m_aShapetextBuffer);
    3923                 :         36 :     return bRet;
    3924                 :            : }
    3925                 :            : 
    3926                 :     147642 : bool RTFDocumentImpl::getSkipUnknown()
    3927                 :            : {
    3928                 :     147642 :     return m_bSkipUnknown;
    3929                 :            : }
    3930                 :            : 
    3931                 :       1479 : void RTFDocumentImpl::setSkipUnknown(bool bSkipUnknown)
    3932                 :            : {
    3933                 :       1479 :     m_bSkipUnknown = bSkipUnknown;
    3934                 :       1479 : }
    3935                 :            : 
    3936                 :     202860 : void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex)
    3937                 :            : {
    3938 [ +  + ][ +  + ]:     202860 :     if (bUnicode && m_aUnicodeBuffer.getLength() > 0)
                 [ +  + ]
    3939                 :            :     {
    3940         [ +  - ]:        282 :         OUString aString = m_aUnicodeBuffer.makeStringAndClear();
    3941         [ +  - ]:        282 :         text(aString);
    3942                 :            :     }
    3943 [ +  + ][ +  + ]:     202860 :     if (bHex && m_aHexBuffer.getLength() > 0)
                 [ +  + ]
    3944                 :            :     {
    3945 [ +  - ][ +  - ]:       5925 :         OUString aString = OStringToOUString(m_aHexBuffer.makeStringAndClear(), m_aStates.top().nCurrentEncoding);
    3946         [ +  - ]:       5925 :         text(aString);
    3947                 :            :     }
    3948                 :     202860 : }
    3949                 :            : 
    3950                 :      15417 : RTFParserState::RTFParserState(RTFDocumentImpl *pDocumentImpl)
    3951                 :            :     : m_pDocumentImpl(pDocumentImpl),
    3952                 :            :     nInternalState(INTERNAL_NORMAL),
    3953                 :            :     nDestinationState(DESTINATION_NORMAL),
    3954                 :            :     nFieldStatus(FIELD_NONE),
    3955                 :            :     nBorderState(BORDER_NONE),
    3956                 :            :     aTableSprms(),
    3957                 :            :     aTableAttributes(),
    3958                 :            :     aCharacterSprms(),
    3959                 :            :     aCharacterAttributes(),
    3960                 :            :     aParagraphSprms(),
    3961                 :            :     aParagraphAttributes(),
    3962                 :            :     aSectionSprms(),
    3963                 :            :     aSectionAttributes(),
    3964                 :            :     aTableRowSprms(),
    3965                 :            :     aTableRowAttributes(),
    3966                 :            :     aTableCellSprms(),
    3967                 :            :     aTableCellAttributes(),
    3968                 :            :     aTableCellsSprms(),
    3969                 :            :     aTableCellsAttributes(),
    3970                 :            :     aTabAttributes(),
    3971                 :            :     aCurrentColor(),
    3972                 :            :     nCurrentEncoding(0),
    3973                 :            :     nUc(1),
    3974                 :            :     nCharsToSkip(0),
    3975                 :            :     nBinaryToRead(0),
    3976                 :            :     nListLevelNum(0),
    3977                 :            :     aListLevelEntries(),
    3978                 :            :     aLevelNumbers(),
    3979                 :            :     aPicture(),
    3980                 :            :     aShape(),
    3981                 :            :     aDrawingObject(),
    3982                 :            :     aFrame(this),
    3983                 :            :     nCellX(0),
    3984                 :            :     nCells(0),
    3985                 :            :     nInheritingCells(0),
    3986                 :            :     bIsCjk(false),
    3987                 :            :     nYear(0),
    3988                 :            :     nMonth(0),
    3989                 :            :     nDay(0),
    3990                 :            :     nHour(0),
    3991 [ +  - ][ +  - ]:      15417 :     nMinute(0)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    3992                 :            : {
    3993                 :      15417 : }
    3994                 :            : 
    3995                 :        534 : void RTFParserState::resetFrame()
    3996                 :            : {
    3997                 :        534 :     aFrame = RTFFrame(this);
    3998                 :        534 : }
    3999                 :            : 
    4000                 :      15849 : RTFColorTableEntry::RTFColorTableEntry()
    4001                 :            :     : nRed(0),
    4002                 :            :     nGreen(0),
    4003                 :      15849 :     nBlue(0)
    4004                 :            : {
    4005                 :      15849 : }
    4006                 :            : 
    4007                 :      15417 : RTFPicture::RTFPicture()
    4008                 :            :     : nWidth(0),
    4009                 :            :     nHeight(0),
    4010                 :            :     nGoalWidth(0),
    4011                 :            :     nGoalHeight(0),
    4012                 :            :     nScaleX(100),
    4013                 :            :     nScaleY(100),
    4014                 :            :     nCropT(0),
    4015                 :            :     nCropB(0),
    4016                 :            :     nCropL(0),
    4017                 :            :     nCropR(0),
    4018                 :            :     eWMetafile(0),
    4019                 :      15417 :     nStyle(BMPSTYLE_NONE)
    4020                 :            : {
    4021                 :      15417 : }
    4022                 :            : 
    4023                 :      30834 : RTFShape::RTFShape()
    4024                 :            :     : nLeft(0),
    4025                 :            :     nTop(0),
    4026                 :            :     nRight(0),
    4027                 :            :     nBottom(0),
    4028                 :            :     nHoriOrientRelation(0),
    4029                 :      30834 :     nVertOrientRelation(0)
    4030                 :            : {
    4031                 :      30834 : }
    4032                 :            : 
    4033                 :      15417 : RTFDrawingObject::RTFDrawingObject()
    4034                 :            :     : nLineColorR(0),
    4035                 :            :     nLineColorG(0),
    4036                 :            :     nLineColorB(0),
    4037                 :            :     bHasLineColor(false),
    4038                 :            :     nFillColorR(0),
    4039                 :            :     nFillColorG(0),
    4040                 :            :     nFillColorB(0),
    4041         [ +  - ]:      15417 :     bHasFillColor(false)
    4042                 :            : {
    4043                 :      15417 : }
    4044                 :            : 
    4045                 :      15951 : RTFFrame::RTFFrame(RTFParserState* pParserState)
    4046                 :            :     : m_pParserState(pParserState),
    4047                 :            :     nX(0),
    4048                 :            :     nY(0),
    4049                 :            :     nW(0),
    4050                 :            :     nH(0),
    4051                 :            :     nHoriPadding(0),
    4052                 :            :     nVertPadding(0),
    4053                 :            :     nHoriAlign(0),
    4054                 :            :     nHoriAnchor(0),
    4055                 :            :     nVertAlign(0),
    4056                 :            :     nVertAnchor(0),
    4057                 :            :     nHRule(NS_ooxml::LN_Value_wordprocessingml_ST_HeightRule_auto),
    4058                 :      15951 :     nAnchorType(0)
    4059                 :            : {
    4060                 :      15951 : }
    4061                 :            : 
    4062                 :        138 : void RTFFrame::setSprm(Id nId, Id nValue)
    4063                 :            : {
    4064         [ +  + ]:        138 :     if (m_pParserState->m_pDocumentImpl->getFirstRun())
    4065                 :            :     {
    4066                 :         12 :         m_pParserState->m_pDocumentImpl->checkFirstRun();
    4067                 :         12 :         m_pParserState->m_pDocumentImpl->setNeedPar(false);
    4068                 :            :     }
    4069   [ +  +  +  +  :        138 :     switch (nId)
          -  -  +  +  +  
                   +  - ]
    4070                 :            :     {
    4071                 :            :         case NS_sprm::LN_PDxaWidth:
    4072                 :         18 :             nW = nValue;
    4073                 :         18 :             break;
    4074                 :            :         case NS_sprm::LN_PWHeightAbs:
    4075                 :         18 :             nH = nValue;
    4076                 :         18 :             break;
    4077                 :            :         case NS_ooxml::LN_CT_FramePr_x:
    4078                 :         18 :             nX = nValue;
    4079                 :         18 :             break;
    4080                 :            :         case NS_ooxml::LN_CT_FramePr_y:
    4081                 :         18 :             nY = nValue;
    4082                 :         18 :             break;
    4083                 :            :         case NS_sprm::LN_PDxaFromText:
    4084                 :          0 :             nHoriPadding = nValue;
    4085                 :          0 :             break;
    4086                 :            :         case NS_sprm::LN_PDyaFromText:
    4087                 :          0 :             nVertPadding = nValue;
    4088                 :          0 :             break;
    4089                 :            :         case NS_ooxml::LN_CT_FramePr_xAlign:
    4090                 :         18 :             nHoriAlign = nValue;
    4091                 :         18 :             break;
    4092                 :            :         case NS_ooxml::LN_CT_FramePr_hAnchor:
    4093                 :         12 :             nHoriAnchor = nValue;
    4094                 :         12 :             break;
    4095                 :            :         case NS_ooxml::LN_CT_FramePr_yAlign:
    4096                 :         18 :             nVertAlign = nValue;
    4097                 :         18 :             break;
    4098                 :            :         case NS_ooxml::LN_CT_FramePr_vAnchor:
    4099                 :         18 :             nVertAnchor = nValue;
    4100                 :         18 :             break;
    4101                 :            :         default:
    4102                 :          0 :             break;
    4103                 :            :     }
    4104                 :        138 : }
    4105                 :            : 
    4106                 :         24 : RTFSprms RTFFrame::getSprms()
    4107                 :            : {
    4108         [ +  - ]:         24 :     RTFSprms sprms;
    4109                 :            : 
    4110                 :            :     static Id pNames[] =
    4111                 :            :     {
    4112                 :            :         NS_ooxml::LN_CT_FramePr_x,
    4113                 :            :         NS_ooxml::LN_CT_FramePr_y,
    4114                 :            :         NS_ooxml::LN_CT_FramePr_hRule, // Make sure nHRule is processed before nH
    4115                 :            :         NS_sprm::LN_PWHeightAbs,
    4116                 :            :         NS_sprm::LN_PDxaWidth,
    4117                 :            :         NS_sprm::LN_PDxaFromText,
    4118                 :            :         NS_sprm::LN_PDyaFromText,
    4119                 :            :         NS_ooxml::LN_CT_FramePr_hAnchor,
    4120                 :            :         NS_ooxml::LN_CT_FramePr_vAnchor,
    4121                 :            :         NS_ooxml::LN_CT_FramePr_xAlign,
    4122                 :            :         NS_ooxml::LN_CT_FramePr_yAlign,
    4123                 :            :         NS_sprm::LN_PWr,
    4124                 :            :         NS_ooxml::LN_CT_FramePr_dropCap,
    4125                 :            :         NS_ooxml::LN_CT_FramePr_lines
    4126                 :            :     };
    4127                 :            : 
    4128         [ +  + ]:        360 :     for ( int i = 0, len = SAL_N_ELEMENTS(pNames); i < len; ++i )
    4129                 :            :     {
    4130                 :        336 :         Id nId = pNames[i];
    4131         [ +  - ]:        336 :         RTFValue::Pointer_t pValue;
    4132                 :            : 
    4133   [ +  +  +  +  :        336 :         switch ( nId )
          +  +  +  +  +  
                +  +  + ]
    4134                 :            :         {
    4135                 :            :             case NS_ooxml::LN_CT_FramePr_x:
    4136         [ +  - ]:         24 :                 if ( nX != 0 )
    4137 [ +  - ][ +  - ]:         24 :                     pValue.reset(new RTFValue(nX));
                 [ +  - ]
    4138                 :         24 :                 break;
    4139                 :            :             case NS_ooxml::LN_CT_FramePr_y:
    4140         [ +  - ]:         24 :                 if ( nY != 0 )
    4141 [ +  - ][ +  - ]:         24 :                     pValue.reset(new RTFValue(nY));
                 [ +  - ]
    4142                 :         24 :                 break;
    4143                 :            :             case NS_sprm::LN_PWHeightAbs:
    4144         [ +  - ]:         24 :                 if ( nH != 0 )
    4145                 :            :                 {
    4146         [ +  - ]:         24 :                     if (nHRule == NS_ooxml::LN_Value_wordprocessingml_ST_HeightRule_exact)
    4147 [ +  - ][ +  - ]:         24 :                         pValue.reset(new RTFValue(-nH)); // The negative value just sets nHRule
                 [ +  - ]
    4148                 :            :                     else
    4149 [ #  # ][ #  # ]:          0 :                         pValue.reset(new RTFValue(nH));
                 [ #  # ]
    4150                 :            :                 }
    4151                 :         24 :                 break;
    4152                 :            :             case NS_sprm::LN_PDxaWidth:
    4153         [ +  - ]:         24 :                 if ( nW != 0 )
    4154 [ +  - ][ +  - ]:         24 :                     pValue.reset(new RTFValue(nW));
                 [ +  - ]
    4155                 :         24 :                 break;
    4156                 :            :             case NS_sprm::LN_PDxaFromText:
    4157         [ -  + ]:         24 :                 if ( nHoriPadding != 0 )
    4158 [ #  # ][ #  # ]:          0 :                     pValue.reset(new RTFValue(nHoriPadding));
                 [ #  # ]
    4159                 :         24 :                 break;
    4160                 :            :             case NS_sprm::LN_PDyaFromText:
    4161         [ -  + ]:         24 :                 if ( nVertPadding != 0 )
    4162 [ #  # ][ #  # ]:          0 :                     pValue.reset(new RTFValue(nVertPadding));
                 [ #  # ]
    4163                 :         24 :                 break;
    4164                 :            :             case NS_ooxml::LN_CT_FramePr_hAnchor:
    4165         [ +  + ]:         24 :                 if ( nHoriAnchor != 0 )
    4166 [ +  - ][ +  - ]:         18 :                     pValue.reset(new RTFValue(nHoriAnchor));
                 [ +  - ]
    4167                 :         24 :                 break;
    4168                 :            :             case NS_ooxml::LN_CT_FramePr_vAnchor:
    4169         [ +  - ]:         24 :                 if ( nVertAnchor != 0 )
    4170 [ +  - ][ +  - ]:         24 :                     pValue.reset(new RTFValue(nVertAnchor));
                 [ +  - ]
    4171                 :         24 :                 break;
    4172                 :            :             case NS_ooxml::LN_CT_FramePr_xAlign:
    4173 [ +  - ][ +  - ]:         24 :                 pValue.reset(new RTFValue(nHoriAlign));
                 [ +  - ]
    4174                 :         24 :                 break;
    4175                 :            :             case NS_ooxml::LN_CT_FramePr_yAlign:
    4176 [ +  - ][ +  - ]:         24 :                 pValue.reset(new RTFValue(nVertAlign));
                 [ +  - ]
    4177                 :         24 :                 break;
    4178                 :            :             case NS_ooxml::LN_CT_FramePr_hRule:
    4179                 :            :                 {
    4180         [ +  - ]:         24 :                     if ( nH < 0 )
    4181                 :         24 :                         nHRule = NS_ooxml::LN_Value_wordprocessingml_ST_HeightRule_exact;
    4182         [ #  # ]:          0 :                     else if ( nH > 0 )
    4183                 :          0 :                         nHRule = NS_ooxml::LN_Value_wordprocessingml_ST_HeightRule_atLeast;
    4184 [ +  - ][ +  - ]:         24 :                     pValue.reset(new RTFValue(nHRule));
                 [ +  - ]
    4185                 :         24 :                     break;
    4186                 :            :                 }
    4187                 :            :             default:
    4188                 :         72 :                 break;
    4189                 :            :         }
    4190                 :            : 
    4191         [ +  + ]:        336 :         if (pValue.get())
    4192 [ +  - ][ +  - ]:        210 :             sprms.set(nId, pValue);
                 [ +  - ]
    4193         [ +  - ]:        336 :     }
    4194                 :            : 
    4195         [ +  - ]:         24 :     RTFSprms frameprSprms;
    4196 [ +  - ][ +  - ]:         24 :     RTFValue::Pointer_t pFrameprValue(new RTFValue(sprms));
         [ +  - ][ +  - ]
    4197 [ +  - ][ +  - ]:         24 :     frameprSprms.set(NS_ooxml::LN_CT_PPrBase_framePr, pFrameprValue);
                 [ +  - ]
    4198                 :            : 
    4199         [ +  - ]:         24 :     return frameprSprms;
    4200                 :            : }
    4201                 :            : 
    4202                 :       1728 : bool RTFFrame::hasProperties()
    4203                 :            : {
    4204                 :            :     return nX != 0 || nY != 0 || nW != 0 || nH != 0 ||
    4205                 :            :         nHoriPadding != 0 || nVertPadding != 0 ||
    4206                 :            :         nHoriAlign != 0 || nHoriAnchor != 0 || nVertAlign != 0 || nVertAnchor != 0 ||
    4207 [ +  + ][ +  - ]:       1728 :         nAnchorType != 0;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ -  + ]
    4208                 :            : }
    4209                 :            : 
    4210                 :            : } // namespace rtftok
    4211 [ +  - ][ +  - ]:         60 : } // namespace writerfilter
    4212                 :            : 
    4213                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10