LCOV - code coverage report
Current view: top level - writerperfect/source/filter - ListStyle.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 100 0.0 %
Date: 2012-08-25 Functions: 0 12 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 460 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /* ListStyle: Stores (and writes) list-based information that is
       3                 :            :  * needed at the head of an OO document.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  */
       9                 :            : 
      10                 :            : /* "This product is not manufactured, approved, or supported by
      11                 :            :  * Corel Corporation or Corel Corporation Limited."
      12                 :            :  */
      13                 :            : #include "FilterInternal.hxx"
      14                 :            : #include "ListStyle.hxx"
      15                 :            : #include "DocumentElement.hxx"
      16                 :            : 
      17                 :          0 : OrderedListLevelStyle::OrderedListLevelStyle(const WPXPropertyList &xPropList) :
      18         [ #  # ]:          0 :     mPropList(xPropList)
      19                 :            : {
      20                 :          0 : }
      21                 :            : 
      22                 :          0 : void OrderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList &xPropList)
      23                 :            : {
      24         [ #  # ]:          0 :     if (iLevel < 0)
      25                 :          0 :         return;
      26         [ #  # ]:          0 :     if (!isListLevelDefined(iLevel))
      27         [ #  # ]:          0 :         setListLevel(iLevel, new OrderedListLevelStyle(xPropList));
      28                 :            : }
      29                 :            : 
      30                 :          0 : void OrderedListLevelStyle::write(OdfDocumentHandler *pHandler, int iLevel) const
      31                 :            : {
      32         [ #  # ]:          0 :     WPXString sLevel;
      33         [ #  # ]:          0 :     sLevel.sprintf("%i", (iLevel+1));
      34                 :            : 
      35 [ #  # ][ #  # ]:          0 :     TagOpenElement listLevelStyleOpen("text:list-level-style-number");
                 [ #  # ]
      36 [ #  # ][ #  # ]:          0 :     listLevelStyleOpen.addAttribute("text:level", sLevel);
                 [ #  # ]
      37 [ #  # ][ #  # ]:          0 :     listLevelStyleOpen.addAttribute("text:style-name", "Numbering_Symbols");
         [ #  # ][ #  # ]
                 [ #  # ]
      38 [ #  # ][ #  # ]:          0 :     if (mPropList["style:num-prefix"])
      39                 :            :     {
      40 [ #  # ][ #  # ]:          0 :         WPXString sEscapedString(mPropList["style:num-prefix"]->getStr(), true);
         [ #  # ][ #  # ]
      41 [ #  # ][ #  # ]:          0 :         listLevelStyleOpen.addAttribute("style:num-prefix", sEscapedString);
         [ #  # ][ #  # ]
      42                 :            :     }
      43 [ #  # ][ #  # ]:          0 :     if (mPropList["style:num-suffix"])
      44                 :            :     {
      45 [ #  # ][ #  # ]:          0 :         WPXString sEscapedString(mPropList["style:num-suffix"]->getStr(), true);
         [ #  # ][ #  # ]
      46 [ #  # ][ #  # ]:          0 :         listLevelStyleOpen.addAttribute("style:num-suffix", sEscapedString);
         [ #  # ][ #  # ]
      47                 :            :     }
      48 [ #  # ][ #  # ]:          0 :     if (mPropList["style:num-format"])
      49 [ #  # ][ #  # ]:          0 :         listLevelStyleOpen.addAttribute("style:num-format", mPropList["style:num-format"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      50 [ #  # ][ #  # ]:          0 :     if (mPropList["text:start-value"])
      51                 :            :     {
      52                 :            :         // odf as to the version 1.1 does require the text:start-value to be a positive integer, means > 0
      53 [ #  # ][ #  # ]:          0 :         if (mPropList["text:start-value"]->getInt() > 0)
                 [ #  # ]
      54 [ #  # ][ #  # ]:          0 :             listLevelStyleOpen.addAttribute("text:start-value", mPropList["text:start-value"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      55                 :            :         else
      56 [ #  # ][ #  # ]:          0 :             listLevelStyleOpen.addAttribute("text:start-value", "1");
         [ #  # ][ #  # ]
                 [ #  # ]
      57                 :            :     }
      58         [ #  # ]:          0 :     listLevelStyleOpen.write(pHandler);
      59                 :            : 
      60 [ #  # ][ #  # ]:          0 :     TagOpenElement stylePropertiesOpen("style:list-level-properties");
                 [ #  # ]
      61 [ #  # ][ #  # ]:          0 :     if (mPropList["text:space-before"] && mPropList["text:space-before"]->getDouble() > 0.0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      62 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("text:space-before", mPropList["text:space-before"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      63 [ #  # ][ #  # ]:          0 :     if (mPropList["text:min-label-width"] && mPropList["text:min-label-width"]->getDouble() > 0.0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      64 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("text:min-label-width", mPropList["text:min-label-width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      65 [ #  # ][ #  # ]:          0 :     if (mPropList["text:min-label-distance"] && mPropList["text:min-label-distance"]->getDouble() > 0.0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      66 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("text:min-label-distance", mPropList["text:min-label-distance"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      67         [ #  # ]:          0 :     stylePropertiesOpen.write(pHandler);
      68                 :            : 
      69         [ #  # ]:          0 :     pHandler->endElement("style:list-level-properties");
      70 [ #  # ][ #  # ]:          0 :     pHandler->endElement("text:list-level-style-number");
         [ #  # ][ #  # ]
      71                 :          0 : }
      72                 :            : 
      73                 :          0 : UnorderedListLevelStyle::UnorderedListLevelStyle(const WPXPropertyList &xPropList)
      74         [ #  # ]:          0 :     : mPropList(xPropList)
      75                 :            : {
      76                 :          0 : }
      77                 :            : 
      78                 :          0 : void UnorderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList &xPropList)
      79                 :            : {
      80         [ #  # ]:          0 :     if (iLevel < 0)
      81                 :          0 :         return;
      82         [ #  # ]:          0 :     if (!isListLevelDefined(iLevel))
      83         [ #  # ]:          0 :         setListLevel(iLevel, new UnorderedListLevelStyle(xPropList));
      84                 :            : }
      85                 :            : 
      86                 :          0 : void UnorderedListLevelStyle::write(OdfDocumentHandler *pHandler, int iLevel) const
      87                 :            : {
      88         [ #  # ]:          0 :     WPXString sLevel;
      89         [ #  # ]:          0 :     sLevel.sprintf("%i", (iLevel+1));
      90 [ #  # ][ #  # ]:          0 :     TagOpenElement listLevelStyleOpen("text:list-level-style-bullet");
                 [ #  # ]
      91 [ #  # ][ #  # ]:          0 :     listLevelStyleOpen.addAttribute("text:level", sLevel);
                 [ #  # ]
      92 [ #  # ][ #  # ]:          0 :     listLevelStyleOpen.addAttribute("text:style-name", "Bullet_Symbols");
         [ #  # ][ #  # ]
                 [ #  # ]
      93 [ #  # ][ #  # ]:          0 :     if (mPropList["text:bullet-char"] && (mPropList["text:bullet-char"]->getStr().len()))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
      94                 :            :     {
      95                 :            :         // The following is needed because the odf format does not accept bullet chars longer than one character
      96 [ #  # ][ #  # ]:          0 :         WPXString::Iter i(mPropList["text:bullet-char"]->getStr());
         [ #  # ][ #  # ]
      97         [ #  # ]:          0 :         i.rewind();
      98         [ #  # ]:          0 :         WPXString sEscapedString(".");
      99 [ #  # ][ #  # ]:          0 :         if (i.next())
     100 [ #  # ][ #  # ]:          0 :             sEscapedString = WPXString(i(), true);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     101 [ #  # ][ #  # ]:          0 :         listLevelStyleOpen.addAttribute("text:bullet-char", sEscapedString);
         [ #  # ][ #  # ]
                 [ #  # ]
     102                 :            : 
     103                 :            :     }
     104                 :            :     else
     105 [ #  # ][ #  # ]:          0 :         listLevelStyleOpen.addAttribute("text:bullet-char", ".");
         [ #  # ][ #  # ]
                 [ #  # ]
     106         [ #  # ]:          0 :     listLevelStyleOpen.write(pHandler);
     107                 :            : 
     108 [ #  # ][ #  # ]:          0 :     TagOpenElement stylePropertiesOpen("style:list-level-properties");
                 [ #  # ]
     109 [ #  # ][ #  # ]:          0 :     if (mPropList["text:space-before"] && mPropList["text:space-before"]->getDouble() > 0.0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     110 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("text:space-before", mPropList["text:space-before"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     111 [ #  # ][ #  # ]:          0 :     if (mPropList["text:min-label-width"] && mPropList["text:min-label-width"]->getDouble() > 0.0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     112 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("text:min-label-width", mPropList["text:min-label-width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     113 [ #  # ][ #  # ]:          0 :     if (mPropList["text:min-label-distance"] && mPropList["text:min-label-distance"]->getDouble() > 0.0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     114 [ #  # ][ #  # ]:          0 :         stylePropertiesOpen.addAttribute("text:min-label-distance", mPropList["text:min-label-distance"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     115 [ #  # ][ #  # ]:          0 :     stylePropertiesOpen.addAttribute("style:font-name", "OpenSymbol");
         [ #  # ][ #  # ]
                 [ #  # ]
     116         [ #  # ]:          0 :     stylePropertiesOpen.write(pHandler);
     117                 :            : 
     118         [ #  # ]:          0 :     pHandler->endElement("style:list-level-properties");
     119 [ #  # ][ #  # ]:          0 :     pHandler->endElement("text:list-level-style-bullet");
         [ #  # ][ #  # ]
     120                 :          0 : }
     121                 :            : 
     122                 :          0 : ListStyle::ListStyle(const char *psName, const int iListID) :
     123                 :            :     Style(psName),
     124         [ #  # ]:          0 :     miListID(iListID)
     125                 :            : {
     126         [ #  # ]:          0 :     for (int i=0; i<WP6_NUM_LIST_LEVELS; ++i)
     127                 :          0 :         mppListLevels[i] = 0;
     128                 :            : 
     129                 :          0 : }
     130                 :            : 
     131                 :          0 : ListStyle::~ListStyle()
     132                 :            : {
     133         [ #  # ]:          0 :     for (int i=0; i<WP6_NUM_LIST_LEVELS; ++i)
     134                 :            :     {
     135         [ #  # ]:          0 :         if (mppListLevels[i])
     136 [ #  # ][ #  # ]:          0 :             delete(mppListLevels[i]);
     137                 :            :     }
     138                 :            : 
     139         [ #  # ]:          0 : }
     140                 :            : 
     141                 :          0 : bool ListStyle::isListLevelDefined(int iLevel) const
     142                 :            : {
     143         [ #  # ]:          0 :     if (!mppListLevels[iLevel])
     144                 :          0 :         return false;
     145                 :            : 
     146                 :          0 :     return true;
     147                 :            : }
     148                 :            : 
     149                 :          0 : void ListStyle::setListLevel(int iLevel, ListLevelStyle *iListLevelStyle)
     150                 :            : {
     151                 :            :     // can't uncomment this next line without adding some extra logic.
     152                 :            :     // figure out which is best: use the initial message, or constantly
     153                 :            :     // update?
     154         [ #  # ]:          0 :     if (!mppListLevels[iLevel])
     155                 :          0 :         mppListLevels[iLevel] = iListLevelStyle;
     156                 :          0 : }
     157                 :            : 
     158                 :          0 : void ListStyle::write(OdfDocumentHandler *pHandler) const
     159                 :            : {
     160 [ #  # ][ #  # ]:          0 :     TagOpenElement listStyleOpenElement("text:list-style");
                 [ #  # ]
     161 [ #  # ][ #  # ]:          0 :     listStyleOpenElement.addAttribute("style:name", getName());
                 [ #  # ]
     162         [ #  # ]:          0 :     listStyleOpenElement.write(pHandler);
     163                 :            : 
     164         [ #  # ]:          0 :     for (int i=0; i<WP6_NUM_LIST_LEVELS; ++i)
     165                 :            :     {
     166         [ #  # ]:          0 :         if (mppListLevels[i])
     167         [ #  # ]:          0 :             mppListLevels[i]->write(pHandler, i);
     168                 :            :     }
     169                 :            : 
     170 [ #  # ][ #  # ]:          0 :     pHandler->endElement("text:list-style");
     171                 :          0 : }
     172                 :            : 
     173                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10